aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/StmtSerialization.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-05-01 17:26:20 +0000
committerTed Kremenek <kremenek@apple.com>2008-05-01 17:26:20 +0000
commitea958e57a370b641c5a69347b75e9f8e3b5a41a2 (patch)
treebbdd104a583c9db6dac9fff848ad2600d0ba49ad /lib/AST/StmtSerialization.cpp
parentc7122d5dd2aba01a59259f1f659bf59eca30d7e6 (diff)
Use pointer swizziling to unify in ObjCMessageExpr the receiver and classname "fields". This saves us a pointer.
Implemented serialization for ObjCMessageExpr. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50528 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/StmtSerialization.cpp')
-rw-r--r--lib/AST/StmtSerialization.cpp61
1 files changed, 58 insertions, 3 deletions
diff --git a/lib/AST/StmtSerialization.cpp b/lib/AST/StmtSerialization.cpp
index 3bec743740..adaa559b06 100644
--- a/lib/AST/StmtSerialization.cpp
+++ b/lib/AST/StmtSerialization.cpp
@@ -181,6 +181,9 @@ Stmt* Stmt::Create(Deserializer& D, ASTContext& C) {
case ObjCIvarRefExprClass:
return ObjCIvarRefExpr::CreateImpl(D, C);
+ case ObjCMessageExprClass:
+ return ObjCMessageExpr::CreateImpl(D, C);
+
case ObjCSelectorExprClass:
return ObjCSelectorExpr::CreateImpl(D, C);
@@ -190,9 +193,9 @@ Stmt* Stmt::Create(Deserializer& D, ASTContext& C) {
//==--------------------------------------==//
// C++
//==--------------------------------------==//
- case CXXDefaultArgExprClass:
- return CXXDefaultArgExpr::CreateImpl(D, C);
+ case CXXDefaultArgExprClass:
+ return CXXDefaultArgExpr::CreateImpl(D, C);
}
}
@@ -327,7 +330,7 @@ void CallExpr::EmitImpl(Serializer& S) const {
S.Emit(getType());
S.Emit(RParenLoc);
S.EmitInt(NumArgs);
- S.BatchEmitOwnedPtrs(NumArgs+1,SubExprs);
+ S.BatchEmitOwnedPtrs(NumArgs+1, SubExprs);
}
CallExpr* CallExpr::CreateImpl(Deserializer& D, ASTContext& C) {
@@ -984,6 +987,58 @@ ObjCIvarRefExpr* ObjCIvarRefExpr::CreateImpl(Deserializer& D, ASTContext& C) {
return dr;
}
+void ObjCMessageExpr::EmitImpl(Serializer& S) const {
+ S.EmitBool(getReceiver() ? true : false);
+ S.Emit(getType());
+ S.Emit(SelName);
+ S.Emit(LBracloc);
+ S.Emit(RBracloc);
+ S.EmitInt(NumArgs);
+ S.EmitPtr(MethodProto);
+
+ if (getReceiver())
+ S.BatchEmitOwnedPtrs(NumArgs+1, SubExprs);
+ else {
+ S.EmitPtr(getClassName());
+ S.BatchEmitOwnedPtrs(NumArgs, &SubExprs[ARGS_START]);
+ }
+}
+
+ObjCMessageExpr* ObjCMessageExpr::CreateImpl(Deserializer& D, ASTContext& C) {
+ bool isReceiver = D.ReadBool();
+ QualType t = QualType::ReadVal(D);
+ Selector S = Selector::ReadVal(D);
+ SourceLocation L = SourceLocation::ReadVal(D);
+ SourceLocation R = SourceLocation::ReadVal(D);
+
+ // Construct an array for the subexpressions.
+ unsigned NumArgs = D.ReadInt();
+ Expr** SubExprs = new Expr*[NumArgs+1];
+
+ // Construct the ObjCMessageExpr object using the special ctor.
+ ObjCMessageExpr* ME = new ObjCMessageExpr(S, t, L, R, SubExprs, NumArgs);
+
+ // Read in the MethodProto. Read the instance variable directly
+ // allows it to be backpatched.
+ D.ReadPtr(ME->MethodProto);
+
+ // Now read in the arguments.
+
+ if (isReceiver)
+ D.BatchReadOwnedPtrs(NumArgs+1, SubExprs, C);
+ else {
+ // Read the pointer for ClassName. The Deserializer will handle the
+ // bit-mangling automatically.
+ SubExprs[RECEIVER] = (Expr*) ((uintptr_t) 0x1);
+ D.ReadUIntPtr((uintptr_t&) SubExprs[RECEIVER]);
+
+ // Read the arguments.
+ D.BatchReadOwnedPtrs(NumArgs, &SubExprs[ARGS_START], C);
+ }
+
+ return ME;
+}
+
void ObjCSelectorExpr::EmitImpl(Serializer& S) const {
S.Emit(AtLoc);
S.Emit(RParenLoc);