forked from OSchip/llvm-project
Fix ASTUnit::getOriginalSourceFileName() when using ASTUnit's derived from
source files. llvm-svn: 90311
This commit is contained in:
parent
7afbb8c08c
commit
a8a509376c
|
@ -54,6 +54,9 @@ class ASTUnit {
|
||||||
// FIXME: This is temporary; eventually, CIndex will always do this.
|
// FIXME: This is temporary; eventually, CIndex will always do this.
|
||||||
bool OnlyLocalDecls;
|
bool OnlyLocalDecls;
|
||||||
|
|
||||||
|
/// The name of the original source file used to generate this ASTUnit.
|
||||||
|
std::string OriginalSourceFile;
|
||||||
|
|
||||||
// Critical optimization when using clang_getCursor().
|
// Critical optimization when using clang_getCursor().
|
||||||
ASTLocation LastLoc;
|
ASTLocation LastLoc;
|
||||||
|
|
||||||
|
|
|
@ -95,10 +95,11 @@ public:
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
const std::string &ASTUnit::getOriginalSourceFileName() {
|
const std::string &ASTUnit::getOriginalSourceFileName() {
|
||||||
return dyn_cast<PCHReader>(Ctx->getExternalSource())->getOriginalSourceFile();
|
return OriginalSourceFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string &ASTUnit::getPCHFileName() {
|
const std::string &ASTUnit::getPCHFileName() {
|
||||||
|
assert(Ctx->getExternalSource() && "Not an ASTUnit from a PCH file!");
|
||||||
return dyn_cast<PCHReader>(Ctx->getExternalSource())->getFileName();
|
return dyn_cast<PCHReader>(Ctx->getExternalSource())->getFileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,6 +139,8 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AST->OriginalSourceFile = Reader->getOriginalSourceFile();
|
||||||
|
|
||||||
// PCH loaded successfully. Now create the preprocessor.
|
// PCH loaded successfully. Now create the preprocessor.
|
||||||
|
|
||||||
// Get information about the target being compiled for.
|
// Get information about the target being compiled for.
|
||||||
|
@ -230,6 +233,8 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocation(const CompilerInvocation &CI,
|
||||||
// FIXME: Use the provided diagnostic client.
|
// FIXME: Use the provided diagnostic client.
|
||||||
AST.reset(new ASTUnit());
|
AST.reset(new ASTUnit());
|
||||||
|
|
||||||
|
AST->OriginalSourceFile = Clang.getFrontendOpts().Inputs[0].second;
|
||||||
|
|
||||||
// Create a file manager object to provide access to and cache the filesystem.
|
// Create a file manager object to provide access to and cache the filesystem.
|
||||||
Clang.setFileManager(&AST->getFileManager());
|
Clang.setFileManager(&AST->getFileManager());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue