[PATCH] D151515: [CodeGen] add additional cast when checking call arguments
Eli Friedman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri May 26 10:37:00 PDT 2023
efriedma added a comment.
Relevant bit of the AST:
`-ExprWithCleanups 0xd16a780 <line:6:3, col:8> 'void':'void'
`-CXXOperatorCallExpr 0xd16a678 <col:3, col:8> 'void':'void' '()'
|-ImplicitCastExpr 0xd16a5a8 <col:4, col:8> 'void (*)(int (&&)[]) const' <FunctionToPointerDecay>
| `-DeclRefExpr 0xd16a528 <col:4, col:8> 'void (int (&&)[]) const' lvalue CXXMethod 0xd14f7f8 'operator()' 'void (int (&&)[]) const'
|-ImplicitCastExpr 0xd16a5e8 <col:3> 'const (lambda at <stdin>:5:12)' lvalue <NoOp>
| `-DeclRefExpr 0xd16a460 <col:3> '(lambda at <stdin>:5:12)':'(lambda at <stdin>:5:12)' lvalue Var 0xd14f628 'f' '(lambda at <stdin>:5:12)':'(lambda at <stdin>:5:12)'
`-MaterializeTemporaryExpr 0xd16a660 <col:5, col:7> 'int[1]' xvalue
`-InitListExpr 0xd16a600 <col:5, col:7> 'int[1]'
`-ImplicitCastExpr 0xd16a640 <col:6> 'int' <LValueToRValue>
`-DeclRefExpr 0xd16a480 <col:6> 'int' lvalue ParmVar 0xd14f3a8 'a' 'int'
At first glance, I'd consider this a problem with the AST: there should be a no-op cast from `int[1]` to `int[]`. We generate such a cast for the following:
void foo(int a) {
auto f = [](int(&&)[]) {};
int aa[1] = {a};
f(static_cast<int(&&)[1]>(aa));
}
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151515/new/
https://reviews.llvm.org/D151515
More information about the cfe-commits
mailing list