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

Ted Kremenek kremenek at apple.com
Tue Nov 6 16:37:40 PST 2007


Author: kremenek
Date: Tue Nov  6 18:37:40 2007
New Revision: 43796

URL: http://llvm.org/viewvc/llvm-project?rev=43796&view=rev
Log:
Added serialization/deserialization of DeclStmts.
Reordered stmt serialization method implementations to be in alphabetical order.

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

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

==============================================================================
--- cfe/trunk/AST/StmtSerialization.cpp (original)
+++ cfe/trunk/AST/StmtSerialization.cpp Tue Nov  6 18:37:40 2007
@@ -30,24 +30,43 @@
     default:  
       assert (false && "Not implemented.");
       return NULL;
+    
+    case BinaryOperatorClass:
+      return BinaryOperator::directMaterialize(D);
       
     case CompoundStmtClass:
       return CompoundStmt::directMaterialize(D);
       
-    case ReturnStmtClass:
-      return ReturnStmt::directMaterialize(D);
-      
-    case BinaryOperatorClass:
-      return BinaryOperator::directMaterialize(D);
-      
     case DeclRefExprClass:
       return DeclRefExpr::directMaterialize(D);
       
+    case DeclStmtClass:
+      return DeclStmt::directMaterialize(D);
+            
     case IntegerLiteralClass:
-      return IntegerLiteral::directMaterialize(D);
+      return IntegerLiteral::directMaterialize(D);      
+      
+    case ReturnStmtClass:
+      return ReturnStmt::directMaterialize(D);        
   }
 }
 
+void BinaryOperator::directEmit(llvm::Serializer& S) const {
+  S.EmitInt(Opc);
+  S.Emit(OpLoc);;
+  S.Emit(getType());
+  S.EmitOwnedPtr(getLHS());
+  S.EmitOwnedPtr(getRHS());
+}
+
+BinaryOperator* BinaryOperator::directMaterialize(llvm::Deserializer& D) {
+  Opcode Opc = static_cast<Opcode>(D.ReadInt());
+  SourceLocation OpLoc = SourceLocation::ReadVal(D);
+  QualType Result = QualType::ReadVal(D);
+  Expr* LHS = D.ReadOwnedPtr<Expr>();
+  Expr* RHS = D.ReadOwnedPtr<Expr>();
+  return new BinaryOperator(LHS,RHS,Opc,Result,OpLoc);
+}
 
 
 void CompoundStmt::directEmit(llvm::Serializer& S) const {
@@ -74,34 +93,9 @@
   return stmt;
 }
 
-
-void ReturnStmt::directEmit(llvm::Serializer& S) const {
-  S.Emit(RetLoc);
-  S.EmitOwnedPtr(RetExpr);
-}
-
-ReturnStmt* ReturnStmt::directMaterialize(llvm::Deserializer& D) {
-  SourceLocation RetLoc = SourceLocation::ReadVal(D);
-  Expr* RetExpr = D.ReadOwnedPtr<Expr>();  
-  return new ReturnStmt(RetLoc,RetExpr);
-}
-
-
-void BinaryOperator::directEmit(llvm::Serializer& S) const {
-  S.EmitInt(Opc);
-  S.Emit(OpLoc);;
-  S.Emit(getType());
-  S.EmitOwnedPtr(getLHS());
-  S.EmitOwnedPtr(getRHS());
-}
-
-BinaryOperator* BinaryOperator::directMaterialize(llvm::Deserializer& D) {
-  Opcode Opc = static_cast<Opcode>(D.ReadInt());
-  SourceLocation OpLoc = SourceLocation::ReadVal(D);
-  QualType Result = QualType::ReadVal(D);
-  Expr* LHS = D.ReadOwnedPtr<Expr>();
-  Expr* RHS = D.ReadOwnedPtr<Expr>();
-  return new BinaryOperator(LHS,RHS,Opc,Result,OpLoc);
+void DeclStmt::directEmit(llvm::Serializer& S) const {
+  // FIXME: special handling for struct decls.
+  S.EmitOwnedPtr(getDecl());  
 }
 
 void DeclRefExpr::directEmit(llvm::Serializer& S) const {
@@ -118,6 +112,12 @@
   return dr;
 }
 
+DeclStmt* DeclStmt::directMaterialize(llvm::Deserializer& D) {
+  ScopedDecl* decl = cast<ScopedDecl>(D.ReadOwnedPtr<Decl>());
+  return new DeclStmt(decl);
+}
+
+
 void IntegerLiteral::directEmit(llvm::Serializer& S) const {
   S.Emit(Loc);
   S.Emit(getType());
@@ -136,4 +136,16 @@
   
   return expr;
 }
-  
+
+
+void ReturnStmt::directEmit(llvm::Serializer& S) const {
+  S.Emit(RetLoc);
+  S.EmitOwnedPtr(RetExpr);
+}
+
+ReturnStmt* ReturnStmt::directMaterialize(llvm::Deserializer& D) {
+  SourceLocation RetLoc = SourceLocation::ReadVal(D);
+  Expr* RetExpr = D.ReadOwnedPtr<Expr>();  
+  return new ReturnStmt(RetLoc,RetExpr);
+}
+

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

==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Tue Nov  6 18:37:40 2007
@@ -143,6 +143,9 @@
   // Iterators
   virtual child_iterator child_begin();
   virtual child_iterator child_end();
+  
+  virtual void directEmit(llvm::Serializer& S) const;
+  static DeclStmt* directMaterialize(llvm::Deserializer& D);
 };
 
 /// NullStmt - This is the null statement ";": C99 6.8.3p3.





More information about the cfe-commits mailing list