================
@@ -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) {
----------------
Endilll wrote:

> I'd expect we would produce diagnostics here respecting the relationship 
> between errors / warnings and their attached notes.

I'm not entirely sure what you have in mind, but it seems like you're asking 
for something smarter, like "this note appears after this error instead of that 
error". If that's the case, I agree that it would be nice to have, but much 
more complicated to implement (and maintain) than what I did in this patch.

> So I'd expect this to be enforced before we get here.

I'm not sure how can we enforce this before getting here, because this is the 
only place in `VerifyDiagnosticConsumer` where all kinds of diagnostics 
(errors, warning, notes, remarks) are considered together, and not separately.

> For example, right now with this patch, if a note is missing from a 
> diagnostic, but coincidentally an identical note is present on a later one, 
> we wouldn't produce a diagnostic pointing where that note is missing, since 
> we haven't checked any orderings until now, and we won't check the orderings 
> at all since the third bullet isn't satisfied.

I'm intentionally separating diagnostics about ordering from other `-verify` 
diagnostics, because single ordering error made by the user can result in 
multiple diagnostics about ordering, which can be overwhelming by themselves, 
even before you combine them with other `-verify` diagnostics. In your example, 
if you have N diagnostics emitted between points where note was missing and 
finally appeared, you'll get N ordering diagnostics issued.

https://github.com/llvm/llvm-project/pull/179835
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to