[clang] [clang][bytecode] Add InitLinkScope for temporary variables (PR #106552)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 7 06:34:16 PDT 2024
tbaederr wrote:
In this code:
```c++
namespace ExplicitThisInTemporary {
struct B { B *p = this; };
constexpr bool g(B b) { return &b == b.p; }
static_assert(g({}), "");
}
```
The AST for the `static_assert` expr is:
```
CallExpr 0x52100009ed98 '_Bool'
|-ImplicitCastExpr 0x52100009ed78 '_Bool (*)(B)' <FunctionToPointerDecay>
| `-DeclRefExpr 0x5210000754a0 '_Bool (B)' lvalue Function 0x521000075188 'g' '_Bool (B)'
`-InitListExpr 0x52100009edc8 'B':'struct ExplicitThisInTemporary::B'
`-CXXDefaultInitExpr 0x52100009ee20 'B *' has rewritten init
`-CXXThisExpr 0x521000075008 'struct ExplicitThisInTemporary::B *' this
```
the `CXXThisExpr` here doesn't point to the current instance pointer of the frame (that doesn't even exist), but to the object created by the `InitListExpr` surrounding it (`0x52100009edc8`).
https://github.com/llvm/llvm-project/pull/106552
More information about the cfe-commits
mailing list