[PATCH] D51747: [clangd] Implement deprecation diagnostics with lower severity.
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 13 04:53:25 PDT 2018
kadircet updated this revision to Diff 165252.
kadircet marked 5 inline comments as done.
kadircet added a comment.
- Resolve discussions.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D51747
Files:
clangd/ClangdServer.cpp
unittests/clangd/ClangdUnitTests.cpp
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
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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51747.165252.patch
Type: text/x-patch
Size: 2197 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180913/997944ef/attachment.bin>
More information about the cfe-commits
mailing list