summaryrefslogtreecommitdiffstats
path: root/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
commit1f468121f536d0087a5e64aa9fa7b2d4800fb3f0 (patch)
tree68511be04fca093b48365f08d7bad8235fa67864 /lib/Lex/PPExpressions.cpp
parentf6dfb10742fe2954dc75d04a29bbf14150ab883a (diff)
[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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236176 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PPExpressions.cpp')
-rw-r--r--lib/Lex/PPExpressions.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/Lex/PPExpressions.cpp b/lib/Lex/PPExpressions.cpp
index a6f16f80b7..9246fb188f 100644
--- a/lib/Lex/PPExpressions.cpp
+++ b/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()));
}