Skip to content

Commit a4e2722

Browse files
committed
[clangd] Add a missing include-fixer test for incomplete_type, NFC.
Also sort the list to make it easier to verify with the implementation code. Differential Revision: https://reviews.llvm.org/D88964
1 parent 70bf350 commit a4e2722

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

clang-tools-extra/clangd/IncludeFixer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ class VisitedContextCollector : public VisibleDeclConsumer {
6868
std::vector<Fix> IncludeFixer::fix(DiagnosticsEngine::Level DiagLevel,
6969
const clang::Diagnostic &Info) const {
7070
switch (Info.getID()) {
71-
case diag::err_incomplete_type:
72-
case diag::err_incomplete_member_access:
73-
case diag::err_incomplete_base_class:
7471
case diag::err_incomplete_nested_name_spec:
72+
case diag::err_incomplete_base_class:
73+
case diag::err_incomplete_member_access:
74+
case diag::err_incomplete_type:
7575
// Incomplete type diagnostics should have a QualType argument for the
7676
// incomplete type.
7777
for (unsigned Idx = 0; Idx < Info.getNumArgs(); ++Idx) {

clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,9 +708,11 @@ class Y : $base[[public ns::X]] {};
708708
int main() {
709709
ns::X *x;
710710
x$access[[->]]f();
711+
auto& $type[[[]]a] = *x;
711712
}
712713
)cpp");
713714
auto TU = TestTU::withCode(Test.code());
715+
TU.ExtraArgs.push_back("-std=c++17");
714716
auto Index = buildIndexWithSymbol(
715717
{SymbolWithHeader{"ns::X", "unittest:///x.h", "\"x.h\""}});
716718
TU.ExternalIndex = Index.get();
@@ -731,7 +733,13 @@ int main() {
731733
"member access into incomplete type 'ns::X'"),
732734
DiagName("incomplete_member_access"),
733735
WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
734-
"Add include \"x.h\" for symbol ns::X")))));
736+
"Add include \"x.h\" for symbol ns::X"))),
737+
AllOf(
738+
Diag(Test.range("type"),
739+
"incomplete type 'ns::X' where a complete type is required"),
740+
DiagName("incomplete_type"),
741+
WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
742+
"Add include \"x.h\" for symbol ns::X")))));
735743
}
736744

737745
TEST(IncludeFixerTest, NoSuggestIncludeWhenNoDefinitionInHeader) {

0 commit comments

Comments
 (0)