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

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 10 15:16:15 PDT 2021


njames93 added a comment.

In D97653#2675005 <https://reviews.llvm.org/D97653#2675005>, @aaron.ballman wrote:

> 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).

That sounds like a good place to start, thanks.



================
Comment at: clang/lib/Sema/SemaLambda.cpp:1619
+  if (Cap.isVariableCapture() && ImplicitCaptureLoc.isValid())
+    cast<DeclRefExpr>(InitExpr)->setRefersToDefaultCapture(true);
   InitializedEntity Entity = InitializedEntity::InitializeLambdaCapture(
----------------
aaron.ballman wrote:
> 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"?
Can't capture anonymous members so thats a non issue. I'm not entirely sure about dependent, but the codepaths where isVariableCapture is true always seem to result in either an ExprError or DeclRefExpr.

I do agree with the name though.


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