[clang-tools-extra] 48a82c4 - [clangd] Verify the diagnostic code in include-fixer diagnostic tests, NFC.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 6 02:02:35 PDT 2020
Author: Haojian Wu
Date: 2020-10-06T11:02:22+02:00
New Revision: 48a82c42457b47936d8e1f4b2af6a1f3cbb6e992
URL: https://github.com/llvm/llvm-project/commit/48a82c42457b47936d8e1f4b2af6a1f3cbb6e992
DIFF: https://github.com/llvm/llvm-project/commit/48a82c42457b47936d8e1f4b2af6a1f3cbb6e992.diff
LOG: [clangd] Verify the diagnostic code in include-fixer diagnostic tests, NFC.
Make it easier to spot which diagnostics in the include-fixer list are tested.
Differential Revision: https://reviews.llvm.org/D88828
Added:
Modified:
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index 6974131562b3..8fd1fe385a1c 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -720,13 +720,16 @@ int main() {
UnorderedElementsAre(
AllOf(Diag(Test.range("nested"),
"incomplete type 'ns::X' named in nested name specifier"),
+ DiagName("incomplete_nested_name_spec"),
WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
"Add include \"x.h\" for symbol ns::X"))),
AllOf(Diag(Test.range("base"), "base class has incomplete type"),
+ DiagName("incomplete_base_class"),
WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
"Add include \"x.h\" for symbol ns::X"))),
AllOf(Diag(Test.range("access"),
"member access into incomplete type 'ns::X'"),
+ DiagName("incomplete_member_access"),
WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
"Add include \"x.h\" for symbol ns::X")))));
}
@@ -789,19 +792,23 @@ void bar() {
TU.build().getDiagnostics(),
UnorderedElementsAre(
AllOf(Diag(Test.range("unqualified1"), "unknown type name 'X'"),
+ DiagName("unknown_typename"),
WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
"Add include \"x.h\" for symbol ns::X"))),
Diag(Test.range("unqualified2"), "use of undeclared identifier 'X'"),
AllOf(Diag(Test.range("qualified1"),
"no type named 'X' in namespace 'ns'"),
+ DiagName("typename_nested_not_found"),
WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
"Add include \"x.h\" for symbol ns::X"))),
AllOf(Diag(Test.range("qualified2"),
"no member named 'X' in namespace 'ns'"),
+ DiagName("no_member"),
WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
"Add include \"x.h\" for symbol ns::X"))),
AllOf(Diag(Test.range("global"),
"no type named 'Global' in the global namespace"),
+ DiagName("typename_nested_not_found"),
WithFix(Fix(Test.range("insert"), "#include \"global.h\"\n",
"Add include \"global.h\" for symbol Global")))));
}
@@ -825,6 +832,7 @@ void foo() {
EXPECT_THAT(TU.build().getDiagnostics(),
UnorderedElementsAre(AllOf(
Diag(Test.range("unqualified"), "unknown type name 'X'"),
+ DiagName("unknown_typename"),
WithFix(Fix(Test.range("insert"), "#include \"a.h\"\n",
"Add include \"a.h\" for symbol na::X"),
Fix(Test.range("insert"), "#include \"b.h\"\n",
@@ -905,6 +913,7 @@ void g() { ns::$[[scope]]::X_Y(); }
TU.build().getDiagnostics(),
UnorderedElementsAre(AllOf(
Diag(Test.range(), "no member named 'scope' in namespace 'ns'"),
+ DiagName("no_member"),
WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
"Add include \"x.h\" for symbol ns::scope::X_Y")))));
}
@@ -934,22 +943,26 @@ void f() {
AllOf(
Diag(Test.range("q1"), "use of undeclared identifier 'clangd'; "
"did you mean 'clang'?"),
+ DiagName("undeclared_var_use_suggest"),
WithFix(_, // change clangd to clang
Fix(Test.range("insert"), "#include \"x.h\"\n",
"Add include \"x.h\" for symbol clang::clangd::X"))),
AllOf(
Diag(Test.range("x"), "no type named 'X' in namespace 'clang'"),
+ DiagName("typename_nested_not_found"),
WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
"Add include \"x.h\" for symbol clang::clangd::X"))),
AllOf(
Diag(Test.range("q2"), "use of undeclared identifier 'clangd'; "
"did you mean 'clang'?"),
+ DiagName("undeclared_var_use_suggest"),
WithFix(
- _, // change clangd to clangd
+ _, // change clangd to clang
Fix(Test.range("insert"), "#include \"y.h\"\n",
"Add include \"y.h\" for symbol clang::clangd::ns::Y"))),
AllOf(Diag(Test.range("ns"),
"no member named 'ns' in namespace 'clang'"),
+ DiagName("no_member"),
WithFix(Fix(
Test.range("insert"), "#include \"y.h\"\n",
"Add include \"y.h\" for symbol clang::clangd::ns::Y")))));
@@ -971,6 +984,7 @@ namespace c {
EXPECT_THAT(TU.build().getDiagnostics(),
UnorderedElementsAre(AllOf(
Diag(Test.range(), "no type named 'X' in namespace 'a'"),
+ DiagName("typename_nested_not_found"),
WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
"Add include \"x.h\" for symbol a::X")))));
}
More information about the cfe-commits
mailing list