[PATCH] D88828: [clangd] Verify the diagnostic code in include-fixer diagnostic tests, NFC.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 5 06:00:22 PDT 2020
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
Herald added a project: clang.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D88828
Files:
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
@@ -720,13 +720,16 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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")))));
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88828.296165.patch
Type: text/x-patch
Size: 5355 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201005/b3a8318c/attachment-0001.bin>
More information about the cfe-commits
mailing list