Index: clangd/ClangdServer.cpp =================================================================== --- clangd/ClangdServer.cpp +++ clangd/ClangdServer.cpp @@ -531,9 +531,11 @@ if (!C) // FIXME: Suppress diagnostics? Let the user know? C = CDB.getFallbackCommand(File); - // Inject the resource dir. + // Inject the resource dir. These flags are working for both gcc and clang-cl + // driver modes. // FIXME: Don't overwrite it if it's already there. C->CommandLine.push_back("-resource-dir=" + ResourceDir); + C->CommandLine.push_back("-Wdeprecated"); return std::move(*C); } Index: unittests/clangd/ClangdUnitTests.cpp =================================================================== --- unittests/clangd/ClangdUnitTests.cpp +++ unittests/clangd/ClangdUnitTests.cpp @@ -220,6 +220,44 @@ } } +TEST(DiagnosticsTest, DiagnosticDeprecated) { + Annotations Test(R"cpp( + void foo() __attribute__(($foodeprecation[[deprecated]])); + class A { + public: + int x __attribute__(($xdeprecation[[deprecated]])); + }; + int main() { + $foo[[foo]](); + return A().$x[[x]]; + } + )cpp"); + EXPECT_THAT( + TestTU::withCode(Test.code()).build().getDiagnostics(), + ElementsAre( + AllOf(Diag(Test.range("foo"), "'foo' is deprecated"), + WithNote( + Diag(Test.range("foodeprecation"), + "'foo' has been explicitly marked deprecated here"))), + AllOf(Diag(Test.range("x"), "'x' is deprecated"), + WithNote( + Diag(Test.range("xdeprecation"), + "'x' has been explicitly marked deprecated here"))))); +} + +TEST(DiagnosticsTest, DiagnosticDeprecatedWithFix) { + Annotations Test(R"cpp( + void bar(); + void foo() __attribute__((deprecated("", "bar"))); + int main() { + $deprecated[[foo]](); + } + )cpp"); + EXPECT_THAT(TestTU::withCode(Test.code()).build().getDiagnostics(), + ElementsAre(WithFix(Fix(Test.range("deprecated"), "bar", + "change 'foo' to 'bar'")))); +} + } // namespace } // namespace clangd } // namespace clang