================
@@ -962,6 +962,17 @@ class DiagnosticsEngine : public 
RefCountedBase<DiagnosticsEngine> {
            diag::Severity::Ignored;
   }
 
+  bool areAllIgnored(StringRef Group, SourceLocation Loc) const {
+    llvm::SmallVector<diag::kind> diagsInGroup;
+    bool Failed = Diags->getDiagnosticsInGroup(diag::Flavor::WarningOrError,
+                                               Group, diagsInGroup);
+    assert(!Failed && "Incorrect group name?");
+    (void)Failed;
+    return llvm::all_of(diagsInGroup, [&](diag::kind DiagID) {
----------------
AaronBallman wrote:

This is a very straightforward implementation, but it also means we do a ton of 
lookup work repeatedly. My concern is for times when there are a lot of 
diagnostics in the group (like with `-Wdocumentation`); we are basically 
calling `getDiagnosticSeverity()` on every diagnostic id in the group and that 
does a fair amount of work. I was thinking we would only need to call things 
like `GetDiagStateForLoc` one time and then re-use that state when checking 
each diagnostic, that sort of thing.

Given that we want to use this interface in order to avoid doing expensive 
work, I'm not certain whether we should do that work up front or not. (Maybe 
you can test how slow it is to check this for a single id vs a group with a lot 
of ids to at least be sure we don't have anything quadratic going on? If it's 
linear time, maybe it's sufficiently fast for most groups?)

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

Reply via email to