From 952eddef9aff85b1e92626e89baaf7a360e2ac85 Mon Sep 17 00:00:00 2001 From: dim Date: Sun, 22 Dec 2013 00:07:40 +0000 Subject: Vendor import of clang release_34 branch r197841 (effectively, 3.4 RC3): https://llvm.org/svn/llvm-project/cfe/branches/release_34@197841 --- lib/Serialization/GeneratePCH.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'lib/Serialization/GeneratePCH.cpp') diff --git a/lib/Serialization/GeneratePCH.cpp b/lib/Serialization/GeneratePCH.cpp index 32c2df3..7e8baa2 100644 --- a/lib/Serialization/GeneratePCH.cpp +++ b/lib/Serialization/GeneratePCH.cpp @@ -28,22 +28,29 @@ PCHGenerator::PCHGenerator(const Preprocessor &PP, StringRef OutputFile, clang::Module *Module, StringRef isysroot, - raw_ostream *OS) + raw_ostream *OS, bool AllowASTWithErrors) : PP(PP), OutputFile(OutputFile), Module(Module), isysroot(isysroot.str()), Out(OS), - SemaPtr(0), Stream(Buffer), Writer(Stream) { + SemaPtr(0), Stream(Buffer), Writer(Stream), + AllowASTWithErrors(AllowASTWithErrors), + HasEmittedPCH(false) { } PCHGenerator::~PCHGenerator() { } void PCHGenerator::HandleTranslationUnit(ASTContext &Ctx) { - if (PP.getDiagnostics().hasErrorOccurred()) + // Don't create a PCH if there were fatal failures during module loading. + if (PP.getModuleLoader().HadFatalFailure) + return; + + bool hasErrors = PP.getDiagnostics().hasErrorOccurred(); + if (hasErrors && !AllowASTWithErrors) return; // Emit the PCH file assert(SemaPtr && "No Sema?"); - Writer.WriteAST(*SemaPtr, OutputFile, Module, isysroot); + Writer.WriteAST(*SemaPtr, OutputFile, Module, isysroot, hasErrors); // Write the generated bitstream to "Out". Out->write((char *)&Buffer.front(), Buffer.size()); @@ -53,6 +60,8 @@ void PCHGenerator::HandleTranslationUnit(ASTContext &Ctx) { // Free up some memory, in case the process is kept alive. Buffer.clear(); + + HasEmittedPCH = true; } ASTMutationListener *PCHGenerator::GetASTMutationListener() { -- cgit v1.1