Fix ASTUnit::getOriginalSourceFileName() when using ASTUnit's derived from
source files.
llvm-svn: 90311
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index ac21338..87d0d7d 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -95,10 +95,11 @@
} // anonymous namespace
const std::string &ASTUnit::getOriginalSourceFileName() {
- return dyn_cast<PCHReader>(Ctx->getExternalSource())->getOriginalSourceFile();
+ return OriginalSourceFile;
}
const std::string &ASTUnit::getPCHFileName() {
+ assert(Ctx->getExternalSource() && "Not an ASTUnit from a PCH file!");
return dyn_cast<PCHReader>(Ctx->getExternalSource())->getFileName();
}
@@ -138,6 +139,8 @@
return NULL;
}
+ AST->OriginalSourceFile = Reader->getOriginalSourceFile();
+
// PCH loaded successfully. Now create the preprocessor.
// Get information about the target being compiled for.
@@ -230,6 +233,8 @@
// FIXME: Use the provided diagnostic client.
AST.reset(new ASTUnit());
+ AST->OriginalSourceFile = Clang.getFrontendOpts().Inputs[0].second;
+
// Create a file manager object to provide access to and cache the filesystem.
Clang.setFileManager(&AST->getFileManager());