diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-03-07 01:51:17 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-03-07 01:51:17 +0000 |
commit | 4a280ff48fd6194d5fe06df21b057d30af93a386 (patch) | |
tree | 2a904ffe7ce2cd1dcf1214b18eccd09cbe3ea5ab /clang/lib/Serialization/ASTReader.cpp | |
parent | 9b2ab81a0c37d1adbf7924823ac923045a543eed (diff) | |
download | bcm5719-llvm-4a280ff48fd6194d5fe06df21b057d30af93a386.tar.gz bcm5719-llvm-4a280ff48fd6194d5fe06df21b057d30af93a386.zip |
[PCH] Mark a PCH file with a flag to indicate if the serialized AST had
compiler errors or not.
-Control whether ASTReader should reject such a PCH by a boolean flag at ASTReader's creation time.
By default, such a PCH file will be rejected with an error when trying to load it.
[libclang] Allow clang_saveTranslationUnit to create a PCH file even if compiler errors
occurred.
-Have libclang API calls accept a PCH that had compiler errors.
The general idea is that we want libclang to stay functional even if a PCH had a compiler error.
rdar://10976363.
llvm-svn: 152192
Diffstat (limited to 'clang/lib/Serialization/ASTReader.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 39f24da6d40..5684949e7eb 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -1807,6 +1807,12 @@ ASTReader::ReadASTBlock(ModuleFile &F) { return IgnorePCH; } + bool hasErrors = Record[5]; + if (hasErrors && !DisableValidation && !AllowASTWithCompilerErrors) { + Diag(diag::err_pch_with_compiler_errors); + return IgnorePCH; + } + RelocatablePCH = Record[4]; if (Listener) { std::string TargetTriple(BlobStart, BlobLen); @@ -6282,14 +6288,15 @@ void ASTReader::FinishedDeserializing() { ASTReader::ASTReader(Preprocessor &PP, ASTContext &Context, StringRef isysroot, bool DisableValidation, - bool DisableStatCache) + bool DisableStatCache, bool AllowASTWithCompilerErrors) : Listener(new PCHValidator(PP, *this)), DeserializationListener(0), SourceMgr(PP.getSourceManager()), FileMgr(PP.getFileManager()), Diags(PP.getDiagnostics()), SemaObj(0), PP(PP), Context(Context), Consumer(0), ModuleMgr(FileMgr.getFileSystemOptions()), RelocatablePCH(false), isysroot(isysroot), DisableValidation(DisableValidation), - DisableStatCache(DisableStatCache), + DisableStatCache(DisableStatCache), + AllowASTWithCompilerErrors(AllowASTWithCompilerErrors), CurrentGeneration(0), NumStatHits(0), NumStatMisses(0), NumSLocEntriesRead(0), TotalNumSLocEntries(0), NumStatementsRead(0), TotalNumStatements(0), NumMacrosRead(0), |