[clang] [clang] Avoid calling isInSystemMacro() too often (PR #182217)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 18 21:01:23 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
This caused a performance regression as reported in https://github.com/llvm/llvm-project/pull/141950
---
Full diff: https://github.com/llvm/llvm-project/pull/182217.diff
1 Files Affected:
- (modified) clang/lib/Basic/DiagnosticIDs.cpp (+2-2)
``````````diff
diff --git a/clang/lib/Basic/DiagnosticIDs.cpp b/clang/lib/Basic/DiagnosticIDs.cpp
index 804f0d9957f23..fcd2d9f34414e 100644
--- a/clang/lib/Basic/DiagnosticIDs.cpp
+++ b/clang/lib/Basic/DiagnosticIDs.cpp
@@ -570,13 +570,13 @@ DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, SourceLocation Loc,
// We also ignore warnings due to system macros. As above, we respect the
// ForceSystemWarnings override.
if (State->SuppressSystemWarnings && !Diag.getForceSystemWarnings() &&
- Loc.isValid() && SM.isInSystemMacro(Loc)) {
+ Loc.isValid()) {
bool ShowInSystemMacro = true;
if (const StaticDiagInfoRec *Rec = GetDiagInfo(DiagID))
ShowInSystemMacro = Rec->WarnShowInSystemMacro;
- if (!ShowInSystemMacro)
+ if (!ShowInSystemMacro && SM.isInSystemMacro(Loc))
return diag::Severity::Ignored;
}
// Clang-diagnostics pragmas always take precedence over suppression mapping.
``````````
</details>
https://github.com/llvm/llvm-project/pull/182217
More information about the cfe-commits
mailing list