[PATCH] D139171: Don't revisit the subexpressions of PseudoObjectExpr when building a ParentMap

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 1 23:25:50 PST 2022


ahatanak created this revision.
ahatanak added reviewers: rjmccall, jordan_rose.
ahatanak added a project: clang.
Herald added a project: All.
ahatanak requested review of this revision.

The assertion that is removed in this patch was failing when ObjC dot notation expressions appear in both sides of an assignment (see the test case in arc-repeated-weak.mm). Visit the `PseudoObjectExpr` once when the syntactic expression is visited and return without visiting the subexpressions when it's visited again when the semantic expressions are visited.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139171

Files:
  clang/lib/AST/ParentMap.cpp
  clang/test/SemaObjC/arc-repeated-weak.mm


Index: clang/test/SemaObjC/arc-repeated-weak.mm
===================================================================
--- clang/test/SemaObjC/arc-repeated-weak.mm
+++ clang/test/SemaObjC/arc-repeated-weak.mm
@@ -290,6 +290,18 @@
   } while(0);
 }
 
+struct S {
+  int a;
+  id b;
+};
+
+ at interface C
+ at property S p;
+ at end
+
+void test_list_init(C *c) {
+  c.p = {0, c.p.b};
+}
 
 @interface Test (Methods)
 @end
Index: clang/lib/AST/ParentMap.cpp
===================================================================
--- clang/lib/AST/ParentMap.cpp
+++ clang/lib/AST/ParentMap.cpp
@@ -33,9 +33,11 @@
 
   switch (S->getStmtClass()) {
   case Stmt::PseudoObjectExprClass: {
-    assert(OVMode == OV_Transparent && "Should not appear alongside OVEs");
     PseudoObjectExpr *POE = cast<PseudoObjectExpr>(S);
 
+    if (OVMode == OV_Opaque && M[POE->getSyntacticForm()])
+      break;
+
     // If we are rebuilding the map, clear out any existing state.
     if (M[POE->getSyntacticForm()])
       for (Stmt *SubStmt : S->children())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139171.479527.patch
Type: text/x-patch
Size: 1028 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221202/d7291b79/attachment.bin>


More information about the cfe-commits mailing list