hokein created this revision. hokein added a reviewer: adamcz. Herald added subscribers: usaxena95, kadircet, arphaman. Herald added a project: clang. hokein requested review of this revision. Herald added subscribers: MaskRay, ilya-biryukov.
If there is a "-verify" flag in the compile command, clangd will crash (hit the assertion) inside the `~VerifyDiagnosticConsumer` (Looks like our compiler invocation doesn't setup correctly?). This patch disables the verify mode as it is rarely useful in clangd. Repository: rG LLVM Github Monorepo 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.
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.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits