[llvm] f87b410 - [FileCheck] Fix redundant diagnostics due to numeric errors

Joel E. Denny via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 17 16:27:30 PDT 2021


Author: Joel E. Denny
Date: 2021-03-17T19:25:41-04:00
New Revision: f87b4109b26732acfc382ed359c0766cfb15ed2a

URL: https://github.com/llvm/llvm-project/commit/f87b4109b26732acfc382ed359c0766cfb15ed2a
DIFF: https://github.com/llvm/llvm-project/commit/f87b4109b26732acfc382ed359c0766cfb15ed2a.diff

LOG: [FileCheck] Fix redundant diagnostics due to numeric errors

Fixed substitution printing not to produce an empty diagnostic for
errors handled elsewhere.

Reviewed By: thopre

Differential Revision: https://reviews.llvm.org/D98088

Added: 
    

Modified: 
    llvm/lib/FileCheck/FileCheck.cpp
    llvm/test/FileCheck/match-time-error-propagation/invalid-excluded-pattern.txt
    llvm/test/FileCheck/match-time-error-propagation/invalid-expected-pattern.txt

Removed: 
    


################################################################################
diff  --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp
index 2b596fdf1c5e..bcf828d20ee8 100644
--- a/llvm/lib/FileCheck/FileCheck.cpp
+++ b/llvm/lib/FileCheck/FileCheck.cpp
@@ -1362,6 +1362,8 @@ void Pattern::printSubstitutions(const SourceMgr &SM, StringRef Buffer,
               OS << " ";
               E.log(OS);
             });
+        if (!OS.tell())
+          continue;
       } else {
         // Substitution succeeded. Print substituted value.
         OS << "with \"";

diff  --git a/llvm/test/FileCheck/match-time-error-propagation/invalid-excluded-pattern.txt b/llvm/test/FileCheck/match-time-error-propagation/invalid-excluded-pattern.txt
index 7150ae78907f..4513fdc4f8fc 100644
--- a/llvm/test/FileCheck/match-time-error-propagation/invalid-excluded-pattern.txt
+++ b/llvm/test/FileCheck/match-time-error-propagation/invalid-excluded-pattern.txt
@@ -4,10 +4,6 @@
 ; At one time, FileCheck's exit status was zero for this case.  Moreover, it
 ; printed the error diagnostic only if -vv was specified and input dumps were
 ; disabled.  Test every combination as the logic is hard to get right.
-;
-; FIXME: We shouldn't have: (1) the blank note at the end of the trace, and
-; (2) the redundant error in the middle of the dump.  These will be fixed in a
-; subsequent patch.
 
 RUN: echo > %t.chk \
 RUN:      'CHECK-NOT: [[#0x8000000000000000+0x8000000000000000]] [[UNDEFVAR]]'
@@ -24,9 +20,6 @@ ERR-VV-EMPTY:
          ERR:{{.*}}: error: unable to substitute variable or numeric expression: overflow error
     ERR-NEXT:CHECK-NOT: {{.*}}
     ERR-NEXT:{{ *}}^
-    ERR-NEXT:{{.*}}: note: 
-    ERR-NEXT:10000000000000000
-    ERR-NEXT:^
     ERR-NEXT:<stdin>:1:1: note: uses undefined variable(s): "UNDEFVAR"
     ERR-NEXT:10000000000000000
     ERR-NEXT:^
@@ -36,8 +29,7 @@ ERR-VV-EMPTY:
    DUMP-NEXT:         1: 10000000000000000 
    DUMP-NEXT:not:1'0     X~~~~~~~~~~~~~~~~~ error: match failed for invalid pattern
    DUMP-NEXT:not:1'1                        unable to substitute variable or numeric expression: overflow error
-   DUMP-NEXT:not:1'2     X                  error: match failed for invalid pattern
-   DUMP-NEXT:not:1'3                        uses undefined variable(s): "UNDEFVAR"
+   DUMP-NEXT:not:1'2                        uses undefined variable(s): "UNDEFVAR"
 DUMP-VV-NEXT:         2: 
 DUMP-VV-NEXT:eof:1       ^
    DUMP-NEXT:>>>>>>

diff  --git a/llvm/test/FileCheck/match-time-error-propagation/invalid-expected-pattern.txt b/llvm/test/FileCheck/match-time-error-propagation/invalid-expected-pattern.txt
index c066c6250190..6c55b545c031 100644
--- a/llvm/test/FileCheck/match-time-error-propagation/invalid-expected-pattern.txt
+++ b/llvm/test/FileCheck/match-time-error-propagation/invalid-expected-pattern.txt
@@ -1,9 +1,5 @@
 ; Check handling of match-time diagnostics for invalid patterns (e.g.,
 ; substitution overflow) in the case of expected patterns (e.g., CHECK).
-;
-; FIXME: We shouldn't have: (1) the blank note at the end of the trace, and
-; (2) the redundant error in the middle of the dump.  These will be fixed in a
-; subsequent patch.
 
 RUN: echo > %t.chk \
 RUN:      'CHECK: [[#0x8000000000000000+0x8000000000000000]] [[UNDEFVAR]]'
@@ -13,9 +9,6 @@ RUN: echo > %t.in '10000000000000000'
       ERR:{{.*}}: error: unable to substitute variable or numeric expression: overflow error
  ERR-NEXT:CHECK: {{.*}}
  ERR-NEXT:{{ *}}^
- ERR-NEXT:{{.*}}: note: 
- ERR-NEXT:10000000000000000
- ERR-NEXT:^
  ERR-NEXT:<stdin>:1:1: note: uses undefined variable(s): "UNDEFVAR"
  ERR-NEXT:10000000000000000
  ERR-NEXT:^
@@ -25,8 +18,7 @@ RUN: echo > %t.in '10000000000000000'
 DUMP-NEXT:           1: 10000000000000000 
 DUMP-NEXT:check:1'0     X~~~~~~~~~~~~~~~~~ error: match failed for invalid pattern
 DUMP-NEXT:check:1'1                        unable to substitute variable or numeric expression: overflow error
-DUMP-NEXT:check:1'2     X                  error: match failed for invalid pattern
-DUMP-NEXT:check:1'3                        uses undefined variable(s): "UNDEFVAR"
+DUMP-NEXT:check:1'2                        uses undefined variable(s): "UNDEFVAR"
 DUMP-NEXT:>>>>>>
 
 ;--------------------------------------------------


        


More information about the llvm-commits mailing list