[clangd] Collect references in array designators (#140356)

This commit is contained in:
Aleksandr Platonov
2025-06-13 18:32:42 +03:00
committed by GitHub
parent ec21b0fc9f
commit ca5040990e
2 changed files with 15 additions and 0 deletions

View File

@@ -2311,6 +2311,14 @@ TEST(FindReferences, WithinAST) {
$(S::deleteObject)[[de^lete]] S;
}
};
)cpp",
// Array designators
R"cpp(
const int $def[[F^oo]] = 0;
int Bar[] = {
[$(Bar)[[F^oo]]...$(Bar)[[Fo^o]] + 1] = 0,
[$(Bar)[[^Foo]] + 2] = 1
};
)cpp"};
for (const char *Test : Tests)
checkFindRefs(Test);

View File

@@ -435,6 +435,13 @@ public:
ParentDC, SymbolRoleSet(),
/*Relations=*/{}, E);
}
} else {
if (D.isArrayDesignator())
TraverseStmt(E->getArrayIndex(D));
else if (D.isArrayRangeDesignator()) {
TraverseStmt(E->getArrayRangeStart(D));
TraverseStmt(E->getArrayRangeEnd(D));
}
}
}
return true;