[PATCH] D77159: [pch] Honour -fallow-pch-with-compiler-errors for overall compilation status
Ben Langmuir via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 31 12:33:15 PDT 2020
benlangmuir created this revision.
benlangmuir added a reviewer: akyrtzi.
Herald added subscribers: cfe-commits, arphaman, dexonsmith.
Herald added a project: clang.
Previously we would emit a PCH with errors, but fail the overall
compilation. If run using the driver, that would result in removing the
just-produced PCH. Instead, we should have the compilation result match
whether we were able to emit the PCH.
rdar://61110294
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D77159
Files:
clang/lib/Serialization/GeneratePCH.cpp
clang/test/Index/pch-with-errors.c
Index: clang/test/Index/pch-with-errors.c
===================================================================
--- clang/test/Index/pch-with-errors.c
+++ clang/test/Index/pch-with-errors.c
@@ -42,3 +42,6 @@
// RUN: not c-index-test -write-pch %t.pch foobar.c 2>&1 | FileCheck -check-prefix=NONEXISTENT %s
// NONEXISTENT: Unable to load translation unit
+
+// RUN: %clang -x c-header %s -o %t-clang.h.pch -Xclang -detailed-preprocessing-record -Xclang -fallow-pch-with-compiler-errors
+// RUN: c-index-test -index-file %s -include %t-clang.h -Xclang -detailed-preprocessing-record | FileCheck -check-prefix=CHECK-INDEX %s
Index: clang/lib/Serialization/GeneratePCH.cpp
===================================================================
--- clang/lib/Serialization/GeneratePCH.cpp
+++ clang/lib/Serialization/GeneratePCH.cpp
@@ -57,6 +57,11 @@
}
}
+ // Errors that do not prevent the PCH from being written should not cause the
+ // overall compilation to fail either.
+ if (AllowASTWithErrors)
+ PP.getDiagnostics().getClient()->clear();
+
// Emit the PCH file to the Buffer.
assert(SemaPtr && "No Sema?");
Buffer->Signature =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77159.253958.patch
Type: text/x-patch
Size: 1155 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200331/1d90e8e1/attachment-0001.bin>
More information about the cfe-commits
mailing list