================ @@ -202,6 +202,43 @@ class SemaPPCallbacks : public PPCallbacks { break; } } + void PragmaDiagnostic(SourceLocation Loc, StringRef Namespace, + diag::Severity Mapping, StringRef Str) override { + // If one of the analysis-based diagnostics was enabled while processing + // a function, we want to note it in the analysis-based warnings so they + // can be run at the end of the function body even if the analysis warnings + // are disabled at that point. + SmallVector<diag::kind, 256> GroupDiags; + diag::Flavor Flavor = + Str[1] == 'W' ? diag::Flavor::WarningOrError : diag::Flavor::Remark; + StringRef Group = Str.substr(2); + + if (S->PP.getDiagnostics().getDiagnosticIDs()->getDiagnosticsInGroup( + Flavor, Group, GroupDiags)) + return; + + for (diag::kind K : GroupDiags) { + // Note: the cases in this switch should be kept in sync with the + // diagnostics in AnalysisBasedWarnings::getPolicyInEffectAt(). + AnalysisBasedWarnings::Policy &Override = + S->AnalysisWarnings.getPolicyOverrides(); + switch (K) { + default: break; ---------------- erichkeane wrote:
At the moment, yes. As a follow-up, I would wonder if we could auto-generate this from tablegen. Though, in this patch, we could perhaps instead of doing this override, have the policy store a LIST of override diagnostics, that we then check are in the list. So this would instead of this whole switch do: `Override.DiagOverrideList.push_back(K);` That would work for ALL diagnostics, at the expense of a somewhat significant size increase. https://github.com/llvm/llvm-project/pull/136323 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits