[clang-tools-extra] [clangd] Add designator hints for parenthesis aggregate initialization (PR #170642)
Mythreya Kuricheti via cfe-commits
cfe-commits at lists.llvm.org
Sun Dec 7 00:16:46 PST 2025
================
@@ -1822,6 +1821,37 @@ TEST(DesignatorHints, NoCrash) {
ExpectedHint{".b=", "b"});
}
+TEST(DesignatorHints, BasicParenInit) {
+ assertDesignatorHints(R"cpp(
+ struct S {
+ int x;
+ int y;
+ int z;
+ };
+ S s ($x[[1]], $y[[2+2]], $z[[4]]);
+ )cpp",
+ ExpectedHint{".x=", "x"}, ExpectedHint{".y=", "y"},
+ ExpectedHint{".z=", "z"});
+}
+
+TEST(DesignatorHints, BasicParenInitDerived) {
+ assertDesignatorHints(R"cpp(
+ struct S1 {
+ int a;
+ int b;
+ };
+
+ struct S2 : S1 {
+ int c;
+ int d;
+ };
+ S2 s2 ({$a[[0]], $b[[0]]}, $c[[0]], $d[[0]]);
+ )cpp",
+ // ExpectedHint{"S1:", "S1"},
----------------
MythreyaK wrote:
@HighCommander4 suggested we add [this](https://github.com/llvm/llvm-project/pull/170642#discussion_r2594632814) in a separate PR so that it's easy to revert if that hint is not well received. Will create a separate PR for it.
https://github.com/llvm/llvm-project/pull/170642
More information about the cfe-commits
mailing list