[PATCH] [FileCheck] Fix a bug that cause FileCheck to misidentify check-prefix
Ron Ofir
ron.ofir at gmail.com
Fri Aug 2 12:13:56 PDT 2013
FileCheck should check to make sure the prefix was found, and not a word containing it (e.g -check-prefix=BASEREL shouldn't match NOBASEREL)
http://llvm-reviews.chandlerc.com/D1271
Files:
FileCheck.cpp
Index: FileCheck.cpp
===================================================================
--- FileCheck.cpp
+++ FileCheck.cpp
@@ -704,7 +704,9 @@
LineNumber += Buffer.substr(0, PrefixLoc).count('\n');
- Buffer = Buffer.substr(PrefixLoc);
+ // Keep the charcter before our prefix so we can validate the we have found
+ // our prefix, and account for cases when PrefixLoc is 0.
+ Buffer = Buffer.substr(std::min(PrefixLoc-1, PrefixLoc));
const char *CheckPrefixStart = Buffer.data();
@@ -713,8 +715,16 @@
bool IsCheckNext = false, IsCheckNot = false, IsCheckDag = false,
IsCheckLabel = false;
+ // Make sure we have actually found our prefix, and not a word containing
+ // our prefix.
+ if (PrefixLoc != 0 && ((Buffer[0] >= 'A' &&
+ Buffer[0] <= 'z') ||
+ (Buffer[0] >= '1' &&
+ Buffer[0] <= '9'))) {
+ Buffer = Buffer.substr(CheckPrefix.size());
+ continue;
// Verify that the : is present after the prefix.
- if (Buffer[CheckPrefix.size()] == ':') {
+ } else if (Buffer[CheckPrefix.size()] == ':') {
Buffer = Buffer.substr(CheckPrefix.size()+1);
} else if (Buffer.size() > CheckPrefix.size()+6 &&
memcmp(Buffer.data()+CheckPrefix.size(), "-NEXT:", 6) == 0) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1271.1.patch
Type: text/x-patch
Size: 1344 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130802/49ccf1b9/attachment.bin>
More information about the llvm-commits
mailing list