[clang] [llvm] [clang] Add `-verify-directives` cc1 flag (PR #179835)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 3 06:49:23 PST 2026


================
@@ -1044,6 +1146,141 @@ static unsigned CheckResults(DiagnosticsEngine &Diags, SourceManager &SourceMgr,
   return NumProblems;
 }
 
+// Checks that directives are lexically in the same order as the emitted
+// diagnostics. Assumes that:
+//   - every directive matches exactly one diagnostic,
+//   - there are no wildcards, and
+//   - CheckResults returned 0 problems, i.e. every diagnostic
+//     was matched by every directive without considering the order.
+static unsigned CheckResultsAreInOrder(DiagnosticsEngine &Diags,
+                                       SourceManager &SourceMgr,
+                                       const TextDiagnosticBuffer &Buffer,
+                                       const ExpectedData &ED) {
----------------
AaronBallman wrote:

I think I'm a bit confused -- we do produce notes in isolation, that's kind of the problem (we just call `Diag()` and the diagnostics engine has to be smart enough to associate the note with another diagnostic, we don't do that hookup explicitly currently).

So I think I'm with @Endilll on this being a reasonable suggestion but something outside the scope of this PR (there are other questions afoot about associating notes with diagnostics explicitly which are related I think). But I could be missing something, too.

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


More information about the cfe-commits mailing list