[cfe-commits] r43806 - in /cfe/trunk: AST/StmtSerialization.cpp include/clang/AST/Expr.h include/clang/AST/Stmt.h
Ted Kremenek
kremenek at apple.com
Tue Nov 6 21:25:31 PST 2007
Author: kremenek
Date: Tue Nov 6 23:25:31 2007
New Revision: 43806
URL: http://llvm.org/viewvc/llvm-project?rev=43806&view=rev
Log:
Implemented serialization of SwitchStmt, CaseStmt, BreakStmt, DefaultStmt,
and ParenExpr.
Modified:
cfe/trunk/AST/StmtSerialization.cpp
cfe/trunk/include/clang/AST/Expr.h
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=43806&r1=43805&r2=43806&view=diff
==============================================================================
--- cfe/trunk/AST/StmtSerialization.cpp (original)
+++ cfe/trunk/AST/StmtSerialization.cpp Tue Nov 6 23:25:31 2007
@@ -34,6 +34,12 @@
case BinaryOperatorClass:
return BinaryOperator::directMaterialize(D);
+ case BreakStmtClass:
+ return BreakStmt::directMaterialize(D);
+
+ case CaseStmtClass:
+ return CaseStmt::directMaterialize(D);
+
case CompoundStmtClass:
return CompoundStmt::directMaterialize(D);
@@ -42,7 +48,10 @@
case DeclStmtClass:
return DeclStmt::directMaterialize(D);
-
+
+ case DefaultStmtClass:
+ return DefaultStmt::directMaterialize(D);
+
case IntegerLiteralClass:
return IntegerLiteral::directMaterialize(D);
@@ -52,8 +61,14 @@
case NullStmtClass:
return NullStmt::directMaterialize(D);
+ case ParenExprClass:
+ return ParenExpr::directMaterialize(D);
+
case ReturnStmtClass:
- return ReturnStmt::directMaterialize(D);
+ return ReturnStmt::directMaterialize(D);
+
+ case SwitchStmtClass:
+ return SwitchStmt::directMaterialize(D);
}
}
@@ -74,6 +89,34 @@
return new BinaryOperator(LHS,RHS,Opc,Result,OpLoc);
}
+void BreakStmt::directEmit(llvm::Serializer& S) const {
+ S.Emit(BreakLoc);
+}
+
+BreakStmt* BreakStmt::directMaterialize(llvm::Deserializer& D) {
+ SourceLocation Loc = SourceLocation::ReadVal(D);
+ return new BreakStmt(Loc);
+}
+
+void CaseStmt::directEmit(llvm::Serializer& S) const {
+ S.Emit(CaseLoc);
+ S.EmitOwnedPtr(getLHS());
+ S.EmitOwnedPtr(getRHS());
+ S.EmitOwnedPtr(getSubStmt());
+ S.EmitPtr(getNextSwitchCase());
+}
+
+CaseStmt* CaseStmt::directMaterialize(llvm::Deserializer& D) {
+ SourceLocation CaseLoc = SourceLocation::ReadVal(D);
+ Expr* LHS = D.ReadOwnedPtr<Expr>();
+ Expr* RHS = D.ReadOwnedPtr<Expr>();
+ Stmt* SubStmt = D.ReadOwnedPtr<Stmt>();
+
+ CaseStmt* stmt = new CaseStmt(LHS,RHS,SubStmt,CaseLoc);
+ stmt->setNextSwitchCase(D.ReadPtr<SwitchCase>());
+
+ return stmt;
+}
void CompoundStmt::directEmit(llvm::Serializer& S) const {
S.Emit(LBracLoc);
@@ -123,6 +166,21 @@
return new DeclStmt(decl);
}
+void DefaultStmt::directEmit(llvm::Serializer& S) const {
+ S.Emit(DefaultLoc);
+ S.EmitOwnedPtr(getSubStmt());
+ S.EmitPtr(getNextSwitchCase());
+}
+
+DefaultStmt* DefaultStmt::directMaterialize(llvm::Deserializer& D) {
+ SourceLocation Loc = SourceLocation::ReadVal(D);
+ Stmt* SubStmt = D.ReadOwnedPtr<Stmt>();
+
+ DefaultStmt* stmt = new DefaultStmt(Loc,SubStmt);
+ stmt->setNextSwitchCase(D.ReadPtr<SwitchCase>());
+
+ return stmt;
+}
void IntegerLiteral::directEmit(llvm::Serializer& S) const {
S.Emit(Loc);
@@ -165,6 +223,19 @@
return new NullStmt(SemiLoc);
}
+void ParenExpr::directEmit(llvm::Serializer& S) const {
+ S.Emit(L);
+ S.Emit(R);
+ S.EmitOwnedPtr(Val);
+}
+
+ParenExpr* ParenExpr::directMaterialize(llvm::Deserializer& D) {
+ SourceLocation L = SourceLocation::ReadVal(D);
+ SourceLocation R = SourceLocation::ReadVal(D);
+ Expr* val = D.ReadOwnedPtr<Expr>();
+ return new ParenExpr(L,R,val);
+}
+
void ReturnStmt::directEmit(llvm::Serializer& S) const {
S.Emit(RetLoc);
S.EmitOwnedPtr(RetExpr);
@@ -176,3 +247,22 @@
return new ReturnStmt(RetLoc,RetExpr);
}
+void SwitchStmt::directEmit(llvm::Serializer& S) const {
+ S.Emit(SwitchLoc);
+ S.EmitOwnedPtr(getCond());
+ S.EmitOwnedPtr(getBody());
+ S.EmitPtr(FirstCase);
+}
+
+SwitchStmt* SwitchStmt::directMaterialize(llvm::Deserializer& D) {
+ SourceLocation Loc = SourceLocation::ReadVal(D);
+ Stmt* Cond = D.ReadOwnedPtr<Stmt>();
+ Stmt* Body = D.ReadOwnedPtr<Stmt>();
+ SwitchCase* FirstCase = cast<SwitchCase>(D.ReadPtr<Stmt>());
+
+ SwitchStmt* stmt = new SwitchStmt(cast<Expr>(Cond));
+ stmt->setBody(Body,Loc);
+ stmt->FirstCase = FirstCase;
+
+ return stmt;
+}
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=43806&r1=43805&r2=43806&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Nov 6 23:25:31 2007
@@ -339,6 +339,9 @@
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
+
+ void directEmit(llvm::Serializer& S) const;
+ static ParenExpr* directMaterialize(llvm::Deserializer& D);
};
Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=43806&r1=43805&r2=43806&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Tue Nov 6 23:25:31 2007
@@ -295,6 +295,9 @@
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
+
+ virtual void directEmit(llvm::Serializer& S) const;
+ static CaseStmt* directMaterialize(llvm::Deserializer& D);
};
class DefaultStmt : public SwitchCase {
@@ -321,6 +324,9 @@
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
+
+ virtual void directEmit(llvm::Serializer& S) const;
+ static DefaultStmt* directMaterialize(llvm::Deserializer& D);
};
class LabelStmt : public Stmt {
@@ -441,6 +447,9 @@
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
+
+ void directEmit(llvm::Serializer& S) const;
+ static SwitchStmt* directMaterialize(llvm::Deserializer& D);
};
@@ -634,6 +643,9 @@
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
+
+ void directEmit(llvm::Serializer& S) const;
+ static BreakStmt* directMaterialize(llvm::Deserializer& D);
};
More information about the cfe-commits
mailing list