aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/PPExpressions.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-04-29 23:20:19 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-04-29 23:20:19 +0000
commit20e883e59b4dc30d70552f14af40987db9338bb7 (patch)
tree9d2b93090e92a4da4b0158d8ed4ac246d83a3d86 /clang/lib/Lex/PPExpressions.cpp
parentbf0a42ac09f45b05345f4f1eba0bd20500681575 (diff)
downloadllvm-20e883e59b4dc30d70552f14af40987db9338bb7.zip
llvm-20e883e59b4dc30d70552f14af40987db9338bb7.tar.gz
llvm-20e883e59b4dc30d70552f14af40987db9338bb7.tar.bz2
[modules] Stop trying to fake up a linear MacroDirective history.
Modules builds fundamentally have a non-linear macro history. In the interest of better source fidelity, represent the macro definition information faithfully: we have a linear macro directive history within each module, and at any point we have a unique "latest" local macro directive and a collection of visible imported directives. This also removes the attendent complexity of attempting to create a correct MacroDirective history (which we got wrong in the general case). No functionality change intended. llvm-svn: 236176
Diffstat (limited to 'clang/lib/Lex/PPExpressions.cpp')
-rw-r--r--clang/lib/Lex/PPExpressions.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp
index a6f16f8..9246fb1 100644
--- a/clang/lib/Lex/PPExpressions.cpp
+++ b/clang/lib/Lex/PPExpressions.cpp
@@ -108,15 +108,13 @@ static bool EvaluateDefined(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
// Otherwise, we got an identifier, is it defined to something?
IdentifierInfo *II = PeekTok.getIdentifierInfo();
- Result.Val = II->hasMacroDefinition();
+ Preprocessor::MacroDefinition Macro = PP.getMacroDefinition(II);
+ Result.Val = !!Macro;
Result.Val.setIsUnsigned(false); // Result is signed intmax_t.
- MacroDirective *Macro = nullptr;
// If there is a macro, mark it used.
- if (Result.Val != 0 && ValueLive) {
- Macro = PP.getMacroDirective(II);
- PP.markMacroAsUsed(Macro->getMacroInfo());
- }
+ if (Result.Val != 0 && ValueLive)
+ PP.markMacroAsUsed(Macro.getMacroInfo());
// Save macro token for callback.
Token macroToken(PeekTok);
@@ -144,10 +142,8 @@ static bool EvaluateDefined(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
// Invoke the 'defined' callback.
if (PPCallbacks *Callbacks = PP.getPPCallbacks()) {
- MacroDirective *MD = Macro;
- // Pass the MacroInfo for the macro name even if the value is dead.
- if (!MD && Result.Val != 0)
- MD = PP.getMacroDirective(II);
+ // FIXME: Tell callbacks about module macros.
+ MacroDirective *MD = Macro.getLocalDirective();
Callbacks->Defined(macroToken, MD,
SourceRange(beginLoc, PeekTok.getLocation()));
}