diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-12-02 21:47:43 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-12-02 21:47:43 +0000 |
commit | c7822dbf3c01a2a5f837cff82ba7889ea755daca (patch) | |
tree | c81a21a61b02f1e642fab58c96bf4b862ec290cd /lib/Frontend/ASTUnit.cpp | |
parent | 68ea2ac7fd98a5a44c7a5b04c54076cf794531cb (diff) |
ASTUnit: Explicitly track whether the ASTUnit came from an actual AST or not.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90349 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/ASTUnit.cpp')
-rw-r--r-- | lib/Frontend/ASTUnit.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index 6cbcb46e52..a3db339b83 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -34,7 +34,10 @@ #include "llvm/System/Path.h" using namespace clang; -ASTUnit::ASTUnit(DiagnosticClient *diagClient) : tempFile(false) { +ASTUnit::ASTUnit(bool _MainFileIsAST, + DiagnosticClient *diagClient) + : tempFile(false), MainFileIsAST(_MainFileIsAST) +{ Diags.setClient(diagClient ? diagClient : new TextDiagnosticBuffer()); } ASTUnit::~ASTUnit() { @@ -99,7 +102,7 @@ const std::string &ASTUnit::getOriginalSourceFileName() { } const std::string &ASTUnit::getPCHFileName() { - assert(Ctx->getExternalSource() && "Not an ASTUnit from a PCH file!"); + assert(isMainFileAST() && "Not an ASTUnit from a PCH file!"); return dyn_cast<PCHReader>(Ctx->getExternalSource())->getFileName(); } @@ -108,7 +111,7 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename, DiagnosticClient *diagClient, bool OnlyLocalDecls, bool UseBumpAllocator) { - llvm::OwningPtr<ASTUnit> AST(new ASTUnit(diagClient)); + llvm::OwningPtr<ASTUnit> AST(new ASTUnit(true, diagClient)); AST->OnlyLocalDecls = OnlyLocalDecls; AST->HeaderInfo.reset(new HeaderSearch(AST->getFileManager())); @@ -230,7 +233,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocation(const CompilerInvocation &CI, // Create the AST unit. // // FIXME: Use the provided diagnostic client. - AST.reset(new ASTUnit()); + AST.reset(new ASTUnit(false)); AST->OnlyLocalDecls = OnlyLocalDecls; AST->OriginalSourceFile = Clang.getFrontendOpts().Inputs[0].second; |