llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Sameer Sahasrabuddhe (ssahasra) <details> <summary>Changes</summary> The implementation of ParentMap assumes that the key is absent if it is mapped to nullptr. This breaks when trying to store a tuple as the value type. Remove this assumption by explicit uses of `contains()` and `erase()`. --- Full diff: https://github.com/llvm/llvm-project/pull/121736.diff 1 Files Affected: - (modified) clang/lib/AST/ParentMap.cpp (+4-4) ``````````diff diff --git a/clang/lib/AST/ParentMap.cpp b/clang/lib/AST/ParentMap.cpp index fd749b02b758c9..ada7b19487a782 100644 --- a/clang/lib/AST/ParentMap.cpp +++ b/clang/lib/AST/ParentMap.cpp @@ -34,13 +34,13 @@ static void BuildParentMap(MapTy& M, Stmt* S, case Stmt::PseudoObjectExprClass: { PseudoObjectExpr *POE = cast<PseudoObjectExpr>(S); - if (OVMode == OV_Opaque && M[POE->getSyntacticForm()]) + if (OVMode == OV_Opaque && M.contains(POE->getSyntacticForm())) break; // If we are rebuilding the map, clear out any existing state. - if (M[POE->getSyntacticForm()]) + if (M.contains(POE->getSyntacticForm())) for (Stmt *SubStmt : S->children()) - M[SubStmt] = nullptr; + M.erase(SubStmt); M[POE->getSyntacticForm()] = S; BuildParentMap(M, POE->getSyntacticForm(), OV_Transparent); @@ -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; BuildParentMap(M, OVE->getSourceExpr(), OV_Transparent); } `````````` </details> https://github.com/llvm/llvm-project/pull/121736 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits