[clang] [clang][Lex][NFC] Reorder SrcMgr checks in CheckMacroName (PR #141483)
via cfe-commits
cfe-commits at lists.llvm.org
Mon May 26 05:08:03 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
isInPredefinedFile() will look at the presumed loc, which is comparatively slow. Move it after isInSystemFile().
http://llvm-compile-time-tracker.com/compare.php?from=843e362318e884991e517a54446b4faeacdad789&to=de0421a1a38052042721a67a6094f5cb38431f26&stat=instructions:u
---
Full diff: https://github.com/llvm/llvm-project/pull/141483.diff
1 Files Affected:
- (modified) clang/lib/Lex/PPDirectives.cpp (+2-2)
``````````diff
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index b2a8459d6b9cc..12688f0939a26 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -373,8 +373,8 @@ bool Preprocessor::CheckMacroName(Token &MacroNameTok, MacroUse isDefineUndef,
// Macro names with reserved identifiers are accepted if built-in or passed
// through the command line (the later may be present if -dD was used to
// generate the preprocessed file).
- if (!SourceMgr.isInPredefinedFile(MacroNameLoc) &&
- !SourceMgr.isInSystemHeader(MacroNameLoc)) {
+ if (!SourceMgr.isInSystemHeader(MacroNameLoc) &&
+ !SourceMgr.isInPredefinedFile(MacroNameLoc)) {
MacroDiag D = MD_NoWarn;
if (isDefineUndef == MU_Define) {
D = shouldWarnOnMacroDef(*this, II);
``````````
</details>
https://github.com/llvm/llvm-project/pull/141483
More information about the cfe-commits
mailing list