[clang] [Clang] Preserve CXXParenListInitExpr in TreeTransform. (PR #138518)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 2 06:45:21 PDT 2025


erichkeane wrote:

> @alexfh I don't have the resources to look into this issue. Please revert if you need to.

This has been in trunk for a long time, a revert here would be HIGHLY unfortunate.  I would vastly prefer someone spend time trying to figure out why we are confused with the variable init here instead.  So:

`q.Push(new Node(0));`

Seems to be the line that isn't producing the same value.  We're initializing it with an int instead of a 64-bit-`long`.  I see here:
https://godbolt.org/z/KofsM8hdj

```
|               `-CXXMemberCallExpr <line:47:5, col:23> 'void'
|                 |-MemberExpr <col:5, col:7> '<bound member function type>' .Push 0x28726e38
|                 | `-DeclRefExpr <col:5> 'IntrusiveMPSCQueue' lvalue Var 0x28735d18 'q' 'IntrusiveMPSCQueue' refers_to_enclosing_variable_or_capture
|                 `-CXXNewExpr <col:12, col:22> 'Node *' Function 0x28731c68 'operator new' 'void *(unsigned long)'
|                   `-CXXParenListInitExpr <col:20, col:22> 'Node'
|                     |-IntegerLiteral <col:21> 'int' 0
```

IN a non-template version (i removed the template head itself), we get:
```
|               `-CXXNewExpr <col:12, col:22> 'Node *' Function 0x22566848 'operator new' 'void *(unsigned long)'
|                 `-CXXParenListInitExpr <col:20, col:22> 'Node'
|                   |-ImplicitCastExpr <col:21> 'long' <IntegralCast>
|                   | `-IntegerLiteral <col:21> 'int' 0
|                   `-ImplicitValueInitExpr 'Node *'
```

In the primary template we have:

```
| |       |       `-CXXNewExpr <col:12, col:22> 'Node *' Function 0x22566848 'operator new' 'void *(unsigned long)'
| |       |         `-CXXParenListInitExpr <col:20, col:22> 'Node'
| |       |           |-ImplicitCastExpr <col:21> 'long' <IntegralCast>
| |       |           | `-IntegerLiteral <col:21> 'int' 0
```

SO something about instantiating the expressions lost their cast?  I'm not sure how that happens?

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


More information about the cfe-commits mailing list