<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jul 21, 2014 at 10:14 PM, Bataev, Alexey <span dir="ltr"><<a href="mailto:a.bataev@hotmail.com" target="_blank">a.bataev@hotmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Richard, I don't think this is possible. If we storing VariableLengthArray* on FieldDecl, then in Lambda operator we can access VariableLengthArray-><u></u>getSizeExpr(). But! We won't be able to get the llvm::Value* for this VariableLengthArray-><u></u>getSizeExpr(), calculated in another function. We should pass this llvm::Value* as a member of RecordDecl for LambdaExpr! Here is a scheme:<br>

<br>
foo() {<br>
int vla[n+m];<br>
....<br>
some_lambda {vla....;}<br>
....<br>
}<br>
<br>
What we have in CodeGen for this example:<br>
CodeGenFunction(foo), llvm::DenseMap<const Expr*, llvm::Value*> VLASizeMap[n+m]=value; VLASizeMap stores pre-calculated size of each VLA.<br>
{<br>
  FD->field_for_m+n_expr = (int [n+m]*)0;<br>
  CodeGenFunction CGF(some_lambda.operator(), FD);<br>
}<br>
<br>
CodeGenFunction(some_lambda.<u></u>operator()), llvm::DenseMap<const Expr*, llvm::Value*> VLASizeMap[n+m]=????? - llvm::Value* for 'n+m' is not captured here, we don't have an access to 'value', calculated in CodeGenFunction(foo) for expression 'n+m'.<br>

<br>
To solve this problem we can try to capture 2 fields instead - one for VariableLengthArray*, and another one for llvm::Value* calculated for VariableLengthArray-><u></u>getSizeExpr().</blockquote><div><br></div><div>I'm sorry, I still think we're miscommunicating. What I'm suggesting is a mechanical transformation: store the VariableArrayType* on the FieldDecl, and then when you need the size expression that you're currently storing there, call getSizeExpr() on the type.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">
Best regards,<br>
Alexey Bataev<br>
=============<br>
Software Engineer<br>
Intel Compiler Team<br>
<br></div>
22 Июль 2014 г. 8:57:54, Richard Smith писал:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">
On Mon, Jul 21, 2014 at 5:43 AM, Alexey Bataev <<a href="mailto:a.bataev@hotmail.com" target="_blank">a.bataev@hotmail.com</a><br></div><div><div class="h5">
<mailto:<a href="mailto:a.bataev@hotmail.com" target="_blank">a.bataev@hotmail.com</a>>> wrote:<br>
<br>
    Updated version after last review. Unfortunately, I don't think it<br>
    is possible to pass captured expression as a VariableLengthArray<br>
    *. I have to capture expr of VariableLengthArray * and then cast<br>
    it to SizeExpr->getType() type to make lambda capture this type,<br>
    not VariableLengthArray *. I have to pass actual value of SizeExpr<br>
    to the Lambda in this field, because it is defined only in calling<br>
    function and in Lambda it can be received only in one of captured<br>
    fields.<br>
<br>
<br>
I don't understand what you're saying. What I'm suggesting is storing<br>
the VariableLengthArray* in the InitializerOrBitWidth field on<br>
FieldDecl, instead of storing the array bound there.<br>
<br>
    <a href="http://reviews.llvm.org/D4368" target="_blank">http://reviews.llvm.org/D4368</a><br>
<br>
    Files:<br>
      include/clang/AST/Decl.h<br>
      include/clang/AST/<u></u>LambdaCapture.h<br>
      include/clang/Basic/<u></u>DiagnosticSemaKinds.td<br>
      lib/AST/Decl.cpp<br>
      lib/AST/Expr.cpp<br>
      lib/AST/ExprCXX.cpp<br>
      lib/AST/StmtPrinter.cpp<br>
      lib/AST/StmtProfile.cpp<br>
      lib/CodeGen/CGDebugInfo.cpp<br>
      lib/CodeGen/CGExprCXX.cpp<br>
      lib/CodeGen/CodeGenFunction.<u></u>cpp<br>
      lib/Sema/SemaDecl.cpp<br>
      lib/Sema/SemaExpr.cpp<br>
      lib/Sema/TreeTransform.h<br>
      test/CodeGenCXX/instantiate-<u></u>typeof-vla.cpp<br>
      test/SemaTemplate/instantiate-<u></u>typeof.cpp<br>
      tools/libclang/IndexBody.cpp<br>
<br>
<br>
</div></div></blockquote>
</blockquote></div><br></div></div>