]> granicus.if.org Git - clang/commitdiff
[GeneratePCHAction] If preprocessor option 'AllowPCHWithCompilerErrors' is enabled...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 27 Feb 2017 03:52:36 +0000 (03:52 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 27 Feb 2017 03:52:36 +0000 (03:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296320 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Frontend/FrontendActions.h
lib/Frontend/FrontendActions.cpp
test/Index/pch-from-libclang.c

index 20fddc4d5a5221c71b8c9ff305940c84e854f33f..778b40b15df7e29be1bc88cf0ba2e3f716f2ada7 100644 (file)
@@ -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.
index c475cf467aabedab217abad13cb58d0c055adf6b..bb4f5302eda6c0805fa48b03430cf5b8e0021b1b 100644 (file)
@@ -93,7 +93,7 @@ GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
   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::ComputeASTConsumerArguments(CompilerInstance &CI,
   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;
index f6ee81e0cdc7c4daa18b6ca30f62f81aa3255c10..349fcac01ecadf9ec43c27bb565474c7ae1c1297 100644 (file)
@@ -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;
 }