@@ -33,17 +33,19 @@ static void BuildParentMap(MapTy& M, Stmt* S,
33
33
switch (S->getStmtClass ()) {
34
34
case Stmt::PseudoObjectExprClass: {
35
35
PseudoObjectExpr *POE = cast<PseudoObjectExpr>(S);
36
-
37
- if (OVMode == OV_Opaque && M.contains (POE->getSyntacticForm ()))
38
- break ;
39
-
40
- // If we are rebuilding the map, clear out any existing state.
41
- if (M.contains (POE->getSyntacticForm ()))
36
+ Expr *SF = POE->getSyntacticForm ();
37
+
38
+ auto [Iter, Inserted] = M.try_emplace (SF, S);
39
+ if (!Inserted) {
40
+ // Nothing more to do in opaque mode if we are updating an existing map.
41
+ if (OVMode == OV_Opaque)
42
+ break ;
43
+ // Update the entry in transparent mode, and clear existing state.
44
+ Iter->second = SF;
42
45
for (Stmt *SubStmt : S->children ())
43
46
M.erase (SubStmt);
44
-
45
- M[POE->getSyntacticForm ()] = S;
46
- BuildParentMap (M, POE->getSyntacticForm (), OV_Transparent);
47
+ }
48
+ BuildParentMap (M, SF, OV_Transparent);
47
49
48
50
for (PseudoObjectExpr::semantics_iterator I = POE->semantics_begin (),
49
51
E = POE->semantics_end ();
@@ -78,10 +80,15 @@ static void BuildParentMap(MapTy& M, Stmt* S,
78
80
// The right thing to do is to give the OpaqueValueExpr its syntactic
79
81
// parent, then not reassign that when traversing the semantic expressions.
80
82
OpaqueValueExpr *OVE = cast<OpaqueValueExpr>(S);
81
- if (OVMode == OV_Transparent || !M.contains (OVE->getSourceExpr ())) {
82
- M[OVE->getSourceExpr ()] = S;
83
- BuildParentMap (M, OVE->getSourceExpr (), OV_Transparent);
83
+ Expr *SrcExpr = OVE->getSourceExpr ();
84
+ auto [Iter, Inserted] = M.try_emplace (SrcExpr, S);
85
+ // Force update in transparent mode.
86
+ if (!Inserted && OVMode == OV_Transparent) {
87
+ Iter->second = S;
88
+ Inserted = true ;
84
89
}
90
+ if (Inserted)
91
+ BuildParentMap (M, SrcExpr, OV_Transparent);
85
92
break ;
86
93
}
87
94
case Stmt::CapturedStmtClass:
0 commit comments