summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2015-09-19 00:10:32 +0000
committerAdrian Prantl <aprantl@apple.com>2015-09-19 00:10:32 +0000
commitc6458d6a4d3b5b8b95794f05c555990f9b037b82 (patch)
treea7bcb64a75be80913992332278c6e6b10a2b4fcc /clang/lib
parent8bd4c13f6762220ce4c3e5121e53d0a38fe7eb99 (diff)
downloadbcm5719-llvm-c6458d6a4d3b5b8b95794f05c555990f9b037b82.tar.gz
bcm5719-llvm-c6458d6a4d3b5b8b95794f05c555990f9b037b82.zip
Refactor ASTReader::getSourceDescriptor(const Module &) into a constructor
of ASTSourceDescriptor. It was effectively a static function. NFC. llvm-svn: 248069
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/ExternalASTSource.cpp10
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp3
-rw-r--r--clang/lib/Serialization/ASTReader.cpp22
3 files changed, 11 insertions, 24 deletions
diff --git a/clang/lib/AST/ExternalASTSource.cpp b/clang/lib/AST/ExternalASTSource.cpp
index 8a44c05dbb7..62d41d3e497 100644
--- a/clang/lib/AST/ExternalASTSource.cpp
+++ b/clang/lib/AST/ExternalASTSource.cpp
@@ -16,6 +16,7 @@
#include "clang/AST/ExternalASTSource.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclarationName.h"
+#include "clang/Basic/Module.h"
#include "llvm/Support/ErrorHandling.h"
using namespace clang;
@@ -27,9 +28,12 @@ ExternalASTSource::getSourceDescriptor(unsigned ID) {
return None;
}
-ExternalASTSource::ASTSourceDescriptor
-ExternalASTSource::getSourceDescriptor(const Module &M) {
- return ASTSourceDescriptor();
+ExternalASTSource::ASTSourceDescriptor::ASTSourceDescriptor(const Module &M)
+ : ModuleName(M.getFullModuleName()), Signature(M.Signature) {
+ if (M.Directory)
+ Path = M.Directory->getName();
+ if (auto *File = M.getASTFile())
+ ASTFile = File->getName();
}
void ExternalASTSource::FindFileRegionDecls(FileID File, unsigned Offset,
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 723e8ffde3b..7d6bd166873 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3391,8 +3391,7 @@ void CGDebugInfo::EmitUsingDecl(const UsingDecl &UD) {
}
void CGDebugInfo::EmitImportDecl(const ImportDecl &ID) {
- auto *Reader = CGM.getContext().getExternalSource();
- auto Info = Reader->getSourceDescriptor(*ID.getImportedModule());
+ auto Info = ExternalASTSource::ASTSourceDescriptor(*ID.getImportedModule());
DBuilder.createImportedDeclaration(
getCurrentContextDescriptor(cast<Decl>(ID.getDeclContext())),
getOrCreateModuleRef(Info, DebugTypeExtRefs),
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 45837285cda..110afbdf863 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7403,33 +7403,17 @@ unsigned ASTReader::getModuleFileID(ModuleFile *F) {
return (I - PCHModules.end()) << 1;
}
-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);
+ return ExternalASTSource::ASTSourceDescriptor(*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 ASTReader::ASTSourceDescriptor(
+ MF.OriginalSourceFileName, MF.OriginalDir, MF.FileName, MF.Signature);
}
return None;
}
OpenPOWER on IntegriCloud