[clang] Make -Wpadded cause us to check the layout immediately, always checking (PR #206820)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 1 05:28:54 PDT 2026


================
@@ -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


More information about the cfe-commits mailing list