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

Shourya Goel via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 22 09:47:28 PST 2024


================
@@ -1098,7 +1098,16 @@ 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 directives;
+      for (auto &Prefix : Diags.getDiagnosticOptions().VerifyPrefixes) {
+        directives = directives + Prefix + ",";
+      }
----------------
Sh0g0-1758 wrote:

yes suppose multiple diagnostics were not found like given in the third case here : 

> ![Screenshot from 2024-01-20 00-23-12](https://private-user-images.githubusercontent.com/114918019/298168762-c8c7dcca-a1eb-4ee5-8fe7-53c7c2ac99ca.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDU5NDU2NTIsIm5iZiI6MTcwNTk0NTM1MiwicGF0aCI6Ii8xMTQ5MTgwMTkvMjk4MTY4NzYyLWM4YzdkY2NhLWExZWItNGVlNS04ZmU3LTUzYzdjMmFjOTljYS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwMTIyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDEyMlQxNzQyMzJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03ZTRjNmIwYmU4MDhhMGNhZjc3NzE2NTgwYmUzNjRiZjEzNDE5YzhmNTJmYmNhZDM3ZDBmZTg5NTUwNGViNzc2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.CEGvxZlT56vu6qZ73y9ZSxX4d2a2FhH5hYEW3Wp6sUM)

then in the error generated, I give all the diagnostics as ```consider use of 'foo,alpha,bar,gamma-no-diagnostics'```. But if that is not the intended behavior or if multiple errors are expected to be emitted in response to multiple diagnostics not found, then that can also be done. Please specify which of the two is required. 

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


More information about the cfe-commits mailing list