From 8a308ec24d627e22c29b1e6305c334dc2ba4c4b4 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 5 Nov 2015 00:54:55 +0000 Subject: [modules] If we're given a module file, via -fmodule-file=, for a module, but we can't load that file due to a configuration mismatch, and implicit module building is disabled, and the user turns off the error-by-default warning for that situation, then fall back to textual inclusion for the module rather than giving an error if any of its headers are included. llvm-svn: 252114 --- clang/lib/Serialization/ASTReader.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'clang/lib/Serialization/ASTReader.cpp') diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index b7b56f68b81..32656037921 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -2151,6 +2151,7 @@ ASTReader::ReadControlBlock(ModuleFile &F, const ModuleFile *ImportedBy, unsigned ClientLoadCapabilities) { BitstreamCursor &Stream = F.Stream; + ASTReadResult Result = Success; if (Stream.EnterSubBlock(CONTROL_BLOCK_ID)) { Error("malformed block record in AST file"); @@ -2211,7 +2212,7 @@ ASTReader::ReadControlBlock(ModuleFile &F, } } - return Success; + return Result; } case llvm::BitstreamEntry::SubBlock: @@ -2239,16 +2240,21 @@ ASTReader::ReadControlBlock(ModuleFile &F, bool AllowCompatibleConfigurationMismatch = F.Kind == MK_ExplicitModule; - auto Result = ReadOptionsBlock(Stream, ClientLoadCapabilities, - AllowCompatibleConfigurationMismatch, - *Listener, SuggestedPredefines); + Result = ReadOptionsBlock(Stream, ClientLoadCapabilities, + AllowCompatibleConfigurationMismatch, + *Listener, SuggestedPredefines); if (Result == Failure) { Error("malformed block record in AST file"); return Result; } - if (!DisableValidation && Result != Success && - (Result != ConfigurationMismatch || !AllowConfigurationMismatch)) + if (DisableValidation || + (AllowConfigurationMismatch && Result == ConfigurationMismatch)) + Result = Success; + + // If we've diagnosed a problem, we're done. + if (Result != Success && + isDiagnosedResult(Result, ClientLoadCapabilities)) return Result; } else if (Stream.SkipBlock()) { Error("malformed block record in AST file"); -- cgit v1.2.3