For ObjCAtCatchStmt, removed field 'NextAtCatchStmt' (which referenced the next @catch)
and put the the next ObjcAtCatchStmt* as part of SubExprs. This fixes a bug with
iterating over the children of ObjcAtCatch, where the next @catch was not
properly being iterated over as a child.
Altered serialization of ObjCAtCatchStmt to reflect this new layout of
its subexpressions, and fixed an ownership issue with the next @catch not
being serialized as an owned pointer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46647 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/Stmt.cpp b/AST/Stmt.cpp
index fd72481..249794d 100644
--- a/AST/Stmt.cpp
+++ b/AST/Stmt.cpp
@@ -152,13 +152,14 @@
SubExprs[SELECTOR] = catchVarStmtDecl;
SubExprs[BODY] = atCatchStmt;
if (!atCatchList)
- NextAtCatchStmt = NULL;
+ SubExprs[NEXT_CATCH] = NULL;
else {
- ObjCAtCatchStmt *AtCatchList =
- static_cast<ObjCAtCatchStmt*>(atCatchList);
- while (AtCatchList->NextAtCatchStmt)
- AtCatchList = AtCatchList->NextAtCatchStmt;
- AtCatchList->NextAtCatchStmt = this;
+ ObjCAtCatchStmt *AtCatchList = static_cast<ObjCAtCatchStmt*>(atCatchList);
+
+ while (ObjCAtCatchStmt* NextCatch = AtCatchList->getNextCatchStmt())
+ AtCatchList = NextCatch;
+
+ AtCatchList->SubExprs[NEXT_CATCH] = this;
}
AtCatchLoc = atCatchLoc;
RParenLoc = rparenloc;