[PATCH] [C++11] Support for capturing of variable length arrays in lambda expression.

Alexey Bataev a.bataev at hotmail.com
Wed Jul 16 19:02:52 PDT 2014


Hi Richard,
Yes, I already found that there are some problems with the 
serialization/deserialization (bu after I published the patch). I'll try 
to fix it ASAP.

Best regards,
Alexey Bataev
=============
Software Engineer
Intel Compiler Team

17.07.2014 4:09, Richard Smith пишет:
> Please add a serialization / deserialization test.
>
> ================
> Comment at: include/clang/AST/Decl.h:2253-2255
> @@ -2255,1 +2252,5 @@
>   
> +  /// \brief Determine whether this member has a reference to captured
> +  /// expression for structs/classes generates for list of variables captured
> +  /// in lambda expressions.
> +  bool hasCapturedExpr() const;
> ----------------
> I can't parse this sentence.
>
> ================
> Comment at: include/clang/AST/Decl.h:2256-2258
> @@ +2255,5 @@
> +  /// in lambda expressions.
> +  bool hasCapturedExpr() const;
> +  /// \brief Get the captured expression if any.
> +  Expr *getCapturedExpr() const {
> +    return hasCapturedExpr() ? InitializerOrBitWidth.getPointer() : nullptr;
> ----------------
> I think this should be made more specific: this actually refers specifically to capturing a VLA bound, so it should be named thusly.
>
> ================
> Comment at: include/clang/AST/LambdaCapture.h:81
> @@ -77,1 +80,3 @@
>   
> +  /// \brief Determine whether this captures expression.
> +  bool capturesExpression() const {
> ----------------
> "... captures an expression."
>
> ================
> Comment at: include/clang/AST/LambdaCapture.h:82
> @@ +81,3 @@
> +  /// \brief Determine whether this captures expression.
> +  bool capturesExpression() const {
> +    return (DeclAndBits.getPointer() == nullptr) &&
> ----------------
> Please make this instead be `capturesVLABound`, since that's what it's for.
>
> ================
> Comment at: lib/AST/Decl.cpp:3265-3269
> @@ +3264,7 @@
> +      InitializerOrBitWidth.getPointer()) {
> +    if (getDeclContext() && getDeclContext()->isRecord()) {
> +      if (auto *RD = dyn_cast<CXXRecordDecl>(getParent())) {
> +        return !RD->isLambda();
> +      }
> +    }
> +    return true;
> ----------------
> Please update the comment for `InitializerOrBitWidth` to describe what you're doing here.
>
> ================
> Comment at: lib/AST/Decl.cpp:3333
> @@ +3332,3 @@
> +         "bit width, initializer or captured expr already set");
> +  InitializerOrBitWidth.setPointer(CapturedExpr);
> +}
> ----------------
> It's not really safe to track the captured expression like this: we don't guarantee to preserve expression pointer equality across serialization and deserialization if the expression is reachable from multiple parents, as this one will be.
>
> Instead, how about passing in and storing a `VariableArrayType` here?
>
> http://reviews.llvm.org/D4368
>
>

http://reviews.llvm.org/D4368






More information about the cfe-commits mailing list