[llvm-branch-commits] [clang] b03c124 - [clang] Avoid calling isInSystemMacro() too often (#182217)

Cullen Rhodes via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Feb 23 08:06:54 PST 2026


Author: Timm Baeder
Date: 2026-02-23T16:06:09Z
New Revision: b03c1244905d1f85038a8cb466991babf5fc9662

URL: https://github.com/llvm/llvm-project/commit/b03c1244905d1f85038a8cb466991babf5fc9662
DIFF: https://github.com/llvm/llvm-project/commit/b03c1244905d1f85038a8cb466991babf5fc9662.diff

LOG: [clang] Avoid calling isInSystemMacro() too often (#182217)

This caused a performance regression as reported in
https://github.com/llvm/llvm-project/pull/141950

(cherry picked from commit 6e9a308a884d18315fa3cb31693718148dfa63dd)

Added: 
    

Modified: 
    clang/lib/Basic/DiagnosticIDs.cpp

Removed: 
    


################################################################################
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.


        


More information about the llvm-branch-commits mailing list