diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-12-02 08:44:16 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-12-02 08:44:16 +0000 |
commit | 68d40e2d16b9fadba386853d6bbb60089291fdc5 (patch) | |
tree | 76a08400f4a144cbda7c7485d8a6588999515afd /lib/Frontend/ASTUnit.cpp | |
parent | cb6dda1a7abe2fe30b0345bfbbf872cc73446678 (diff) |
Fix ASTUnit::getOriginalSourceFileName() when using ASTUnit's derived from
source files.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90311 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/ASTUnit.cpp')
-rw-r--r-- | lib/Frontend/ASTUnit.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index ac21338058..87d0d7d1a4 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -95,10 +95,11 @@ public: } // 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 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename, 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 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocation(const CompilerInvocation &CI, // 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()); |