diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-09-29 01:06:04 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-09-29 01:06:04 +0000 |
commit | 43af5132c51d1dc592132488d1d8afe79057897c (patch) | |
tree | 26de14612e894cdec7e218b4ece40e64c5b8ad8f | |
parent | 051b4432429c869a3505eaa74cb3cd4802ae8909 (diff) | |
download | bcm5719-llvm-43af5132c51d1dc592132488d1d8afe79057897c.tar.gz bcm5719-llvm-43af5132c51d1dc592132488d1d8afe79057897c.zip |
In the Module class, add a reference to the corresponding AST file.
llvm-svn: 164873
-rw-r--r-- | clang/include/clang/Basic/Module.h | 19 | ||||
-rw-r--r-- | clang/lib/Basic/Module.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 3 |
3 files changed, 22 insertions, 4 deletions
diff --git a/clang/include/clang/Basic/Module.h b/clang/include/clang/Basic/Module.h index c8027f47028..cdf993cb4a1 100644 --- a/clang/include/clang/Basic/Module.h +++ b/clang/include/clang/Basic/Module.h @@ -63,6 +63,10 @@ private: /// \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 @@ public: /// \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 @@ public: 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; diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index 634884074e1..91b6207b55a 100644 --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -23,8 +23,8 @@ using namespace clang; 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) diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 6de153107f3..4cc46b8ab74 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -980,6 +980,9 @@ Module *CompilerInstance::loadModule(SourceLocation ImportLoc, 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; |