[clang] b4e0589 - [clang][Verify] Show prefix in -verify error messages
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 17 01:10:24 PDT 2023
Author: Timm Bäder
Date: 2023-08-17T10:09:50+02:00
New Revision: b4e0589b2cd98a93aad449486bb2a52ab8790781
URL: https://github.com/llvm/llvm-project/commit/b4e0589b2cd98a93aad449486bb2a52ab8790781
DIFF: https://github.com/llvm/llvm-project/commit/b4e0589b2cd98a93aad449486bb2a52ab8790781.diff
LOG: [clang][Verify] Show prefix in -verify error messages
Differential Revision: https://reviews.llvm.org/D154688
Added:
Modified:
clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
clang/test/ARCMT/verify.m
clang/test/Frontend/verify-any-file.c
clang/test/Frontend/verify-fatal.c
clang/test/Frontend/verify-ignore-unexpected.c
clang/test/Frontend/verify-unknown-arg.c
clang/test/Frontend/verify.c
clang/test/Frontend/verify2.c
clang/test/Frontend/verify3.c
clang/test/Misc/diag-verify.cpp
Removed:
################################################################################
diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
index d57b27e9e36fce..c811db86611e03 100644
--- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -876,8 +876,10 @@ static unsigned PrintUnexpected(DiagnosticsEngine &Diags, SourceManager *SourceM
OS << ": " << I->second;
}
+ std::string Prefix = *Diags.getDiagnosticOptions().VerifyPrefixes.begin();
+ std::string KindStr = Prefix + "-" + Kind;
Diags.Report(diag::err_verify_inconsistent_diags).setForceEmit()
- << Kind << /*Unexpected=*/true << OS.str();
+ << KindStr << /*Unexpected=*/true << OS.str();
return std::distance(diag_begin, diag_end);
}
@@ -907,8 +909,10 @@ static unsigned PrintExpected(DiagnosticsEngine &Diags,
OS << ": " << D->Text;
}
+ std::string Prefix = *Diags.getDiagnosticOptions().VerifyPrefixes.begin();
+ std::string KindStr = Prefix + "-" + Kind;
Diags.Report(diag::err_verify_inconsistent_diags).setForceEmit()
- << Kind << /*Unexpected=*/false << OS.str();
+ << KindStr << /*Unexpected=*/false << OS.str();
return DL.size();
}
diff --git a/clang/test/ARCMT/verify.m b/clang/test/ARCMT/verify.m
index 7480e0dc9677cf..7d245fe80575e5 100644
--- a/clang/test/ARCMT/verify.m
+++ b/clang/test/ARCMT/verify.m
@@ -12,6 +12,6 @@
// expected-error at -1 {{}}
// CHECK: error: no expected directives found: consider use of 'expected-no-diagnostics'
-// CHECK-NEXT: error: 'error' diagnostics seen but not expected:
+// CHECK-NEXT: error: 'expected-error' diagnostics seen but not expected:
// CHECK-NEXT: (frontend): error reading '{{.*}}verify.m.tmp.invalid'
// CHECK-NEXT: 2 errors generated.
diff --git a/clang/test/Frontend/verify-any-file.c b/clang/test/Frontend/verify-any-file.c
index d2c0d90b9db5a9..c5ca44fe87597e 100644
--- a/clang/test/Frontend/verify-any-file.c
+++ b/clang/test/Frontend/verify-any-file.c
@@ -7,8 +7,8 @@
// expected-error@*:123 {{invalid line : "*" required}}
//
-// CHECK: error: 'error' diagnostics expected but not seen:
+// CHECK: error: 'expected-error' diagnostics expected but not seen:
// CHECK-NEXT: File * Line * (directive at {{.*}}verify-any-file.c:6): missing error
-// CHECK-NEXT: error: 'error' diagnostics seen but not expected:
+// CHECK-NEXT: error: 'expected-error' diagnostics seen but not expected:
// CHECK-NEXT: File {{.*}}verify-any-file.c Line 8: missing or invalid line number following '@' in expected '*'
// CHECK-NEXT: 2 errors generated.
diff --git a/clang/test/Frontend/verify-fatal.c b/clang/test/Frontend/verify-fatal.c
index 1a26196efa1b85..68fdf551717461 100644
--- a/clang/test/Frontend/verify-fatal.c
+++ b/clang/test/Frontend/verify-fatal.c
@@ -7,6 +7,6 @@
// expected-error at -1 {{second fatal}}
-// CHECK: error: 'error' diagnostics expected but not seen:
+// CHECK: error: 'expected-error' diagnostics expected but not seen:
// CHECK-NEXT: Line 6 (directive at {{.*}}verify-fatal.c:7): second fatal
// CHECK-NEXT: 1 error generated.
diff --git a/clang/test/Frontend/verify-ignore-unexpected.c b/clang/test/Frontend/verify-ignore-unexpected.c
index bc3e0d16e686b8..085e23c8fcb9e7 100644
--- a/clang/test/Frontend/verify-ignore-unexpected.c
+++ b/clang/test/Frontend/verify-ignore-unexpected.c
@@ -3,7 +3,7 @@
#ifdef TEST_SWITCH
// expected-no-diagnostics
#endif
-// CHECK-BAD-SWITCH: error: 'error' diagnostics seen but not expected:
+// CHECK-BAD-SWITCH: error: 'expected-error' diagnostics seen but not expected:
// CHECK-BAD-SWITCH-NEXT: (frontend): invalid value 'aoeu' in '-verify-ignore-unexpected='
// RUN: %clang_cc1 -DTEST1 -verify %s
@@ -31,32 +31,32 @@ int x;
float x;
#endif
// CHECK-UNEXP: no expected directives found
-// CHECK-UNEXP-NEXT: 'error' diagnostics seen but not expected
+// CHECK-UNEXP-NEXT: 'expected-error' diagnostics seen but not expected
// CHECK-UNEXP-NEXT: Line {{[0-9]+}}: redefinition of 'x'
-// CHECK-UNEXP-NEXT: 'warning' diagnostics seen but not expected
+// CHECK-UNEXP-NEXT: 'expected-warning' diagnostics seen but not expected
// CHECK-UNEXP-NEXT: Line {{[0-9]+}}: MyWarning2
-// CHECK-UNEXP-NEXT: 'note' diagnostics seen but not expected
+// CHECK-UNEXP-NEXT: 'expected-note' diagnostics seen but not expected
// CHECK-UNEXP-NEXT: Line {{[0-9]+}}: previous definition is here
// CHECK-UNEXP-NEXT: 4 errors generated.
// CHECK-NOTE: no expected directives found
-// CHECK-NOTE-NEXT: 'error' diagnostics seen but not expected
+// CHECK-NOTE-NEXT: 'expected-error' diagnostics seen but not expected
// CHECK-NOTE-NEXT: Line {{[0-9]+}}: redefinition of 'x'
-// CHECK-NOTE-NEXT: 'warning' diagnostics seen but not expected
+// CHECK-NOTE-NEXT: 'expected-warning' diagnostics seen but not expected
// CHECK-NOTE-NEXT: Line {{[0-9]+}}: MyWarning2
// CHECK-NOTE-NEXT: 3 errors generated.
// CHECK-WARN: no expected directives found
-// CHECK-WARN-NEXT: 'error' diagnostics seen but not expected
+// CHECK-WARN-NEXT: 'expected-error' diagnostics seen but not expected
// CHECK-WARN-NEXT: Line {{[0-9]+}}: redefinition of 'x'
-// CHECK-WARN-NEXT: 'note' diagnostics seen but not expected
+// CHECK-WARN-NEXT: 'expected-note' diagnostics seen but not expected
// CHECK-WARN-NEXT: Line {{[0-9]+}}: previous definition is here
// CHECK-WARN-NEXT: 3 errors generated.
// CHECK-ERR: no expected directives found
-// CHECK-ERR-NEXT: 'warning' diagnostics seen but not expected
+// CHECK-ERR-NEXT: 'expected-warning' diagnostics seen but not expected
// CHECK-ERR-NEXT: Line {{[0-9]+}}: MyWarning2
-// CHECK-ERR-NEXT: 'note' diagnostics seen but not expected
+// CHECK-ERR-NEXT: 'expected-note' diagnostics seen but not expected
// CHECK-ERR-NEXT: Line {{[0-9]+}}: previous definition is here
// CHECK-ERR-NEXT: 3 errors generated.
@@ -65,7 +65,7 @@ float x;
#ifdef TEST3
// expected-error {{test3}}
#endif
-// CHECK-EXP: 'error' diagnostics expected but not seen
+// CHECK-EXP: 'expected-error' diagnostics expected but not seen
// CHECK-EXP-NEXT: Line {{[0-9]+}}: test3
// RUN: not %clang_cc1 -DTEST4 -verify -verify-ignore-unexpected %s 2>&1 \
diff --git a/clang/test/Frontend/verify-unknown-arg.c b/clang/test/Frontend/verify-unknown-arg.c
index 5767daedca3cce..c7eb8fd068286b 100644
--- a/clang/test/Frontend/verify-unknown-arg.c
+++ b/clang/test/Frontend/verify-unknown-arg.c
@@ -2,5 +2,5 @@
// expected-no-diagnostics
-// CHECK: error: 'error' diagnostics seen but not expected:
+// CHECK: error: 'expected-error' diagnostics seen but not expected:
// CHECK-NEXT: (frontend): unknown argument: '-asdf'
diff --git a/clang/test/Frontend/verify.c b/clang/test/Frontend/verify.c
index e2e7894f3b9ed4..221b715c19e416 100644
--- a/clang/test/Frontend/verify.c
+++ b/clang/test/Frontend/verify.c
@@ -48,15 +48,15 @@ unexpected b; // expected-error at 33 1-1 {{unknown type}}
// This is encapsulated in "#if 0" so that the expected-* checks below
// are not inadvertently included in the diagnostic checking!
-// CHECK2: error: 'error' diagnostics expected but not seen:
+// CHECK2: error: 'expected-error' diagnostics expected but not seen:
// CHECK2-NEXT: Line 41: define_error
// CHECK2-NEXT: Line 43: line_error
-// CHECK2-NEXT: error: 'error' diagnostics seen but not expected:
+// CHECK2-NEXT: error: 'expected-error' diagnostics seen but not expected:
// CHECK2-NEXT: Line 43: #line directive requires a positive integer argument
// CHECK2-NEXT: Line 44: AAA // expected-error {{[{][{]BBB[}][}]}} <- this shall be part of diagnostic
-// CHECK2-NEXT: error: 'warning' diagnostics expected but not seen:
+// CHECK2-NEXT: error: 'expected-warning' diagnostics expected but not seen:
// CHECK2-NEXT: Line 42: undef_error
-// CHECK2-NEXT: error: 'warning' diagnostics seen but not expected:
+// CHECK2-NEXT: error: 'expected-warning' diagnostics seen but not expected:
// CHECK2-NEXT: Line 42: extra tokens at end of #undef directive
// CHECK2-NEXT: Line 45: CCC // expected-warning {{[{][{]DDD[}][}]}} <- this shall be part of diagnostic
// CHECK2-NEXT: 7 errors generated.
@@ -78,7 +78,7 @@ unexpected b; // expected-error at 33 1-1 {{unknown type}}
# endif // expected-note {{line_78}}
#endif
-// CHECK3: error: 'note' diagnostics expected but not seen:
+// CHECK3: error: 'expected-note' diagnostics expected but not seen:
// CHECK3-NEXT: Line 67: line_67
// CHECK3-NEXT: Line 71: line_71
// CHECK3-NEXT: Line 72: line_72
@@ -91,9 +91,9 @@ unexpected b; // expected-error at 33 1-1 {{unknown type}}
#ifdef TEST4
#include "missing_header_file.include" // expected-error {{include_error}}
-// CHECK4: error: 'error' diagnostics expected but not seen:
+// CHECK4: error: 'expected-error' diagnostics expected but not seen:
// CHECK4-NEXT: Line 92: include_error
-// CHECK4-NEXT: error: 'error' diagnostics seen but not expected:
+// CHECK4-NEXT: error: 'expected-error' diagnostics seen but not expected:
// CHECK4-NEXT: Line 92: 'missing_header_file.include' file not found
// CHECK4-NEXT: 2 errors generated.
#endif
@@ -102,7 +102,7 @@ unexpected b; // expected-error at 33 1-1 {{unknown type}}
#include "verify-directive.h"
// expected-error at 50 {{source file test}}
-// CHECK5: error: 'error' diagnostics expected but not seen:
+// CHECK5: error: 'expected-error' diagnostics expected but not seen:
// CHECK5-NEXT: Line 1 (directive at {{.*}}verify-directive.h:2): include file test
// CHECK5-NEXT: Line 50 (directive at {{.*}}verify.c:103): source file test
// CHECK5-NEXT: 2 errors generated.
@@ -112,15 +112,15 @@ unexpected b; // expected-error at 33 1-1 {{unknown type}}
// RUN: not %clang_cc1 -verify %t.invalid 2>&1 | FileCheck -check-prefix=CHECK6 %s
// CHECK6: error: no expected directives found: consider use of 'expected-no-diagnostics'
-// CHECK6-NEXT: error: 'error' diagnostics seen but not expected:
+// CHECK6-NEXT: error: 'expected-error' diagnostics seen but not expected:
// CHECK6-NEXT: (frontend): error reading '{{.*}}verify.c.tmp.invalid'
// CHECK6-NEXT: 2 errors generated.
// RUN: printf '//expected-error at 2{{1}}\n#error 2\n' | not %clang_cc1 -verify 2>&1 | FileCheck -check-prefix=CHECK7 %s
-// CHECK7: error: 'error' diagnostics expected but not seen:
+// CHECK7: error: 'expected-error' diagnostics expected but not seen:
// CHECK7-NEXT: Line 2 (directive at <stdin>:1): 1
-// CHECK7-NEXT: error: 'error' diagnostics seen but not expected:
+// CHECK7-NEXT: error: 'expected-error' diagnostics seen but not expected:
// CHECK7-NEXT: Line 2: 2
// CHECK7-NEXT: 2 errors generated.
#endif
@@ -145,7 +145,15 @@ unexpected b; // expected-error at 33 1-1 {{unknown type}}
// expected-warning at verify-directive.h:1 {{diagnostic}}
-// CHECK8: error: 'warning' diagnostics expected but not seen:
+// CHECK8: error: 'expected-warning' diagnostics expected but not seen:
// CHECK8-NEXT: File {{.*}}verify-directive.h Line 1 (directive at {{.*}}verify.c:146): diagnostic
// CHECK8-NEXT: 1 error generated.
#endif
+
+
+#ifdef TEST9
+// RUN: not %clang_cc1 -DTEST9 -verify=what %s 2>&1 | FileCheck -check-prefix=CHECK9 %s
+
+// what-error {{huh?}}
+// CHECK9: error: 'what-error' diagnostics expected but not seen:
+#endif
diff --git a/clang/test/Frontend/verify2.c b/clang/test/Frontend/verify2.c
index 075a2ab6e0f01c..debaeb6b498678 100644
--- a/clang/test/Frontend/verify2.c
+++ b/clang/test/Frontend/verify2.c
@@ -13,7 +13,7 @@
// expected-error {{should be ignored}}
// CHECK: error: no expected directives found: consider use of 'expected-no-diagnostics'
-// CHECK-NEXT: error: 'error' diagnostics seen but not expected:
+// CHECK-NEXT: error: 'expected-error' diagnostics seen but not expected:
// CHECK-NEXT: Line 5: header
// CHECK-NEXT: Line 10: source
// CHECK-NEXT: 3 errors generated.
@@ -31,9 +31,9 @@
// expected-error at verify2.h:* {{header}}
// expected-error at verify2.h:* {{unknown}}
-// CHECK2: error: 'error' diagnostics expected but not seen:
+// CHECK2: error: 'expected-error' diagnostics expected but not seen:
// CHECK2-NEXT: File {{.*}}verify2.h Line * (directive at {{.*}}verify2.c:32): unknown
-// CHECK2-NEXT: error: 'error' diagnostics seen but not expected:
+// CHECK2-NEXT: error: 'expected-error' diagnostics seen but not expected:
// CHECK2-NEXT: File {{.*}}verify2.c Line 10: source
// CHECK2-NEXT: 2 errors generated.
#endif
diff --git a/clang/test/Frontend/verify3.c b/clang/test/Frontend/verify3.c
index 3898bfeedda0c4..e414c7370fad77 100644
--- a/clang/test/Frontend/verify3.c
+++ b/clang/test/Frontend/verify3.c
@@ -7,7 +7,7 @@
// expected-no-diagnostics
// expected-note {{}}
-// CHECK1: error: 'error' diagnostics seen but not expected:
+// CHECK1: error: 'expected-error' diagnostics seen but not expected:
// CHECK1-NEXT: Line 8: expected directive cannot follow 'expected-no-diagnostics' directive
// CHECK1-NEXT: 1 error generated.
#endif
@@ -18,7 +18,7 @@
// expected-warning at -1 {{X}}
// expected-no-diagnostics
-// CHECK2: error: 'error' diagnostics seen but not expected:
+// CHECK2: error: 'expected-error' diagnostics seen but not expected:
// CHECK2-NEXT: Line 19: 'expected-no-diagnostics' directive cannot follow other expected directives
// CHECK2-NEXT: 1 error generated.
#endif
diff --git a/clang/test/Misc/diag-verify.cpp b/clang/test/Misc/diag-verify.cpp
index 397558c0574d7b..2ed8c25ed81cc4 100644
--- a/clang/test/Misc/diag-verify.cpp
+++ b/clang/test/Misc/diag-verify.cpp
@@ -25,7 +25,7 @@ void test() {
x = y; // expected-error{{use of undeclared identifier 'y' identifier 'y'}}
}
-//CHECK: error: 'error' diagnostics expected but not seen:
+//CHECK: error: 'expected-error' diagnostics expected but not seen:
//CHECK: Line 17: use of undeclared identifier 'y' is fine
//CHECK: Line 18: abuse of undeclared identifier 'y'
//CHECK: Line 19: good use of undeclared identifier 'y' in code
@@ -35,7 +35,7 @@ void test() {
//CHECK: Line 23: use of undeclared identifier 'y'; please declare y before use
//CHECK: Line 24: use of use of undeclared identifier 'y'
//CHECK: Line 25: use of undeclared identifier 'y' identifier 'y'
-//CHECK: error: 'error' diagnostics seen but not expected:
+//CHECK: error: 'expected-error' diagnostics seen but not expected:
//CHECK: Line 17: use of undeclared identifier 'y'
//CHECK: Line 18: use of undeclared identifier 'y'
//CHECK: Line 19: use of undeclared identifier 'y'
More information about the cfe-commits
mailing list