Author: benlangmuir Date: Thu Feb 11 12:54:02 2016 New Revision: 260563 URL: http://llvm.org/viewvc/llvm-project?rev=260563&view=rev Log: [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 Added: cfe/trunk/test/Modules/implicit-build-config-out-of-date.m Modified: cfe/trunk/lib/Serialization/ASTReader.cpp Modified: cfe/trunk/lib/Serialization/ASTReader.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=260563&r1=260562&r2=260563&view=diff ============================================================================== --- cfe/trunk/lib/Serialization/ASTReader.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Feb 11 12:54:02 2016 @@ -2269,9 +2269,10 @@ ASTReader::ReadControlBlock(ModuleFile & (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"); Added: cfe/trunk/test/Modules/implicit-build-config-out-of-date.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/implicit-build-config-out-of-date.m?rev=260563&view=auto ============================================================================== --- cfe/trunk/test/Modules/implicit-build-config-out-of-date.m (added) +++ cfe/trunk/test/Modules/implicit-build-config-out-of-date.m Thu Feb 11 12:54:02 2016 @@ -0,0 +1,6 @@ +// RUN: rm -rf %t +// Use -DA=0 so that there is at least one preprocessor option serialized after the diagnostic options. +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs %s -DA=0 -Rmodule-build -verify +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs %s -DA=0 -Werror -Rmodule-build -verify + +@import category_top; // expected-remark {{building module}} expected-remark {{finished building}} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits