[llvm-branch-commits] [clang] [release/22.x][clang] Avoid calling isInSystemMacro() too often (#182… (PR #182726)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Feb 21 21:50:47 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

…217)

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/182726.diff


1 Files Affected:

- (modified) clang/lib/Basic/DiagnosticIDs.cpp (+2-3) 


``````````diff
diff --git a/clang/lib/Basic/DiagnosticIDs.cpp b/clang/lib/Basic/DiagnosticIDs.cpp
index a1d9d0f34d20d..45aa901da307c 100644
--- a/clang/lib/Basic/DiagnosticIDs.cpp
+++ b/clang/lib/Basic/DiagnosticIDs.cpp
@@ -562,14 +562,13 @@ DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, SourceLocation Loc,
       return diag::Severity::Ignored;
   }
   // We also ignore warnings due to system macros
-  if (State->SuppressSystemWarnings && Loc.isValid() &&
-      SM.isInSystemMacro(Loc)) {
+  if (State->SuppressSystemWarnings && 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/182726


More information about the llvm-branch-commits mailing list