[PATCH] D91777: [clangd] No crash on "-verify" mode.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 19 06:52:39 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG734d2f98f649: [clangd] No crash on "-verify" mode. (authored by hokein).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D91777/new/
https://reviews.llvm.org/D91777
Files:
clang-tools-extra/clangd/Compiler.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -491,6 +491,15 @@
ElementsAre(Diag(Test.range(), "use of undeclared identifier 'b'")));
}
+TEST(DiagnosticsTest, IgnoreVerify) {
+ auto TU = TestTU::withCode(R"cpp(
+ int a; // expected-error {{}}
+ )cpp");
+ TU.ExtraArgs.push_back("-Xclang");
+ TU.ExtraArgs.push_back("-verify");
+ EXPECT_THAT(TU.build().getDiagnostics(), IsEmpty());
+}
+
// Recursive main-file include is diagnosed, and doesn't crash.
TEST(DiagnosticsTest, RecursivePreamble) {
auto TU = TestTU::withCode(R"cpp(
Index: clang-tools-extra/clangd/Compiler.cpp
===================================================================
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -60,6 +60,10 @@
CI->getFrontendOpts().DisableFree = false;
CI->getLangOpts()->CommentOpts.ParseAllComments = true;
CI->getLangOpts()->RetainCommentsFromSystemHeaders = true;
+ // Disable "clang -verify" diagnostics, they are rarely useful in clangd, and
+ // our compiler invocation set-up doesn't seem to work with it (leading
+ // assertions in VerifyDiagnosticConsumer).
+ CI->getDiagnosticOpts().VerifyDiagnostics = false;
// Disable any dependency outputting, we don't want to generate files or write
// to stdout/stderr.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91777.306404.patch
Type: text/x-patch
Size: 1507 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201119/ed41ab2f/attachment.bin>
More information about the cfe-commits
mailing list