diff --git a/clang-tools-extra/clangd/IncludeFixer.cpp b/clang-tools-extra/clangd/IncludeFixer.cpp --- a/clang-tools-extra/clangd/IncludeFixer.cpp +++ b/clang-tools-extra/clangd/IncludeFixer.cpp @@ -68,9 +68,9 @@ std::vector IncludeFixer::fix(DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &Info) const { switch (Info.getID()) { + case diag::err_incomplete_base_class: case diag::err_incomplete_type: case diag::err_incomplete_member_access: - case diag::err_incomplete_base_class: case diag::err_incomplete_nested_name_spec: // Incomplete type diagnostics should have a QualType argument for the // incomplete type. diff --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp --- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp +++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp @@ -702,15 +702,17 @@ Annotations Test(R"cpp(// error-ok $insert[[]]namespace ns { class X; - $nested[[X::]]Nested n; } class Y : $base[[public ns::X]] {}; int main() { ns::X *x; + auto& $type[[[]]a] = *x; x$access[[->]]f(); + $nested[[ns::X::]]Nested n; } )cpp"); auto TU = TestTU::withCode(Test.code()); + TU.ExtraArgs.push_back("-std=c++17"); auto Index = buildIndexWithSymbol( {SymbolWithHeader{"ns::X", "unittest:///x.h", "\"x.h\""}}); TU.ExternalIndex = Index.get(); @@ -718,18 +720,24 @@ EXPECT_THAT( TU.build().getDiagnostics(), 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("type"), + "incomplete type 'ns::X' where a complete type is required"), + DiagName("incomplete_type"), + 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"))), + 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"))))); }