[cfe-commits] r43891 - in /cfe/trunk: AST/StmtSerialization.cpp include/clang/AST/Expr.h
Ted Kremenek
kremenek at apple.com
Thu Nov 8 08:32:02 PST 2007
Author: kremenek
Date: Thu Nov 8 10:32:00 2007
New Revision: 43891
URL: http://llvm.org/viewvc/llvm-project?rev=43891&view=rev
Log:
Implemented serialization of AddrLabelExpr.
Implemented serialization of ConditionalOperator.
Implemented serialization of StmtExpr.
Fixed bug in serialization of IndirectGoto (did not properly serialize subexpression).
Modified:
cfe/trunk/AST/StmtSerialization.cpp
cfe/trunk/include/clang/AST/Expr.h
Modified: cfe/trunk/AST/StmtSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtSerialization.cpp?rev=43891&r1=43890&r2=43891&view=diff
==============================================================================
--- cfe/trunk/AST/StmtSerialization.cpp (original)
+++ cfe/trunk/AST/StmtSerialization.cpp Thu Nov 8 10:32:00 2007
@@ -35,6 +35,9 @@
assert (false && "Not implemented.");
return NULL;
+ case AddrLabelExprClass:
+ return AddrLabelExpr::directMaterialize(D);
+
case ArraySubscriptExprClass:
return ArraySubscriptExpr::directMaterialize(D);
@@ -61,6 +64,9 @@
case CompoundStmtClass:
return CompoundStmt::directMaterialize(D);
+
+ case ConditionalOperatorClass:
+ return ConditionalOperator::directMaterialize(D);
case ContinueStmtClass:
return ContinueStmt::directMaterialize(D);
@@ -115,7 +121,10 @@
case ReturnStmtClass:
return ReturnStmt::directMaterialize(D);
-
+
+ case StmtExprClass:
+ return StmtExpr::directMaterialize(D);
+
case StringLiteralClass:
return StringLiteral::directMaterialize(D);
@@ -130,6 +139,22 @@
}
}
+void AddrLabelExpr::directEmit(Serializer& S) const {
+ S.Emit(getType());
+ S.Emit(AmpAmpLoc);
+ S.Emit(LabelLoc);
+ S.EmitPtr(Label);
+}
+
+AddrLabelExpr* AddrLabelExpr::directMaterialize(Deserializer& D) {
+ QualType t = QualType::ReadVal(D);
+ SourceLocation AALoc = SourceLocation::ReadVal(D);
+ SourceLocation LLoc = SourceLocation::ReadVal(D);
+ AddrLabelExpr* expr = new AddrLabelExpr(AALoc,LLoc,NULL,t);
+ D.ReadPtr(expr->Label); // Pointer may be backpatched.
+ return expr;
+}
+
void ArraySubscriptExpr::directEmit(Serializer& S) const {
S.Emit(getType());
S.Emit(RBracketLoc);
@@ -272,6 +297,18 @@
return stmt;
}
+void ConditionalOperator::directEmit(Serializer& S) const {
+ S.Emit(getType());
+ S.BatchEmitOwnedPtrs((unsigned) END_EXPR, SubExprs);
+}
+
+ConditionalOperator* ConditionalOperator::directMaterialize(Deserializer& D) {
+ QualType t = QualType::ReadVal(D);
+ ConditionalOperator* c = new ConditionalOperator(NULL,NULL,NULL,t);
+ D.BatchReadOwnedPtrs((unsigned) END_EXPR, c->SubExprs);
+ return c;
+}
+
void ContinueStmt::directEmit(Serializer& S) const {
S.Emit(ContinueLoc);
}
@@ -418,13 +455,12 @@
}
void IndirectGotoStmt::directEmit(Serializer& S) const {
- S.EmitPtr(Target);
+ S.EmitOwnedPtr(Target);
}
IndirectGotoStmt* IndirectGotoStmt::directMaterialize(Deserializer& D) {
- IndirectGotoStmt* stmt = new IndirectGotoStmt(NULL);
- D.ReadPtr(stmt->Target); // The target may be backpatched.
- return stmt;
+ Expr* Target = D.ReadOwnedPtr<Expr>();
+ return new IndirectGotoStmt(Target);
}
void IntegerLiteral::directEmit(Serializer& S) const {
@@ -505,6 +541,21 @@
return new ReturnStmt(RetLoc,RetExpr);
}
+void StmtExpr::directEmit(Serializer& S) const {
+ S.Emit(getType());
+ S.Emit(LParenLoc);
+ S.Emit(RParenLoc);
+ S.EmitOwnedPtr(SubStmt);
+}
+
+StmtExpr* StmtExpr::directMaterialize(Deserializer& D) {
+ QualType t = QualType::ReadVal(D);
+ SourceLocation L = SourceLocation::ReadVal(D);
+ SourceLocation R = SourceLocation::ReadVal(D);
+ CompoundStmt* SubStmt = cast<CompoundStmt>(D.ReadOwnedPtr<Stmt>());
+ return new StmtExpr(SubStmt,t,L,R);
+}
+
void StringLiteral::directEmit(Serializer& S) const {
S.Emit(getType());
S.Emit(firstTokLoc);
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=43891&r1=43890&r2=43891&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Thu Nov 8 10:32:00 2007
@@ -912,6 +912,9 @@
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
+
+ virtual void directEmit(llvm::Serializer& S) const;
+ static ConditionalOperator* directMaterialize(llvm::Deserializer& D);
};
/// AddrLabelExpr - The GNU address of label extension, representing &&label.
@@ -937,6 +940,9 @@
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
+
+ virtual void directEmit(llvm::Serializer& S) const;
+ static AddrLabelExpr* directMaterialize(llvm::Deserializer& D);
};
/// StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
@@ -965,6 +971,9 @@
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
+
+ virtual void directEmit(llvm::Serializer& S) const;
+ static StmtExpr* directMaterialize(llvm::Deserializer& D);
};
/// TypesCompatibleExpr - GNU builtin-in function __builtin_type_compatible_p.
More information about the cfe-commits
mailing list