]> granicus.if.org Git - clang/commitdiff
For ObjCAtCatchStmt, removed field 'NextAtCatchStmt' (which referenced the next ...
authorTed Kremenek <kremenek@apple.com>
Fri, 1 Feb 2008 21:28:59 +0000 (21:28 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 1 Feb 2008 21:28:59 +0000 (21:28 +0000)
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

AST/Stmt.cpp
AST/StmtSerialization.cpp
include/clang/AST/Stmt.h

index fd72481fee842beee5b557f0f1293a74cc399af4..249794db595c79084bf478cdedefc0b770b0fb58 100644 (file)
@@ -152,13 +152,14 @@ ObjCAtCatchStmt::ObjCAtCatchStmt(SourceLocation atCatchLoc,
   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;
index 227f365e1cc6e87227aa0efcf300362f84a3b3bd..9a03a5320f97f0bcc8d7faa723bf7a2273264d4d 100644 (file)
@@ -859,8 +859,7 @@ WhileStmt* WhileStmt::CreateImpl(Deserializer& D) {
 void ObjCAtCatchStmt::EmitImpl(Serializer& S) const {
   S.Emit(AtCatchLoc);
   S.Emit(RParenLoc);
-  S.EmitPtr(NextAtCatchStmt);
-  S.BatchEmitOwnedPtrs((unsigned) END_EXPR,&SubExprs[0]);
+  S.BatchEmitOwnedPtrs((unsigned) END_EXPR, &SubExprs[0]);
 }
 
 ObjCAtCatchStmt* ObjCAtCatchStmt::CreateImpl(Deserializer& D) {
@@ -868,8 +867,6 @@ ObjCAtCatchStmt* ObjCAtCatchStmt::CreateImpl(Deserializer& D) {
   SourceLocation RParenLoc = SourceLocation::ReadVal(D);
   
   ObjCAtCatchStmt* stmt = new ObjCAtCatchStmt(AtCatchLoc,RParenLoc);
-  
-  D.ReadPtr(stmt->NextAtCatchStmt); // Allows backpatching.
   D.BatchReadOwnedPtrs((unsigned) END_EXPR, &stmt->SubExprs[0]);
 
   return stmt;
index 0018c54473cc36eadc1172667aaf1c4f3587eacd..751d995079caaaf527fcfd35bb1904158277c204 100644 (file)
@@ -817,9 +817,7 @@ public:
 /// ObjCAtCatchStmt - This represents objective-c's @catch statement.
 class ObjCAtCatchStmt : public Stmt {
 private:
-  // Points to next @catch statement, or null
-  ObjCAtCatchStmt *NextAtCatchStmt;
-  enum { SELECTOR, BODY, END_EXPR };
+  enum { SELECTOR, BODY, NEXT_CATCH, END_EXPR };
   Stmt *SubExprs[END_EXPR];
   SourceLocation AtCatchLoc, RParenLoc;
 
@@ -833,8 +831,14 @@ public:
   
   const Stmt *getCatchBody() const { return SubExprs[BODY]; }
   Stmt *getCatchBody() { return SubExprs[BODY]; }
-  const ObjCAtCatchStmt *getNextCatchStmt() const { return NextAtCatchStmt; }
-  ObjCAtCatchStmt *getNextCatchStmt() { return NextAtCatchStmt; }
+
+  const ObjCAtCatchStmt *getNextCatchStmt() const {
+    return static_cast<const ObjCAtCatchStmt*>(SubExprs[NEXT_CATCH]);
+  }
+  ObjCAtCatchStmt *getNextCatchStmt() { 
+    return static_cast<ObjCAtCatchStmt*>(SubExprs[NEXT_CATCH]);
+  }
+
   const Stmt *getCatchParamStmt() const { return SubExprs[SELECTOR]; }
   Stmt *getCatchParamStmt() { return SubExprs[SELECTOR]; }