mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 02:33:06 +01:00
[FileCheck] Fix PR49531: invalid use of string var
FileCheck string substitution block parsing code only report an invalid variable name in a string variable use if it starts with a forbidden character. It does not report anything if there are unparsed characters after the variable name, i.e. [[X-Y]] is parsed as [[X]] and no error is returned. This commit fixes that. Reviewed By: jdenny, jhenderson Differential Revision: https://reviews.llvm.org/D98691
This commit is contained in:
parent
4005ceb216
commit
28db0415f3
@ -1083,8 +1083,15 @@ bool Pattern::parsePattern(StringRef PatternStr, StringRef Prefix,
|
||||
if (IsPseudo) {
|
||||
MatchStr = OrigMatchStr;
|
||||
IsLegacyLineExpr = IsNumBlock = true;
|
||||
} else
|
||||
} else {
|
||||
if (!MatchStr.empty()) {
|
||||
SM.PrintMessage(SMLoc::getFromPointer(Name.data()),
|
||||
SourceMgr::DK_Error,
|
||||
"invalid name in string variable use");
|
||||
return true;
|
||||
}
|
||||
SubstStr = Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,3 +11,15 @@ op4 r30, r18, r21
|
||||
; CHECK-NEXT: op4 {{r[0-9]+}}, [[REGa]], [[REGb]]
|
||||
|
||||
|
||||
// RUN: %ProtectFileCheckOutput \
|
||||
// RUN: not FileCheck --check-prefixes INVALID-VARNAME --input-file %s %s 2>&1 \
|
||||
// RUN: | FileCheck --check-prefix INVALID-VARNAME-MSG --strict-whitespace %s
|
||||
|
||||
5
|
||||
4
|
||||
; INVALID-VARNAME: [[X:]]
|
||||
; INVALID-VARNAME-NEXT: [[Y:]]
|
||||
; INVALID-VARNAME-NEXT: [[X-Y]]
|
||||
; INVALID-VARNAME-MSG: simple-var-capture.txt:[[#@LINE-1]]:27: error: invalid name in string variable use
|
||||
; INVALID-VARNAME-MSG-NEXT: ; {{I}}NVALID-VARNAME-NEXT: {{\[\[X-Y\]\]}}
|
||||
; INVALID-VARNAME-MSG-NEXT: {{^}} ^{{$}}
|
||||
|
@ -1343,6 +1343,9 @@ TEST_F(FileCheckTest, ParsePattern) {
|
||||
// Collision with numeric variable.
|
||||
EXPECT_TRUE(Tester.parsePattern("[[FOO:]]"));
|
||||
|
||||
// Invalid use of string variable.
|
||||
EXPECT_TRUE(Tester.parsePattern("[[FOO-BAR]]"));
|
||||
|
||||
// Valid use of string variable.
|
||||
EXPECT_FALSE(Tester.parsePattern("[[BAR]]"));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user