-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[clang][Lex][NFC] Reorder SrcMgr checks in CheckMacroName #141483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
isInPredefinedFile() will look at the presumed loc, which is comparatively slow. Move it after isInSystemFile().
@llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) ChangesisInPredefinedFile() will look at the presumed loc, which is comparatively slow. Move it after isInSystemFile(). Full diff: https://github.com/llvm/llvm-project/pull/141483.diff 1 Files Affected:
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);
|
@@ -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) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like change deserves a note since it is not obvious the order matters or why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impressive gain!
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
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
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
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