[cfe-commits] r164873 - in /cfe/trunk: include/clang/Basic/Module.h lib/Basic/Module.cpp lib/Frontend/CompilerInstance.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Fri Sep 28 18:06:05 PDT 2012


Author: akirtzidis
Date: Fri Sep 28 20:06:04 2012
New Revision: 164873

URL: http://llvm.org/viewvc/llvm-project?rev=164873&view=rev
Log:
In the Module class, add a reference to the corresponding AST file.

Modified:
    cfe/trunk/include/clang/Basic/Module.h
    cfe/trunk/lib/Basic/Module.cpp
    cfe/trunk/lib/Frontend/CompilerInstance.cpp

Modified: cfe/trunk/include/clang/Basic/Module.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=164873&r1=164872&r2=164873&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Module.h (original)
+++ cfe/trunk/include/clang/Basic/Module.h Fri Sep 28 20:06:04 2012
@@ -63,6 +63,10 @@
   /// \brief A mapping from the submodule name to the index into the 
   /// \c SubModules vector at which that submodule resides.
   llvm::StringMap<unsigned> SubModuleIndex;
+
+  /// \brief The AST file if this is a top-level module which has a
+  /// corresponding serialized AST file, or null otherwise.
+  const FileEntry *ASTFile;
   
 public:
   /// \brief The headers that are part of this module.
@@ -158,7 +162,7 @@
   /// \brief Construct a top-level module.
   explicit Module(StringRef Name, SourceLocation DefinitionLoc,
                   bool IsFramework)
-    : Name(Name), DefinitionLoc(DefinitionLoc), Parent(0), Umbrella(),
+    : Name(Name), DefinitionLoc(DefinitionLoc), Parent(0),Umbrella(),ASTFile(0),
       IsAvailable(true), IsFromModuleFile(false), IsFramework(IsFramework), 
       IsExplicit(false), IsSystem(false),
       InferSubmodules(false), InferExplicitSubmodules(false),
@@ -227,7 +231,18 @@
   StringRef getTopLevelModuleName() const {
     return getTopLevelModule()->Name;
   }
-  
+
+  /// \brief The serialized AST file for this module, if one was created.
+  const FileEntry *getASTFile() const {
+    return getTopLevelModule()->ASTFile;
+  }
+
+  /// \brief Set the serialized AST file for the top-level module of this module.
+  void setASTFile(const FileEntry *File) {
+    assert((getASTFile() == 0 || getASTFile() == File) && "file path changed");
+    getTopLevelModule()->ASTFile = File;
+  }
+
   /// \brief Retrieve the directory for which this module serves as the
   /// umbrella.
   const DirectoryEntry *getUmbrellaDir() const;

Modified: cfe/trunk/lib/Basic/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Module.cpp?rev=164873&r1=164872&r2=164873&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Module.cpp (original)
+++ cfe/trunk/lib/Basic/Module.cpp Fri Sep 28 20:06:04 2012
@@ -23,8 +23,8 @@
 
 Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent, 
                bool IsFramework, bool IsExplicit)
-  : Name(Name), DefinitionLoc(DefinitionLoc), Parent(Parent), 
-    Umbrella(), IsAvailable(true), IsFromModuleFile(false), 
+  : Name(Name), DefinitionLoc(DefinitionLoc), Parent(Parent),
+    Umbrella(), ASTFile(0), IsAvailable(true), IsFromModuleFile(false),
     IsFramework(IsFramework), IsExplicit(IsExplicit), IsSystem(false),
     InferSubmodules(false), InferExplicitSubmodules(false), 
     InferExportWildcard(false), NameVisibility(Hidden) 

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=164873&r1=164872&r2=164873&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Fri Sep 28 20:06:04 2012
@@ -980,6 +980,9 @@
       Module = PP->getHeaderSearchInfo().getModuleMap()
                  .findModule((Path[0].first->getName()));
     }
+
+    if (Module)
+      Module->setASTFile(ModuleFile);
     
     // Cache the result of this top-level module lookup for later.
     Known = KnownModules.insert(std::make_pair(Path[0].first, Module)).first;





More information about the cfe-commits mailing list