================ @@ -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; ---------------- haoNoQ wrote:
So every new analysis-based warning needs to be added to this list right? How weird are the consequences of forgetting it? It might be a good idea to make a unified list of analysis-based warnings. (Or like, make it a flag in `Diagnostic...Kinds.td`.) Then it may be possible to build a runtime assertion to confirm that as long as `AnalysisBasedWarnings::IssueWarnings()` is on the stack, all warnings emitted by clang are on that list. (Probably out of scope for this patch. Sounds like a lot of work. There could be easier ways to check this. Could also be too restrictive in practice.) 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