[llvm] [clang] [clang-tools-extra] [Clang] Fix : More Detailed "No expected directives found" (PR #78338)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 30 05:53:25 PST 2024


================
@@ -1098,7 +1098,14 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() {
     // Produce an error if no expected-* directives could be found in the
     // source file(s) processed.
     if (Status == HasNoDirectives) {
-      Diags.Report(diag::err_verify_no_directives).setForceEmit();
+      std::string Err_Directive;
+      if (Diags.getDiagnosticOptions().VerifyPrefixes.empty()) {
+        Err_Directive = "expected";
+      } else {
+        Err_Directive = *Diags.getDiagnosticOptions().VerifyPrefixes.begin();
+      }
+      Diags.Report(diag::err_verify_no_directives).setForceEmit()
+          << Err_Directive;
----------------
AaronBallman wrote:

```suggestion
      std::string ErrDirective;
      if (Diags.getDiagnosticOptions().VerifyPrefixes.empty())
        ErrDirective = "expected";
      else
        ErrDirective = *Diags.getDiagnosticOptions().VerifyPrefixes.begin();
      Diags.Report(diag::err_verify_no_directives).setForceEmit()
          << ErrDirective;
```
We might want to split this logic out into a helper function if we're also updating `err_verify_invalid_no_diags` at the same time.

https://github.com/llvm/llvm-project/pull/78338


More information about the cfe-commits mailing list