[clang-tools-extra] r353926 - [clangd] Handle a few more diag kinds in include fixer.
Eric Liu via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 13 00:58:54 PST 2019
Author: ioeric
Date: Wed Feb 13 00:58:54 2019
New Revision: 353926
URL: http://llvm.org/viewvc/llvm-project?rev=353926&view=rev
Log:
[clangd] Handle a few more diag kinds in include fixer.
Reviewers: sammccall
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D58135
Modified:
clang-tools-extra/trunk/clangd/IncludeFixer.cpp
clang-tools-extra/trunk/unittests/clangd/DiagnosticsTests.cpp
Modified: clang-tools-extra/trunk/clangd/IncludeFixer.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/IncludeFixer.cpp?rev=353926&r1=353925&r2=353926&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/clangd/IncludeFixer.cpp Wed Feb 13 00:58:54 2019
@@ -79,6 +79,12 @@ std::vector<Fix> IncludeFixer::fix(Diagn
case diag::err_typename_nested_not_found:
case diag::err_no_template:
case diag::err_no_template_suggest:
+ case diag::err_undeclared_use:
+ case diag::err_undeclared_use_suggest:
+ case diag::err_undeclared_var_use:
+ case diag::err_undeclared_var_use_suggest:
+ case diag::err_no_member: // Could be no member in namespace.
+ case diag::err_no_member_suggest:
if (LastUnresolvedName) {
// Try to fix unresolved name caused by missing declaraion.
// E.g.
Modified: clang-tools-extra/trunk/unittests/clangd/DiagnosticsTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/DiagnosticsTests.cpp?rev=353926&r1=353925&r2=353926&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/DiagnosticsTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/DiagnosticsTests.cpp Wed Feb 13 00:58:54 2019
@@ -368,11 +368,14 @@ TEST(IncludeFixerTest, Typo) {
Annotations Test(R"cpp(
$insert[[]]namespace ns {
void foo() {
- $unqualified[[X]] x;
+ $unqualified1[[X]] x;
+ $unqualified2[[X]]::Nested n;
}
}
void bar() {
- ns::$qualified[[X]] x; // ns:: is valid.
+ ns::$qualified1[[X]] x; // ns:: is valid.
+ ns::$qualified2[[X]](); // Error: no member in namespace
+
::$global[[Global]] glob;
}
)cpp");
@@ -385,13 +388,21 @@ void bar() {
EXPECT_THAT(
TU.build().getDiagnostics(),
UnorderedElementsAre(
- AllOf(Diag(Test.range("unqualified"), "unknown type name 'X'"),
+ AllOf(Diag(Test.range("unqualified1"), "unknown type name 'X'"),
+ WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+ "Add include \"x.h\" for symbol ns::X"))),
+ AllOf(Diag(Test.range("unqualified2"),
+ "use of undeclared identifier 'X'"),
WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
"Add include \"x.h\" for symbol ns::X"))),
- AllOf(Diag(Test.range("qualified"),
+ AllOf(Diag(Test.range("qualified1"),
"no type named 'X' in namespace 'ns'"),
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'"),
+ 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"),
WithFix(Fix(Test.range("insert"), "#include \"global.h\"\n",
More information about the cfe-commits
mailing list