diff options
author | Chris Lattner <sabre@nondot.org> | 2007-10-07 08:44:20 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-10-07 08:44:20 +0000 |
commit | c43ddc84a3d2b947ec79d1eb3f73ebb68594bccb (patch) | |
tree | 26fb2750d81acb07fbcb39848ece7824291f20b3 /clang/Lex/MacroExpander.cpp | |
parent | 259716a6e118cd93a64c2a896041b152f9ac5c24 (diff) | |
download | bcm5719-llvm-c43ddc84a3d2b947ec79d1eb3f73ebb68594bccb.tar.gz bcm5719-llvm-c43ddc84a3d2b947ec79d1eb3f73ebb68594bccb.zip |
improve layering:
Now instead of IdentifierInfo knowing anything about MacroInfo,
only the preprocessor knows. This makes MacroInfo truly private
to the Lex library (and its direct clients) instead of being
accessed in the Basic library.
llvm-svn: 42727
Diffstat (limited to 'clang/Lex/MacroExpander.cpp')
-rw-r--r-- | clang/Lex/MacroExpander.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/Lex/MacroExpander.cpp b/clang/Lex/MacroExpander.cpp index 57bdfccc110..19e39e37290 100644 --- a/clang/Lex/MacroExpander.cpp +++ b/clang/Lex/MacroExpander.cpp @@ -84,12 +84,13 @@ const Token *MacroArgs::getUnexpArgument(unsigned Arg) const { /// ArgNeedsPreexpansion - If we can prove that the argument won't be affected /// by pre-expansion, return false. Otherwise, conservatively return true. -bool MacroArgs::ArgNeedsPreexpansion(const Token *ArgTok) const { +bool MacroArgs::ArgNeedsPreexpansion(const Token *ArgTok, + Preprocessor &PP) const { // If there are no identifiers in the argument list, or if the identifiers are // known to not be macros, pre-expansion won't modify it. for (; ArgTok->getKind() != tok::eof; ++ArgTok) if (IdentifierInfo *II = ArgTok->getIdentifierInfo()) { - if (II->getMacroInfo() && II->getMacroInfo()->isEnabled()) + if (II->hasMacroDefinition() && PP.getMacroInfo(II)->isEnabled()) // Return true even though the macro could be a function-like macro // without a following '(' token. return true; @@ -238,7 +239,7 @@ void MacroExpander::Init(Token &Tok, MacroArgs *Actuals) { // associated with it. destroy(); - Macro = Tok.getIdentifierInfo()->getMacroInfo(); + Macro = PP.getMacroInfo(Tok.getIdentifierInfo()); ActualArgs = Actuals; CurToken = 0; InstantiateLoc = Tok.getLocation(); @@ -377,7 +378,7 @@ void MacroExpander::ExpandFunctionArguments() { // Only preexpand the argument if it could possibly need it. This // avoids some work in common cases. const Token *ArgTok = ActualArgs->getUnexpArgument(ArgNo); - if (ActualArgs->ArgNeedsPreexpansion(ArgTok)) + if (ActualArgs->ArgNeedsPreexpansion(ArgTok, PP)) ResultArgToks = &ActualArgs->getPreExpArgument(ArgNo, PP)[0]; else ResultArgToks = ArgTok; // Use non-preexpanded tokens. |