aboutsummaryrefslogtreecommitdiff
path: root/Lex/MacroExpander.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-10-07 08:44:20 +0000
committerChris Lattner <sabre@nondot.org>2007-10-07 08:44:20 +0000
commitcc1a875f94630e58d24a55577ffbf0e89b7da8c7 (patch)
treeca4db3025d08d21df9879e6fe968f9eac07e51b0 /Lex/MacroExpander.cpp
parent0edde55077cc3cb9fffeba19f5936f05a68c8e2b (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42727 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Lex/MacroExpander.cpp')
-rw-r--r--Lex/MacroExpander.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lex/MacroExpander.cpp b/Lex/MacroExpander.cpp
index 57bdfccc11..19e39e3729 100644
--- a/Lex/MacroExpander.cpp
+++ b/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.