[clang] 0ab4d85 - [clang][Lex] don't run -Wnonportable-include-path-separator if disabled (#191148)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 9 05:51:48 PDT 2026
Author: Rose Hudson
Date: 2026-04-09T12:51:42Z
New Revision: 0ab4d8556ddb935d3eda044cf6ea118f0686de0e
URL: https://github.com/llvm/llvm-project/commit/0ab4d8556ddb935d3eda044cf6ea118f0686de0e
DIFF: https://github.com/llvm/llvm-project/commit/0ab4d8556ddb935d3eda044cf6ea118f0686de0e.diff
LOG: [clang][Lex] don't run -Wnonportable-include-path-separator if disabled (#191148)
The diagnostic's addition caused a perf regression:
https://llvm-compile-time-tracker.com/compare.php?from=b9149823d85891044bf34e8654d1a45870e55174&to=e2294efaabcc745bf6beacbefbd371595cf3e87f&stat=instructions:u
So, only run its logic if it's actually enabled:
https://llvm-compile-time-tracker.com/compare.php?from=e2294efaabcc745bf6beacbefbd371595cf3e87f&to=52bd4e1441b75b617cf81dfffcb149966616a34a&stat=instructions:u
Added:
Modified:
clang/lib/Lex/PPDirectives.cpp
Removed:
################################################################################
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 172c2fa57db00..be2878076510d 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -2733,6 +2733,9 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport(
}
bool SuppressBackslashDiag =
+ // The diagnostic logic is expensive, so only run it if it's enabled...
+ Diags->isIgnored(diag::pp_nonportable_path_separator, FilenameLoc) ||
+ // ...and try to only trigger on paths that appear in source.
FilenameLoc.isMacroID() ||
SourceMgr.isWrittenInBuiltinFile(FilenameLoc) ||
SourceMgr.isWrittenInModuleIncludes(FilenameLoc);
More information about the cfe-commits
mailing list