diff options
| author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-02-20 23:58:07 +0000 |
|---|---|---|
| committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-02-20 23:58:07 +0000 |
| commit | 969fdfddd2bccc939bf0c77d2c381231e5dc3b78 (patch) | |
| tree | 963c89d30fba05d8c4ec3de05cb904a108faea32 /clang/lib/Serialization/ASTReader.cpp | |
| parent | 519561f418c77dcf46fd6d96d25d884fa07fd7da (diff) | |
| download | bcm5719-llvm-969fdfddd2bccc939bf0c77d2c381231e5dc3b78.tar.gz bcm5719-llvm-969fdfddd2bccc939bf0c77d2c381231e5dc3b78.zip | |
[PCH] Recover gracefully if the ASTReader detects that a file is different
from the one stored in the PCH/AST, while trying to load a SLocEntry.
We verify that all files of the PCH did not change before loading it but this is not enough because:
- The AST may have been 1) kept around, 2) to do queries on it.
- We may have 1) verified the PCH and 2) started parsing.
Between 1) and 2) files may change and we are going to have crashes because the rest of clang
cannot deal with the ASTReader failing to read a SLocEntry.
Handle this by recovering gracefully in such a case, by initializing the SLocEntry
with the info from the PCH/AST as well as reporting failure by the ASTReader.
rdar://10888929
llvm-svn: 151004
Diffstat (limited to 'clang/lib/Serialization/ASTReader.cpp')
| -rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 75b5d68ce65..dde54d6b791 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -1111,6 +1111,10 @@ ASTReader::ASTReadResult ASTReader::ReadSLocEntryRecord(int ID) { return Failure; } + // We will detect whether a file changed and return 'Failure' for it, but + // we will also try to fail gracefully by setting up the SLocEntry. + ASTReader::ASTReadResult Result = Success; + bool OverriddenBuffer = Record[6]; std::string OrigFilename(BlobStart, BlobStart + BlobLen); @@ -1149,7 +1153,7 @@ ASTReader::ASTReadResult ASTReader::ReadSLocEntryRecord(int ID) { #endif )) { Error(diag::err_fe_pch_file_modified, Filename); - return Failure; + Result = Failure; } SourceLocation IncludeLoc = ReadSourceLocation(*F, Record[1]); @@ -1193,6 +1197,9 @@ ASTReader::ASTReadResult ASTReader::ReadSLocEntryRecord(int ID) { Filename); SourceMgr.overrideFileContents(File, Buffer); } + + if (Result == Failure) + return Failure; break; } |

