summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/PPMacroExpansion.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-04-23 20:40:50 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-04-23 20:40:50 +0000
commit713369b057bc6401e88abbc65cab1fc0a8f688e0 (patch)
tree1ff1bc32fe2a74cf60a317285bddb4407c2f57ba /clang/lib/Lex/PPMacroExpansion.cpp
parent07e2d283a39a3b2a25dd642643e74e62686b5720 (diff)
downloadbcm5719-llvm-713369b057bc6401e88abbc65cab1fc0a8f688e0.tar.gz
bcm5719-llvm-713369b057bc6401e88abbc65cab1fc0a8f688e0.zip
[modules] Store a ModuleMacro* on an imported macro directive rather than duplicating the info within it.
llvm-svn: 235644
Diffstat (limited to 'clang/lib/Lex/PPMacroExpansion.cpp')
-rw-r--r--clang/lib/Lex/PPMacroExpansion.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp
index 883f2d5ff3b..54f72f64628 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -65,21 +65,18 @@ void Preprocessor::appendMacroDirective(IdentifierInfo *II, MacroDirective *MD){
return;
for (auto *PrevMD = OldMD; PrevMD; PrevMD = PrevMD->getPrevious()) {
- // FIXME: Store a ModuleMacro * on an imported directive.
Module *DirectiveMod = getModuleForLocation(PrevMD->getLocation());
- Module *PrevOwningMod =
- PrevMD->isImported()
- ? getExternalSource()->getModule(PrevMD->getOwningModuleID())
- : DirectiveMod;
- auto *MM = getModuleMacro(PrevOwningMod, II);
- if (!MM) {
+ if (ModuleMacro *PrevMM = PrevMD->getOwningModuleMacro())
+ StoredMD.addOverriddenMacro(*this, PrevMM);
+ else if (ModuleMacro *PrevMM = getModuleMacro(DirectiveMod, II))
+ // The previous macro was from another submodule that we #included.
+ // FIXME: Create an import directive when importing a macro from a local
+ // submodule.
+ StoredMD.addOverriddenMacro(*this, PrevMM);
+ else
// We're still within the module defining the previous macro. We don't
// override it.
- assert(!PrevMD->isImported() &&
- "imported macro with no corresponding ModuleMacro");
break;
- }
- StoredMD.addOverriddenMacro(*this, MM);
// Stop once we leave the original macro's submodule.
//
OpenPOWER on IntegriCloud