diff options
| author | Adrian Prantl <aprantl@apple.com> | 2015-06-30 17:39:43 +0000 |
|---|---|---|
| committer | Adrian Prantl <aprantl@apple.com> | 2015-06-30 17:39:43 +0000 |
| commit | 15bcf70cdf843d3070af3e811b7b0412b55e9500 (patch) | |
| tree | fc6f06d437029b0d38652ca3911543b4690d48f7 /clang/lib | |
| parent | 1d9b5e6eced452c671e77ac924bd1fd4808716ee (diff) | |
| download | bcm5719-llvm-15bcf70cdf843d3070af3e811b7b0412b55e9500.tar.gz bcm5719-llvm-15bcf70cdf843d3070af3e811b7b0412b55e9500.zip | |
Add a function to ExternalASTSource that returns a descriptor that
abstracts the commonalities between modules and PCH files that are
needed to emit debug info for a module or precompiled header.
llvm-svn: 241083
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/ExternalASTSource.cpp | 10 | ||||
| -rw-r--r-- | clang/lib/Basic/Module.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 32 |
3 files changed, 43 insertions, 1 deletions
diff --git a/clang/lib/AST/ExternalASTSource.cpp b/clang/lib/AST/ExternalASTSource.cpp index 730842a28f6..1c82c355134 100644 --- a/clang/lib/AST/ExternalASTSource.cpp +++ b/clang/lib/AST/ExternalASTSource.cpp @@ -22,6 +22,16 @@ using namespace clang; ExternalASTSource::~ExternalASTSource() { } +llvm::Optional<ExternalASTSource::ASTSourceDescriptor> +ExternalASTSource::getSourceDescriptor(unsigned ID) { + return None; +} + +ExternalASTSource::ASTSourceDescriptor +ExternalASTSource::getSourceDescriptor(const Module &M) { + return ASTSourceDescriptor(); +} + void ExternalASTSource::FindFileRegionDecls(FileID File, unsigned Offset, unsigned Length, SmallVectorImpl<Decl *> &Decls) {} diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index 7308665bd2d..1a48a6c6a8d 100644 --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -27,7 +27,7 @@ using namespace clang; Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent, bool IsFramework, bool IsExplicit, unsigned VisibilityID) : Name(Name), DefinitionLoc(DefinitionLoc), Parent(Parent), Directory(), - Umbrella(), ASTFile(nullptr), VisibilityID(VisibilityID), + Umbrella(), Signature(0), ASTFile(nullptr), VisibilityID(VisibilityID), IsMissingRequirement(false), IsAvailable(true), IsFromModuleFile(false), IsFramework(IsFramework), IsExplicit(IsExplicit), IsSystem(false), IsExternC(false), IsInferred(false), InferSubmodules(false), diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 5e5999d5bf9..48a898cb30d 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -4269,6 +4269,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { CurrentModule->setASTFile(F.File); } + CurrentModule->Signature = F.Signature; CurrentModule->IsFromModuleFile = true; CurrentModule->IsSystem = IsSystem || CurrentModule->IsSystem; CurrentModule->IsExternC = IsExternC; @@ -7366,6 +7367,37 @@ Module *ASTReader::getModule(unsigned ID) { return getSubmodule(ID); } +ExternalASTSource::ASTSourceDescriptor +ASTReader::getSourceDescriptor(const Module &M) { + StringRef Dir, Filename; + if (M.Directory) + Dir = M.Directory->getName(); + if (auto *File = M.getASTFile()) + Filename = File->getName(); + return ASTReader::ASTSourceDescriptor{ + M.getFullModuleName(), Dir, Filename, + M.Signature + }; +} + +llvm::Optional<ExternalASTSource::ASTSourceDescriptor> +ASTReader::getSourceDescriptor(unsigned ID) { + if (const Module *M = getSubmodule(ID)) + return getSourceDescriptor(*M); + + // If there is only a single PCH, return it instead. + // Chained PCH are not suported. + if (ModuleMgr.size() == 1) { + ModuleFile &MF = ModuleMgr.getPrimaryModule(); + return ASTReader::ASTSourceDescriptor{ + MF.OriginalSourceFileName, MF.OriginalDir, + MF.FileName, + MF.Signature + }; + } + return None; +} + Selector ASTReader::getLocalSelector(ModuleFile &M, unsigned LocalID) { return DecodeSelector(getGlobalSelectorID(M, LocalID)); } |

