diff --git a/include/clang/Basic/Module.h b/include/clang/Basic/Module.h index 6414c94a46a93ed553269e3ce6328c6e2a5cb5f4..f31a304609e9a7fb1c2c2b98e9ea597677a9c388 100644 --- a/include/clang/Basic/Module.h +++ b/include/clang/Basic/Module.h @@ -186,10 +186,7 @@ public: /// particular module. enum NameVisibilityKind { /// \brief All of the names in this module are hidden. - /// Hidden, - /// \brief Only the macro names in this module are visible. - MacrosVisible, /// \brief All of the names in this module are visible. AllVisible }; @@ -197,9 +194,6 @@ public: /// \brief The visibility of names within this particular module. NameVisibilityKind NameVisibility; - /// \brief The location at which macros within this module became visible. - SourceLocation MacroVisibilityLoc; - /// \brief The location of the inferred submodule. SourceLocation InferredSubmoduleLoc; diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index 108fc37ac27ab0151c6be638b8a1ef60d1f9b748..e3cbd79c3d7420217ef517ce2b342e9c112286dd 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -1063,6 +1063,10 @@ public: void makeModuleVisible(Module *M, SourceLocation Loc); + SourceLocation getModuleImportLoc(Module *M) const { + return VisibleModules.getImportLoc(M); + } + /// \brief Lex a string literal, which may be the concatenation of multiple /// string literals and may even come from macro expansion. /// \returns true on success, false if a error diagnostic has been generated. diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 7de6c14ef3635484408cde1c00bfc2dc78fdcbab..e1a67f9e9d11eda5f6fd4ace16535acef7bb2e4a 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -1680,12 +1680,11 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, ReplaceRange, ("@import " + PathString + ";").str()); } - // Load the module. Only make macros visible. We'll make the declarations + // Load the module to import its macros. We'll make the declarations // visible when the parser gets here. - Module::NameVisibilityKind Visibility = Module::MacrosVisible; - ModuleLoadResult Imported - = TheModuleLoader.loadModule(IncludeTok.getLocation(), Path, Visibility, - /*IsIncludeDirective=*/true); + ModuleLoadResult Imported = TheModuleLoader.loadModule( + IncludeTok.getLocation(), Path, Module::Hidden, + /*IsIncludeDirective=*/true); if (Imported) makeModuleVisible(Imported, IncludeTok.getLocation()); assert((Imported == nullptr || Imported == SuggestedModule.getModule()) && diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index 1251e982533a9b5f0b8124f24053a8e394e0a2a0..21dccd127bf8c163dc40acfa3f63db7149ae7671 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -752,7 +752,7 @@ void Preprocessor::LexAfterModuleImport(Token &Result) { if (getLangOpts().Modules) { Imported = TheModuleLoader.loadModule(ModuleImportLoc, ModuleImportPath, - Module::MacrosVisible, + Module::Hidden, /*IsIncludeDirective=*/false); if (Imported) makeModuleVisible(Imported, ModuleImportLoc); diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 150306176eb9e62a3fb7a991c7590bf99e2ca3cc..e6f35e16c4b73fc48f21ec2b72e765fbc84ca665 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -3222,10 +3222,7 @@ static void moveMethodToBackOfGlobalList(Sema &S, ObjCMethodDecl *Method) { } 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. + assert(Owner->NameVisibility != Module::Hidden && "nothing to make visible?"); for (Decl *D : Names) { bool wasHidden = D->Hidden; D->Hidden = false; @@ -3259,9 +3256,6 @@ void ASTReader::makeModuleVisible(Module *Mod, } // Update the module's name visibility. - if (NameVisibility >= Module::MacrosVisible && - Mod->NameVisibility < Module::MacrosVisible) - Mod->MacroVisibilityLoc = ImportLoc; Mod->NameVisibility = NameVisibility; // If we've already deserialized any names from this module, diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 7ea50e5003f7f0dba23bdbadea3cfe810455cfe3..377820db131ec06f040882ef991ab830b7d09f8c 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -4458,7 +4458,7 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, // FIXME: If the module has macros imported then later has declarations // imported, this location won't be the right one as a location for the // declaration imports. - AddSourceLocation(Import.M->MacroVisibilityLoc, ImportedModules); + AddSourceLocation(PP.getModuleImportLoc(Import.M), ImportedModules); } Stream.EmitRecord(IMPORTED_MODULES, ImportedModules);