[PATCH] D150111: [clang][Interp] Implement lambda static invokers
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 15 11:07:06 PDT 2023
aaron.ballman added inline comments.
================
Comment at: clang/lib/AST/Interp/ByteCodeEmitter.cpp:100-103
+ bool IsEligibleForCompilation =
+ FuncDecl->isConstexpr() ||
+ (isa<CXXMethodDecl>(FuncDecl) &&
+ cast<CXXMethodDecl>(FuncDecl)->isLambdaStaticInvoker());
----------------
I don't like the `isa` followed by a `cast` code smell, but rewriting it to use `dyn_cast` is perhaps kind of ugly:
```
bool IsEligibleForCompilation = false;
if (const auto *MD = dyn_cast<CXXMethodDecl>())
IsEligibleForCompilation = MD->isLambdaStaticInvoker();
if (!IsEligibleForCompilation)
IsEligibleForCompilation = FuncDecl->isConstexpr();
```
WDYT?
================
Comment at: clang/lib/AST/Interp/ByteCodeStmtGen.cpp:125-126
+
+ // We do the lvalue-to-rvalue conversion manually here, so no need
+ // to care about references.
+ PrimType ParamType = this->classify(PVD->getType()).value_or(PT_Ptr);
----------------
Why do we need to do lvalue-to-rvalue conversion at all? The caller of the lambda function call operator would have already performed that conversion, right?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150111/new/
https://reviews.llvm.org/D150111
More information about the cfe-commits
mailing list