Skip to content

Commit 9246fcf

Browse files
tbaederrsivan-shani
authored andcommitted
[clang][Lex][NFC] Reorder SrcMgr checks in CheckMacroName (llvm#141483)
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
1 parent a236c49 commit 9246fcf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

clang/lib/Lex/PPDirectives.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,10 @@ bool Preprocessor::CheckMacroName(Token &MacroNameTok, MacroUse isDefineUndef,
373373
// Macro names with reserved identifiers are accepted if built-in or passed
374374
// through the command line (the later may be present if -dD was used to
375375
// generate the preprocessed file).
376-
if (!SourceMgr.isInPredefinedFile(MacroNameLoc) &&
377-
!SourceMgr.isInSystemHeader(MacroNameLoc)) {
376+
// NB: isInPredefinedFile() is relatively expensive, so keep it at the end
377+
// of the condition.
378+
if (!SourceMgr.isInSystemHeader(MacroNameLoc) &&
379+
!SourceMgr.isInPredefinedFile(MacroNameLoc)) {
378380
MacroDiag D = MD_NoWarn;
379381
if (isDefineUndef == MU_Define) {
380382
D = shouldWarnOnMacroDef(*this, II);

0 commit comments

Comments
 (0)