Skip to content

Commit ae39383

Browse files
authored
Don't revisit the subexpressions of PseudoObjectExpr when building a (#5703)
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 (cherry picked from commit 1127e47)
1 parent a0d6c6d commit ae39383

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

clang/lib/AST/ParentMap.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ static void BuildParentMap(MapTy& M, Stmt* S,
3333

3434
switch (S->getStmtClass()) {
3535
case Stmt::PseudoObjectExprClass: {
36-
assert(OVMode == OV_Transparent && "Should not appear alongside OVEs");
3736
PseudoObjectExpr *POE = cast<PseudoObjectExpr>(S);
3837

38+
if (OVMode == OV_Opaque && M[POE->getSyntacticForm()])
39+
break;
40+
3941
// If we are rebuilding the map, clear out any existing state.
4042
if (M[POE->getSyntacticForm()])
4143
for (Stmt *SubStmt : S->children())

clang/test/SemaObjC/arc-repeated-weak.mm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,18 @@ void doWhileLoop(Test *a) {
290290
} while(0);
291291
}
292292

293+
struct S {
294+
int a;
295+
id b;
296+
};
297+
298+
@interface C
299+
@property S p;
300+
@end
301+
302+
void test_list_init(C *c) {
303+
c.p = {0, c.p.b};
304+
}
293305

294306
@interface Test (Methods)
295307
@end

0 commit comments

Comments
 (0)