[clang] [clang] [NFC] explicitly check if ParentMap contains key (PR #121736)

Sameer Sahasrabuddhe via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 6 22:55:33 PST 2025


================
@@ -78,7 +78,7 @@ static void BuildParentMap(MapTy& M, Stmt* S,
     // The right thing to do is to give the OpaqueValueExpr its syntactic
     // parent, then not reassign that when traversing the semantic expressions.
     OpaqueValueExpr *OVE = cast<OpaqueValueExpr>(S);
-    if (OVMode == OV_Transparent || !M[OVE->getSourceExpr()]) {
+    if (OVMode == OV_Transparent || !M.contains(OVE->getSourceExpr())) {
       M[OVE->getSourceExpr()] = S;
----------------
ssahasra wrote:

Fixed with try_emplace() to avoid the second lookup as well, which inserts when the key is already present.


https://github.com/llvm/llvm-project/pull/121736


More information about the cfe-commits mailing list