From f081abcc520dfddb0373a9f8521f05210e0fdae9 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 23 Apr 2015 21:20:19 +0000 Subject: [PATCH] [modules] Remove the now-redundant import of all pending macros at the end of building a module. Since we now track module macros separately from their visibility state, this is no longer necessary. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235648 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Lex/MacroInfo.h | 3 +-- include/clang/Serialization/ASTReader.h | 3 +-- lib/Serialization/ASTReader.cpp | 35 ++++++------------------- 3 files changed, 10 insertions(+), 31 deletions(-) diff --git a/include/clang/Lex/MacroInfo.h b/include/clang/Lex/MacroInfo.h index 12f008a2ad..9d1db2ac38 100644 --- a/include/clang/Lex/MacroInfo.h +++ b/include/clang/Lex/MacroInfo.h @@ -507,8 +507,7 @@ public: class UndefMacroDirective : public MacroDirective { UndefMacroDirective(SourceLocation UndefLoc, ModuleMacro *ImportedFrom) : MacroDirective(MD_Undefine, UndefLoc, ImportedFrom) { - // FIXME: We should have a valid UndefLoc even for an imported macro. - assert((UndefLoc.isValid() || ImportedFrom) && "Invalid UndefLoc!"); + assert(UndefLoc.isValid() && "Invalid UndefLoc!"); } public: diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index 2748b83401..f6fe94ef8e 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -1366,8 +1366,7 @@ public: bool Complain); /// \brief Make the names within this set of hidden names visible. - void makeNamesVisible(const HiddenNames &Names, Module *Owner, - bool FromFinalization); + void makeNamesVisible(const HiddenNames &Names, Module *Owner); /// \brief Take the AST callbacks listener. std::unique_ptr takeListener() { diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 62fefed410..847f1ff881 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -1965,14 +1965,6 @@ void ASTReader::installImportedMacro(IdentifierInfo *II, ModuleMacroInfo &MMI, assert(II && Owner); SourceLocation ImportLoc = Owner->MacroVisibilityLoc; - if (ImportLoc.isInvalid()) { - // FIXME: If we made macros from this module visible but didn't provide a - // source location for the import, we don't have a location for the macro. - // Use the location at which the containing module file was first imported - // for now. - ImportLoc = MMI.F->DirectImportLoc; - assert(ImportLoc.isValid() && "no import location for a visible macro?"); - } AmbiguousMacros *Prev = removeOverriddenMacros(II, ImportLoc, MMI.getOverriddenMacros()); @@ -3426,8 +3418,10 @@ static void moveMethodToBackOfGlobalList(Sema &S, ObjCMethodDecl *Method) { } } -void ASTReader::makeNamesVisible(const HiddenNames &Names, Module *Owner, - bool FromFinalization) { +void ASTReader::makeNamesVisible(const HiddenNames &Names, Module *Owner) { + assert(Owner->NameVisibility >= Module::MacrosVisible && + "nothing to make visible?"); + // FIXME: Only do this if Owner->NameVisibility == AllVisible. for (Decl *D : Names.HiddenDecls) { bool wasHidden = D->Hidden; @@ -3440,15 +3434,8 @@ void ASTReader::makeNamesVisible(const HiddenNames &Names, Module *Owner, } } - assert((FromFinalization || Owner->NameVisibility >= Module::MacrosVisible) && - "nothing to make visible?"); - for (const auto &Macro : Names.HiddenMacros) { - if (FromFinalization) - PP.appendMacroDirective(Macro.first, - Macro.second->import(PP, SourceLocation())); - else - installImportedMacro(Macro.first, *Macro.second, Owner); - } + for (const auto &Macro : Names.HiddenMacros) + installImportedMacro(Macro.first, *Macro.second, Owner); } void ASTReader::makeModuleVisible(Module *Mod, @@ -3484,8 +3471,7 @@ void ASTReader::makeModuleVisible(Module *Mod, if (Hidden != HiddenNamesMap.end()) { auto HiddenNames = std::move(*Hidden); HiddenNamesMap.erase(Hidden); - makeNamesVisible(HiddenNames.second, HiddenNames.first, - /*FromFinalization*/false); + makeNamesVisible(HiddenNames.second, HiddenNames.first); assert(HiddenNamesMap.find(Mod) == HiddenNamesMap.end() && "making names visible added hidden names"); } @@ -4018,12 +4004,7 @@ void ASTReader::InitializeContext() { } void ASTReader::finalizeForWriting() { - while (!HiddenNamesMap.empty()) { - auto HiddenNames = std::move(*HiddenNamesMap.begin()); - HiddenNamesMap.erase(HiddenNamesMap.begin()); - makeNamesVisible(HiddenNames.second, HiddenNames.first, - /*FromFinalization*/true); - } + // Nothing to do for now. } /// \brief Given a cursor at the start of an AST file, scan ahead and drop the -- 2.40.0