From: Daniel Dunbar Date: Tue, 14 Oct 2008 16:57:09 +0000 (+0000) Subject: Add serialization support in several missing places. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d17c24ff8597fe0dee4210639d225bc4f7c5ac04;p=clang Add serialization support in several missing places. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57502 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 7fe172afc4..c2ba3f9ee4 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -1150,6 +1150,9 @@ public: // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); + + virtual void EmitImpl(llvm::Serializer& S) const; + static TypesCompatibleExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C); }; /// ShuffleVectorExpr - clang-specific builtin-in function @@ -1215,6 +1218,9 @@ public: // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); + + virtual void EmitImpl(llvm::Serializer& S) const; + static ShuffleVectorExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C); }; /// ChooseExpr - GNU builtin-in function __builtin_choose_expr. @@ -1256,6 +1262,9 @@ public: // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); + + virtual void EmitImpl(llvm::Serializer& S) const; + static ChooseExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C); }; /// OverloadExpr - Clang builtin function __builtin_overload. @@ -1370,6 +1379,9 @@ public: // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); + + virtual void EmitImpl(llvm::Serializer& S) const; + static VAArgExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C); }; /// InitListExpr - used for struct and array initializers, such as: @@ -1496,6 +1508,9 @@ public: // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); + + virtual void EmitImpl(llvm::Serializer& S) const; + static ExtVectorElementExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C); }; diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h index 32c7996733..3b19fe9527 100644 --- a/include/clang/AST/ExprObjC.h +++ b/include/clang/AST/ExprObjC.h @@ -148,6 +148,9 @@ public: // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); + + virtual void EmitImpl(llvm::Serializer& S) const; + static ObjCProtocolExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C); }; /// ObjCIvarRefExpr - A reference to an ObjC instance variable. diff --git a/lib/AST/StmtSerialization.cpp b/lib/AST/StmtSerialization.cpp index a4fd8c3567..a6bcf7e8b5 100644 --- a/lib/AST/StmtSerialization.cpp +++ b/lib/AST/StmtSerialization.cpp @@ -804,6 +804,80 @@ StmtExpr* StmtExpr::CreateImpl(Deserializer& D, ASTContext& C) { return new StmtExpr(SubStmt,t,L,R); } +void TypesCompatibleExpr::EmitImpl(llvm::Serializer& S) const { + S.Emit(getType()); + S.Emit(BuiltinLoc); + S.Emit(RParenLoc); + S.Emit(Type1); + S.Emit(Type2); +} + +TypesCompatibleExpr* TypesCompatibleExpr::CreateImpl(llvm::Deserializer& D, + ASTContext& C) { + QualType RT = QualType::ReadVal(D); + SourceLocation BL = SourceLocation::ReadVal(D); + SourceLocation RP = SourceLocation::ReadVal(D); + QualType T1 = QualType::ReadVal(D); + QualType T2 = QualType::ReadVal(D); + return new TypesCompatibleExpr(RT, BL, T1, T2, RP); +} + +void ShuffleVectorExpr::EmitImpl(llvm::Serializer& S) const { + S.Emit(getType()); + S.Emit(BuiltinLoc); + S.Emit(RParenLoc); + S.EmitInt(NumExprs); + for (unsigned i = 0; i < NumExprs; ++i) + S.EmitOwnedPtr(getExpr(i)); +} + +ShuffleVectorExpr* ShuffleVectorExpr::CreateImpl(llvm::Deserializer& D, + ASTContext& C) { + QualType T = QualType::ReadVal(D); + SourceLocation BL = SourceLocation::ReadVal(D); + SourceLocation RP = SourceLocation::ReadVal(D); + unsigned NumExprs = D.ReadInt(); + llvm::SmallVector Exprs(NumExprs); + for (unsigned i = 0; i < NumExprs; ++i) + Exprs[i] = D.ReadOwnedPtr(C); + + return new ShuffleVectorExpr(Exprs.begin(), NumExprs, T, BL, RP); +} + +void ChooseExpr::EmitImpl(llvm::Serializer& S) const { + S.Emit(getType()); + S.Emit(BuiltinLoc); + S.Emit(RParenLoc); + S.EmitOwnedPtr(getCond()); + S.EmitOwnedPtr(getLHS()); + S.EmitOwnedPtr(getRHS()); +} + +ChooseExpr* ChooseExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) { + QualType T = QualType::ReadVal(D); + SourceLocation BL = SourceLocation::ReadVal(D); + SourceLocation RP = SourceLocation::ReadVal(D); + Expr *Cond = D.ReadOwnedPtr(C); + Expr *LHS = D.ReadOwnedPtr(C); + Expr *RHS = D.ReadOwnedPtr(C); + return new ChooseExpr(BL, Cond, LHS, RHS, T, RP); +} + +void VAArgExpr::EmitImpl(llvm::Serializer& S) const { + S.Emit(getType()); + S.Emit(BuiltinLoc); + S.Emit(RParenLoc); + S.EmitOwnedPtr(getSubExpr()); +} + +VAArgExpr* VAArgExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) { + QualType T = QualType::ReadVal(D); + SourceLocation BL = SourceLocation::ReadVal(D); + SourceLocation RP = SourceLocation::ReadVal(D); + Expr *E = D.ReadOwnedPtr(C); + return new VAArgExpr(BL, E, T, RP); +} + void StringLiteral::EmitImpl(Serializer& S) const { S.Emit(getType()); S.Emit(firstTokLoc); @@ -981,6 +1055,22 @@ ObjCForCollectionStmt* ObjCForCollectionStmt::CreateImpl(Deserializer& D, ASTCon return new ObjCForCollectionStmt(Element,Collection,Body,ForLoc, RParenLoc); } +void ObjCProtocolExpr::EmitImpl(llvm::Serializer& S) const { + S.Emit(getType()); + S.EmitPtr(Protocol); + S.Emit(AtLoc); + S.Emit(RParenLoc); +} + +ObjCProtocolExpr* ObjCProtocolExpr::CreateImpl(llvm::Deserializer& D, + ASTContext& C) { + QualType T = QualType::ReadVal(D); + ObjCProtocolDecl *PD = D.ReadPtr(); + SourceLocation AL = SourceLocation::ReadVal(D); + SourceLocation RP = SourceLocation::ReadVal(D); + return new ObjCProtocolExpr(T, PD, AL, RP); +} + void ObjCIvarRefExpr::EmitImpl(Serializer& S) const { S.Emit(Loc); S.Emit(getType()); @@ -1112,6 +1202,21 @@ ObjCStringLiteral* ObjCStringLiteral::CreateImpl(Deserializer& D, ASTContext& C) // Serialization for Clang Extensions. //===----------------------------------------------------------------------===// +void ExtVectorElementExpr::EmitImpl(llvm::Serializer& S) const { + S.Emit(getType()); + S.EmitOwnedPtr(getBase()); + S.EmitPtr(&Accessor); + S.Emit(AccessorLoc); +} + +ExtVectorElementExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C) { + QualType T = QualType::ReadVal(D); + Expr *B = D.ReadOwnedPtr(C); + IdentifierInfo *A = D.ReadPtr(); + SourceLocation AL = SourceLocation::ReadVal(D); + return new ExtVectorElementExpr(T, B, *A, AL); +} + void BlockExpr::EmitImpl(Serializer& S) const { S.Emit(getType()); S.EmitOwnedPtr(TheBlock);