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,10 +68,10 @@ std::vector IncludeFixer::fix(DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &Info) const { switch (Info.getID()) { - case diag::err_incomplete_type: - case diag::err_incomplete_member_access: - case diag::err_incomplete_base_class: case diag::err_incomplete_nested_name_spec: + case diag::err_incomplete_base_class: + case diag::err_incomplete_member_access: + case diag::err_incomplete_type: // Incomplete type diagnostics should have a QualType argument for the // incomplete type. for (unsigned Idx = 0; Idx < Info.getNumArgs(); ++Idx) { 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 @@ -708,9 +708,11 @@ int main() { ns::X *x; x$access[[->]]f(); + auto& $type[[[]]a] = *x; } )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(); @@ -731,7 +733,13 @@ "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"))))); + "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"))))); } TEST(IncludeFixerTest, NoSuggestIncludeWhenNoDefinitionInHeader) {