[PATCH] D150111: [clang][Interp] Implement lambda static invokers

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 16 06:25:04 PDT 2023


tbaeder added inline comments.


================
Comment at: clang/lib/AST/Interp/ByteCodeEmitter.cpp:100-103
+  bool IsEligibleForCompilation =
+      FuncDecl->isConstexpr() ||
+      (isa<CXXMethodDecl>(FuncDecl) &&
+       cast<CXXMethodDecl>(FuncDecl)->isLambdaStaticInvoker());
----------------
aaron.ballman wrote:
> 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?
I'm not a fan of that pattern either. I've seen it elsewhere in the code base, didn't like it, but couldn't come up with an objective downside either. If you're also not a fan, I have no problem with changing it.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150111/new/

https://reviews.llvm.org/D150111



More information about the cfe-commits mailing list