[clang-tools-extra] [clangd] Add designator hints for parenthesis aggregate initialization (PR #170642)

Mythreya Kuricheti via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 6 02:07:36 PST 2025


MythreyaK wrote:

I think I'm seeing a bug. For this snippet, 

```cpp

template <typename T>
struct S1 {
  int a;
  int b;
  T* ptr;
};

struct S2 : S1<S2> {
  int c;
  int d;
  S1<S1> mem;
};
S2 s2 ({0, 0}, 0, 0);
S2 s2 ({$a[[0]], $b[[0]]}, $c[[0]], $d[[0]]);
```

source range for mem is 

```
------- FieldDecl 1 -------
FIELD: : RecordFields ----- (/llvm-project/clang-tools-extra/clangd/InlayHints.cpp:746)
FieldDecl 0x2233ae10 </clangd-test/TestTU.cpp:10:3, col:7> col:7 c 'int'
--- InitExpr 1 source range ---
 </clangd-test/TestTU.cpp:14:16>
/clangd-test/TestTU.cpp:14:16
/clangd-test/TestTU.cpp:14:16
------------ END ------------

------- FieldDecl 2 -------------------------
FIELD: : RecordFields ----- (/llvm-project/clang-tools-extra/clangd/InlayHints.cpp:746)
FieldDecl 0x2233ae80 </clangd-test/TestTU.cpp:11:3, col:7> col:7 d 'int'
--- InitExpr 2 source range ---
 </clangd-test/TestTU.cpp:14:19>
/clangd-test/TestTU.cpp:14:19
/clangd-test/TestTU.cpp:14:19
------------ END ------------

------- FieldDecl 3 -------------------------
FIELD: : RecordFields ----- (/llvm-project/clang-tools-extra/clangd/InlayHints.cpp:746)
FieldDecl 0x223aaff8 </clangd-test/TestTU.cpp:12:3, col:10> col:10 mem 'S1<S1<S2>>'
--- InitExpr 3 source range ---
 </clangd-test/TestTU.cpp:14:4>
/clangd-test/TestTU.cpp:14:4    // <------ source range seems incorrect?
/clangd-test/TestTU.cpp:14:4    // <------ source range seems incorrect?
------------ END ------------
```

https://github.com/llvm/llvm-project/pull/170642


More information about the cfe-commits mailing list