diff options
Diffstat (limited to 'clang/lib/Lex/PPMacroExpansion.cpp')
-rw-r--r-- | clang/lib/Lex/PPMacroExpansion.cpp | 19 |
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. // |