[PATCH] D155984: [Sema][ObjC] Invalidate BlockDecl with invalid ParmVarDecl

Ding Fei via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 21 11:01:12 PDT 2023


danix800 created this revision.
danix800 added reviewers: hokein, aaron.ballman.
danix800 added a project: clang.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
danix800 requested review of this revision.
Herald added a subscriber: cfe-commits.

`BlockDecl` should be invalidated because of its invalid `ParmVarDecl`.

Fixes #1 of https://github.com/llvm/llvm-project/issues/64005


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155984

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/ast-dump-recovery.m


Index: clang/test/AST/ast-dump-recovery.m
===================================================================
--- clang/test/AST/ast-dump-recovery.m
+++ clang/test/AST/ast-dump-recovery.m
@@ -16,3 +16,9 @@
   // CHECK-NEXT:   `-DeclRefExpr {{.*}} 'foo'
   foo.undef;
 }
+
+// CHECK:      `-BlockExpr {{.*}} 'int (^)(int, int)'
+// CHECK-NEXT:   `-BlockDecl {{.*}} invalid
+int (^a)(int, int) = ^(int, undefine b) {
+   return 1;
+};
Index: clang/lib/Sema/SemaExpr.cpp
===================================================================
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -16959,6 +16959,9 @@
 
       PushOnScopeChains(AI, CurBlock->TheScope);
     }
+
+    if (AI->isInvalidDecl())
+      CurBlock->TheDecl->setInvalidDecl();
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155984.542993.patch
Type: text/x-patch
Size: 769 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230721/3e47bc99/attachment.bin>


More information about the cfe-commits mailing list