[clang] 1127e47 - Don't revisit the subexpressions of PseudoObjectExpr when building a

Akira Hatanaka via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 2 11:41:51 PST 2022


Author: Akira Hatanaka
Date: 2022-12-02T11:41:09-08:00
New Revision: 1127e479e85011b4284dd5097ca2732347198130

URL: https://github.com/llvm/llvm-project/commit/1127e479e85011b4284dd5097ca2732347198130
DIFF: https://github.com/llvm/llvm-project/commit/1127e479e85011b4284dd5097ca2732347198130.diff

LOG: Don't revisit the subexpressions of PseudoObjectExpr when building a
ParentMap

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.

Differential Revision: https://reviews.llvm.org/D139171

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ParentMap.cpp b/clang/lib/AST/ParentMap.cpp
index da21e573c3202..3d6a1cc84c7b1 100644
--- a/clang/lib/AST/ParentMap.cpp
+++ b/clang/lib/AST/ParentMap.cpp
@@ -33,9 +33,11 @@ static void BuildParentMap(MapTy& M, Stmt* S,
 
   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())

diff  --git a/clang/test/SemaObjC/arc-repeated-weak.mm b/clang/test/SemaObjC/arc-repeated-weak.mm
index e9b4d1a048f13..d23af8c05059f 100644
--- a/clang/test/SemaObjC/arc-repeated-weak.mm
+++ b/clang/test/SemaObjC/arc-repeated-weak.mm
@@ -290,6 +290,18 @@ void doWhileLoop(Test *a) {
   } 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


        


More information about the cfe-commits mailing list