[cfe-commits] r46647 - in /cfe/trunk: AST/Stmt.cpp AST/StmtSerialization.cpp include/clang/AST/Stmt.h

Ted Kremenek kremenek at apple.com
Fri Feb 1 13:28:59 PST 2008


Author: kremenek
Date: Fri Feb  1 15:28:59 2008
New Revision: 46647

URL: http://llvm.org/viewvc/llvm-project?rev=46647&view=rev
Log:
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.

Modified:
    cfe/trunk/AST/Stmt.cpp
    cfe/trunk/AST/StmtSerialization.cpp
    cfe/trunk/include/clang/AST/Stmt.h

Modified: cfe/trunk/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Stmt.cpp?rev=46647&r1=46646&r2=46647&view=diff

==============================================================================
--- cfe/trunk/AST/Stmt.cpp (original)
+++ cfe/trunk/AST/Stmt.cpp Fri Feb  1 15:28:59 2008
@@ -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;

Modified: cfe/trunk/AST/StmtSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtSerialization.cpp?rev=46647&r1=46646&r2=46647&view=diff

==============================================================================
--- cfe/trunk/AST/StmtSerialization.cpp (original)
+++ cfe/trunk/AST/StmtSerialization.cpp Fri Feb  1 15:28:59 2008
@@ -859,8 +859,7 @@
 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 @@
   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;

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=46647&r1=46646&r2=46647&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Fri Feb  1 15:28:59 2008
@@ -817,9 +817,7 @@
 /// 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 @@
   
   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]; }
   





More information about the cfe-commits mailing list