[PATCH] D50948: lambdas in modules: change storage for LambdaDefinitionData

Steve O'Brien via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 18 15:36:08 PDT 2018


elsteveogrande added inline comments.


================
Comment at: lib/Serialization/ASTReaderDecl.cpp:1771
     auto *Def = DD.Definition;
     DD = std::move(MergeDD);
     DD.Definition = Def;
----------------
Hi @rsmith, thanks again for looking!  This is the part that I was concerned about: that `DD` could be either a `DefinitionData` or `LambdaDefinitionData` reference; similar `MergeDD`.  It didn't seem that move-assign was well-defined in the cases where they were mixed.

If their being different is completely unexpected, though, this whole thing could perhaps be an assertion that they are both lambda, or both not lambda.  And an `IsLambda` field on the CXXRecordDecl` (or `TTK_Lambda`).

Alternatively, I could make the lambda data a pointer or `std::unique_ptr<LambdaDefinitionData>` inside `DefinitionData` (and maybe make the latter `final`), so as not to allocate much extra space in the non-lambda case.

Depends on whether a new tag type is not too much of a breaking change.  Also, whether it's known at this point that this record is a lambda (and `DD` is already of the correct type).


Repository:
  rC Clang

https://reviews.llvm.org/D50948





More information about the cfe-commits mailing list