Meinersbur added inline comments.

================
Comment at: clang/lib/AST/Stmt.cpp:1275
-                                                ->isScalarType())) &&
-        "captures by copy are expected to have a scalar type!");
     break;
----------------
jdoerfert wrote:
> Why does this have to go? Is that avoidable?
This is used to capture the loop counter (e.g. `__begin` for a CXXForRangeStmt) 
in front of the loop before it is modified. This can be an iterator whose copy 
constructor needs to be called and this assertion did restrict it to scalar 
types. It is used for the LoopVarFunc closure which is of the form 
`[__begin,&](LogicalIterationNumberTy indvar) { return *(__begin + indvar); }`
The alternative would be to introduce more implicit children of an 
OMPCanonicalLoop that declares a variable and assigns the initial loop counter 
value. I find the byval-capture much more elegant.

The code implementing the byval-capture is shared with the implementation of 
lambdas, so the only reason seems to be that there was no use case when 
introduced in D14940.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94973

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to