summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorBen Langmuir <blangmuir@apple.com>2016-02-11 18:54:02 +0000
committerBen Langmuir <blangmuir@apple.com>2016-02-11 18:54:02 +0000
commit9b1e442e67f39ffb6217775ace457f8191d4c34a (patch)
tree886814fea2fa55a784789eead565ae1bd4ec673b /clang/lib
parent74d7d2f00b24ee60ba9bd7232bc51e937828d22c (diff)
downloadbcm5719-llvm-9b1e442e67f39ffb6217775ace457f8191d4c34a.tar.gz
bcm5719-llvm-9b1e442e67f39ffb6217775ace457f8191d4c34a.zip
[Modules] Early-exit if ReadOptionsBlock fails to avoid crashing
If we didn't tell ReadOptionsBlock to allow failures then we can't assume that the stream is not in the middle of a block if it returns out-of-date. This was causing a crash when we tried to continue reading. Also, it's just generally a good idea to early-exit if we're doing implicit module builds, since we will want to immediately rebuild this module anyway and there's no reason to waste time continuing after failure. rdar://problem/24114938 llvm-svn: 260563
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Serialization/ASTReader.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index b2f59d1fa6c..ac78da26140 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -2269,9 +2269,10 @@ ASTReader::ReadControlBlock(ModuleFile &F,
(AllowConfigurationMismatch && Result == ConfigurationMismatch))
Result = Success;
- // If we've diagnosed a problem, we're done.
- if (Result != Success &&
- isDiagnosedResult(Result, ClientLoadCapabilities))
+ // If we can't load the module, exit early since we likely
+ // will rebuild the module anyway. The stream may be in the
+ // middle of a block.
+ if (Result != Success)
return Result;
} else if (Stream.SkipBlock()) {
Error("malformed block record in AST file");
OpenPOWER on IntegriCloud