diff options
| author | Douglas Gregor <dgregor@apple.com> | 2011-04-28 16:36:13 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2011-04-28 16:36:13 +0000 |
| commit | b6100f2bdcad3deb288b2c441a8de5eb053dfef3 (patch) | |
| tree | e38b7dbb8cf060e60f9ce589ba7e81e0f759dcb5 /clang/lib | |
| parent | 6cec6ab275c2c1117366b1e46d79e2b33369a8c1 (diff) | |
| download | bcm5719-llvm-b6100f2bdcad3deb288b2c441a8de5eb053dfef3.tar.gz bcm5719-llvm-b6100f2bdcad3deb288b2c441a8de5eb053dfef3.zip | |
Only call the MacroExpands callback when we're actually going to
expand the macro, based on a patch by Ori Avtalion. Fixes PR9799.
llvm-svn: 130402
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Lex/PPMacroExpansion.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index 32b2188af58..bacd62464a3 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -176,8 +176,6 @@ bool Preprocessor::isNextPPTokenLParen() { /// expanded as a macro, handle it and return the next token as 'Identifier'. bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier, MacroInfo *MI) { - if (Callbacks) Callbacks->MacroExpands(Identifier, MI); - // If this is a macro expansion in the "#if !defined(x)" line for the file, // then the macro could expand to different things in other contexts, we need // to disable the optimization in this case. @@ -185,6 +183,7 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier, // If this is a builtin macro, like __LINE__ or _Pragma, handle it specially. if (MI->isBuiltinMacro()) { + if (Callbacks) Callbacks->MacroExpands(Identifier, MI); ExpandBuiltinMacro(Identifier); return false; } @@ -225,6 +224,8 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier, // Notice that this macro has been used. markMacroAsUsed(MI); + if (Callbacks) Callbacks->MacroExpands(Identifier, MI); + // If we started lexing a macro, enter the macro expansion body. // Remember where the token is instantiated. |

