Author: akirtzidis Date: Sun Feb 26 21:52:36 2017 New Revision: 296320 URL: http://llvm.org/viewvc/llvm-project?rev=296320&view=rev Log: [GeneratePCHAction] If preprocessor option 'AllowPCHWithCompilerErrors' is enabled, don't delete the produced PCH file if error diagnostics occurred.
Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h cfe/trunk/lib/Frontend/FrontendActions.cpp cfe/trunk/test/Index/pch-from-libclang.c Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=296320&r1=296319&r2=296320&view=diff ============================================================================== --- cfe/trunk/include/clang/Frontend/FrontendActions.h (original) +++ cfe/trunk/include/clang/Frontend/FrontendActions.h Sun Feb 26 21:52:36 2017 @@ -80,6 +80,8 @@ protected: bool hasASTFileSupport() const override { return false; } + bool shouldEraseOutputFiles() override; + public: /// \brief Compute the AST consumer arguments that will be used to /// create the PCHGenerator instance returned by CreateASTConsumer. Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=296320&r1=296319&r2=296320&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/FrontendActions.cpp (original) +++ cfe/trunk/lib/Frontend/FrontendActions.cpp Sun Feb 26 21:52:36 2017 @@ -93,7 +93,7 @@ GeneratePCHAction::CreateASTConsumer(Com Consumers.push_back(llvm::make_unique<PCHGenerator>( CI.getPreprocessor(), OutputFile, Sysroot, Buffer, CI.getFrontendOpts().ModuleFileExtensions, - /*AllowASTWithErrors*/false, + /*AllowASTWithErrors*/CI.getPreprocessorOpts().AllowPCHWithCompilerErrors, /*IncludeTimestamps*/ +CI.getFrontendOpts().IncludeTimestamps)); Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator( @@ -127,6 +127,12 @@ GeneratePCHAction::ComputeASTConsumerArg return OS; } +bool GeneratePCHAction::shouldEraseOutputFiles() { + if (getCompilerInstance().getPreprocessorOpts().AllowPCHWithCompilerErrors) + return false; + return ASTFrontendAction::shouldEraseOutputFiles(); +} + bool GeneratePCHAction::BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) { CI.getLangOpts().CompilingPCH = true; Modified: cfe/trunk/test/Index/pch-from-libclang.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/pch-from-libclang.c?rev=296320&r1=296319&r2=296320&view=diff ============================================================================== --- cfe/trunk/test/Index/pch-from-libclang.c (original) +++ cfe/trunk/test/Index/pch-from-libclang.c Sun Feb 26 21:52:36 2017 @@ -6,18 +6,21 @@ // RUN: %clang_cc1 -fsyntax-only %s -verify // RUN: c-index-test -write-pch %t.h.pch %s -fmodules -fmodules-cache-path=%t.mcp -Xclang -triple -Xclang x86_64-apple-darwin // RUN: %clang -fsyntax-only -include %t.h %s -Xclang -verify -fmodules -fmodules-cache-path=%t.mcp -Xclang -detailed-preprocessing-record -Xclang -triple -Xclang x86_64-apple-darwin -Xclang -fallow-pch-with-compiler-errors +// RUN: %clang -x c-header %s -o %t.clang.h.pch -fmodules -fmodules-cache-path=%t.mcp -Xclang -detailed-preprocessing-record -Xclang -triple -Xclang x86_64-apple-darwin -Xclang -fallow-pch-with-compiler-errors -Xclang -verify +// RUN: c-index-test -test-load-source local %s -include %t.clang.h -fmodules -fmodules-cache-path=%t.mcp -Xclang -triple -Xclang x86_64-apple-darwin | FileCheck %s #ifndef HEADER #define HEADER -struct S { int x; }; - void some_function(undeclared_type p); // expected-error{{unknown type name}} +struct S { int x; }; + #else // expected-no-diagnostics void test(struct S *s) { + // CHECK: [[@LINE+1]]:6: MemberRefExpr=x:[[@LINE-6]]:16 s->x = 0; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits