aboutsummaryrefslogtreecommitdiff
path: root/lib/Serialization
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-02-20 23:58:07 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-02-20 23:58:07 +0000
commita4c29b6e55c9d4ef44a51c45c6785e8b4fe9deed (patch)
tree27010b0e340c3d43e2c60860e77a30cbbfe1e8e4 /lib/Serialization
parentff2348888133dcc64f7363af2093cb608caeb7ce (diff)
[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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151004 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization')
-rw-r--r--lib/Serialization/ASTReader.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index 75b5d68ce6..dde54d6b79 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/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;
}