[all-commits] [llvm/llvm-project] 7f0e5f: [clang] Cache the analysis-based warning policy in...

Anonmiraj via All-commits all-commits at lists.llvm.org
Wed Jul 29 06:42:56 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7f0e5f9eb7466f68bb10d418421c9295bf80b345
      https://github.com/llvm/llvm-project/commit/7f0e5f9eb7466f68bb10d418421c9295bf80b345
  Author: Anonmiraj <ezzibrahimx at gmail.com>
  Date:   2026-07-29 (Wed, 29 Jul 2026)

  Changed paths:
    M clang/include/clang/Basic/Diagnostic.h
    M clang/include/clang/Sema/AnalysisBasedWarnings.h
    M clang/lib/Sema/AnalysisBasedWarnings.cpp
    M clang/lib/Sema/Sema.cpp

  Log Message:
  -----------
  [clang] Cache the analysis-based warning policy in effect (#212213)

While benchmarking with warnings enabled, I found that
`AnalysisBasedWarnings::getPolicyInEffectAt` runs at the end of every
function body, performing six location-sensitive `isIgnored()` queries.
This overhead comes from #136323 ([compile-time
impact](https://llvm-compile-time-tracker.com/compare.php?from=2a9f77f6bd48d757b2d45aadcb6cf76ef4b4ef32&to=71ce9e26aec00e4af27a69ccfab8ca1773ed7018&stat=instructions:u)).

Since these six diagnostics only depend on the diagnostic state at the
query location and whether it is in a system header or macro, we can
cache the computed policy rather than recomputing it for every function.

The cache flushes when a `#pragma clang diagnostic` changes severities,
and it bypasses active diagnostic suppression mappings.

Compile-time results for this pr:

https://llvm-compile-time-tracker.com/compare.php?from=49de424f45389cb757c3cc8c50daf38d024e2314&to=a61503b54e9568254885777cf89f5ca1586ec99f&stat=instructions%3Au



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list