]> granicus.if.org Git - llvm/commitdiff
[FileCheck] Don't scan past the closing CHECK-DAG for CHECK-NOT inside CHECK-DAG
authorBenjamin Kramer <benny.kra@googlemail.com>
Wed, 7 Jun 2017 12:06:45 +0000 (12:06 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Wed, 7 Jun 2017 12:06:45 +0000 (12:06 +0000)
If there's enough data in fron of it the skipped region would just
become arbitrarily large, and we scan for the CHECK-NOT everywhere.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304900 91177308-0d34-0410-b5e6-96231b3b80d8

test/FileCheck/check-dag.txt
utils/FileCheck/FileCheck.cpp

index 2b5a47551e835e2bca9e62c261ab9c80b4af7e94..7c5a1d18292e0c62b107e7df7e9ba46b61a26341 100644 (file)
@@ -12,6 +12,10 @@ add r11, r3, r4
 add r10, r1, r2
 mul r5, r10, r11
 
+# begin
+# end
+xor
+
 ; CHECK-DAG: add [[REG1:r[0-9]+]], r1, r2
 ; CHECK-DAG: add [[REG2:r[0-9]+]], r3, r4
 ; CHECK: mul r5, [[REG1]], [[REG2]]
@@ -24,3 +28,8 @@ mul r5, r10, r11
 ; CHECK-DAG: add [[REG2:r[0-9]+]], r3, r4
 ; CHECK-NOT: xor
 ; CHECK-DAG: mul r5, [[REG1]], [[REG2]]
+
+; CHECK-DAG: begin
+; CHECK-NOT: xor
+; CHECK-DAG: end
+; CHECK: xor
index f563cadc92c3dfba764ea8195c796399fb8c4e48..9d808cc875c0bd1902f7665b6c42128f4eaef141 100644 (file)
@@ -1203,7 +1203,7 @@ size_t CheckString::CheckDag(const SourceMgr &SM, StringRef Buffer,
       // If there's CHECK-NOTs between two CHECK-DAGs or from CHECK to
       // CHECK-DAG, verify that there's no 'not' strings occurred in that
       // region.
-      StringRef SkippedRegion = Buffer.substr(LastPos, MatchPos);
+      StringRef SkippedRegion = Buffer.slice(LastPos, MatchPos);
       if (CheckNot(SM, SkippedRegion, NotStrings, VariableTable))
         return StringRef::npos;
       // Clear "not strings".