diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-06-08 05:48:06 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-06-08 05:48:06 +0000 |
commit | 374a00bcc6e26b4fc3cd1d378a5d056c4c7d618e (patch) | |
tree | 29cc0165be6b097840462ccd0cd1a84f33513319 /lib/Frontend | |
parent | c18909ebd57608f8bec96dbd5e596c5695fa4045 (diff) |
[libclang] Don't crash when saving a PCH from a prefix header
that does not exist.
rdar://11607033
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158193 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend')
-rw-r--r-- | lib/Frontend/ASTUnit.cpp | 11 | ||||
-rw-r--r-- | lib/Frontend/FrontendAction.cpp | 6 |
2 files changed, 13 insertions, 4 deletions
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index d6bdae4aaf..1ef5ba864e 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -1133,7 +1133,8 @@ bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) { StoredDiagnostics); } - Act->Execute(); + if (!Act->Execute()) + goto error; transferASTDataFromCompilerInstance(*Clang); @@ -1795,7 +1796,13 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(CompilerInvocation *CI, AST->getCurrentTopLevelHashValue())); Clang->setASTConsumer(new MultiplexConsumer(Consumers)); } - Act->Execute(); + if (!Act->Execute()) { + AST->transferASTDataFromCompilerInstance(*Clang); + if (OwnAST && ErrAST) + ErrAST->swap(OwnAST); + + return 0; + } // Steal the created target, context, and preprocessor. AST->transferASTDataFromCompilerInstance(*Clang); diff --git a/lib/Frontend/FrontendAction.cpp b/lib/Frontend/FrontendAction.cpp index 1ff32921d9..fb53c71fa9 100644 --- a/lib/Frontend/FrontendAction.cpp +++ b/lib/Frontend/FrontendAction.cpp @@ -315,7 +315,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, return false; } -void FrontendAction::Execute() { +bool FrontendAction::Execute() { CompilerInstance &CI = getCompilerInstance(); // Initialize the main file entry. This needs to be delayed until after PCH @@ -325,7 +325,7 @@ void FrontendAction::Execute() { getCurrentInput().IsSystem ? SrcMgr::C_System : SrcMgr::C_User)) - return; + return false; } if (CI.hasFrontendTimer()) { @@ -333,6 +333,8 @@ void FrontendAction::Execute() { ExecuteAction(); } else ExecuteAction(); + + return true; } void FrontendAction::EndSourceFile() { |