[PATCH] D54550: Mark lambda decl as invalid if a captured variable has an invalid type.

Jorge Gorbe Moya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 14 16:27:12 PST 2018


jgorbe marked 2 inline comments as done.
jgorbe added inline comments.


================
Comment at: clang/lib/Sema/SemaExpr.cpp:14946
+  // as invalid as well.
+  if (const CXXRecordDecl *RD = FieldType->getAsCXXRecordDecl()) {
+    if (RD->isInvalidDecl()) {
----------------
rsmith wrote:
> You'll need to use `FieldType->getBaseElementTypeUnsafe()` or similar here to handle the case where the field type is an array whose element type is a class. (That can happen in a lambda if you capture a local array variable by value.)
Done, I ended up using Context.getBaseElementType because the call to RequireCompleteType below required a QualType.


================
Comment at: clang/lib/Sema/SemaExpr.cpp:14948
+    if (RD->isInvalidDecl()) {
+      Lambda->setInvalidDecl();
+    }
----------------
rsmith wrote:
> For consistency with the class case, I think we should mark the field invalid in this case too.
Done!


https://reviews.llvm.org/D54550





More information about the cfe-commits mailing list