[PATCH] D97653: [clang-tidy] Fix RenamerClangTidy checks breaking lambda captures.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 7 13:18:44 PDT 2021


aaron.ballman added a comment.

In D97653#2593287 <https://reviews.llvm.org/D97653#2593287>, @njames93 wrote:

> Where would be a good place for testing refersToDefaultCapture support?

Thank you for your patience while I thought about this a bit more, sorry for the delay in reviewing it!

I think it probably makes sense to add testing for it in `clang\test\AST` with an AST dumping test (so the text node dumper would probably need to be updated to mention that the `DeclRefExpr` is an implicit capture).



================
Comment at: clang/lib/Sema/SemaLambda.cpp:1619
+  if (Cap.isVariableCapture() && ImplicitCaptureLoc.isValid())
+    cast<DeclRefExpr>(InitExpr)->setRefersToDefaultCapture(true);
   InitializedEntity Entity = InitializedEntity::InitializeLambdaCapture(
----------------
njames93 wrote:
> Correct me if I'm wrong, but there shouldn't be a case where the assert in cast fails.
Hmmm, could it be an unresolved lookup expr in the case of a dependent capture? Or a `MemberExpr` in the case of capturing an anonymous structure or union member capture?

Because we're trying to determine if a `DeclRefExpr` was implicitly captured, would it be better to use "implicit capture" in the identifier rather than "default capture"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97653



More information about the cfe-commits mailing list