Commit ed39812
[clang][P2996] Make parameter-name queries independent of instantiation state
The P3096 consistency walk in getParameterName runs over the function's
redeclaration chain and reports no identifier when redeclarations disagree.
For an instantiated member, however, instantiating the out-of-line
definition REPLACES the parameters on the same FunctionDecl -- no
redeclaration is added -- so the walk saw exactly one name: whichever
redeclaration happened to be instantiated last. The same query on the same
entity then answered differently depending on instantiation state, and two
translation units reflecting the same entity could disagree (field shape:
Eigen declares DenseBase::setConstant(const Scalar& value) and defines it
with 'val'; identifier_of flipped between the two depending on whether
binding lambdas had odr-used the member).
Walk the template instantiation pattern's declaration chain instead, which
carries the in-class declaration and the out-of-line definition regardless
of instantiation state. Skipped when the pattern contains a parameter pack
(its parameter list does not line up index-for-index with the
instantiation's; pack-substituted parameters are already filtered earlier).
An inconsistently-named parameter now deterministically has no identifier;
consistently-named parameters keep their name.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 837da39 commit ed39812
2 files changed
Lines changed: 68 additions & 0 deletions
File tree
- clang/lib/AST
- libcxx/test/std/experimental/reflection
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1099 | 1099 | | |
1100 | 1100 | | |
1101 | 1101 | | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
1102 | 1120 | | |
1103 | 1121 | | |
1104 | 1122 | | |
| |||
Lines changed: 50 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
0 commit comments