r236376 - [modules] Remove dead code from Module for tracking macro import locations.

Richard Smith richard-llvm at metafoo.co.uk
Fri May 1 19:08:26 PDT 2015


Author: rsmith
Date: Fri May  1 21:08:26 2015
New Revision: 236376

URL: http://llvm.org/viewvc/llvm-project?rev=236376&view=rev
Log:
[modules] Remove dead code from Module for tracking macro import locations.

Modified:
    cfe/trunk/include/clang/Basic/Module.h
    cfe/trunk/include/clang/Lex/Preprocessor.h
    cfe/trunk/lib/Lex/PPDirectives.cpp
    cfe/trunk/lib/Lex/Preprocessor.cpp
    cfe/trunk/lib/Serialization/ASTReader.cpp
    cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Basic/Module.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=236376&r1=236375&r2=236376&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Module.h (original)
+++ cfe/trunk/include/clang/Basic/Module.h Fri May  1 21:08:26 2015
@@ -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;
 

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=236376&r1=236375&r2=236376&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Fri May  1 21:08:26 2015
@@ -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.

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=236376&r1=236375&r2=236376&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Fri May  1 21:08:26 2015
@@ -1680,12 +1680,11 @@ void Preprocessor::HandleIncludeDirectiv
                  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()) &&

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=236376&r1=236375&r2=236376&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Fri May  1 21:08:26 2015
@@ -752,7 +752,7 @@ void Preprocessor::LexAfterModuleImport(
     if (getLangOpts().Modules) {
       Imported = TheModuleLoader.loadModule(ModuleImportLoc,
                                             ModuleImportPath,
-                                            Module::MacrosVisible,
+                                            Module::Hidden,
                                             /*IsIncludeDirective=*/false);
       if (Imported)
         makeModuleVisible(Imported, ModuleImportLoc);

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=236376&r1=236375&r2=236376&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri May  1 21:08:26 2015
@@ -3222,10 +3222,7 @@ static void moveMethodToBackOfGlobalList
 }
 
 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
     }
 
     // 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,

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=236376&r1=236375&r2=236376&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Fri May  1 21:08:26 2015
@@ -4458,7 +4458,7 @@ void ASTWriter::WriteASTCore(Sema &SemaR
         // 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);





More information about the cfe-commits mailing list