[PATCH] D98691: [FileCheck] Fix PR49531: invalid use of string var
Thomas Preud'homme via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 24 11:50:01 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG058455ffbec1: [FileCheck] Fix PR49531: invalid use of string var (authored by thopre).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98691/new/
https://reviews.llvm.org/D98691
Files:
llvm/lib/FileCheck/FileCheck.cpp
llvm/test/FileCheck/simple-var-capture.txt
llvm/unittests/FileCheck/FileCheckTest.cpp
Index: llvm/unittests/FileCheck/FileCheckTest.cpp
===================================================================
--- llvm/unittests/FileCheck/FileCheckTest.cpp
+++ llvm/unittests/FileCheck/FileCheckTest.cpp
@@ -1343,6 +1343,9 @@
// 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]]"));
Index: llvm/test/FileCheck/simple-var-capture.txt
===================================================================
--- llvm/test/FileCheck/simple-var-capture.txt
+++ llvm/test/FileCheck/simple-var-capture.txt
@@ -11,3 +11,15 @@
; 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: {{^}} ^{{$}}
Index: llvm/lib/FileCheck/FileCheck.cpp
===================================================================
--- llvm/lib/FileCheck/FileCheck.cpp
+++ llvm/lib/FileCheck/FileCheck.cpp
@@ -1083,8 +1083,15 @@
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;
+ }
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98691.333077.patch
Type: text/x-patch
Size: 2034 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210324/57505c13/attachment.bin>
More information about the llvm-commits
mailing list