Update serialization for ObjCMessageExpr to handle additional bit-swizziling of receiver information.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52679 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h
index d588a1c..e63242e 100644
--- a/include/clang/AST/ExprObjC.h
+++ b/include/clang/AST/ExprObjC.h
@@ -225,13 +225,11 @@
};
class ObjCMessageExpr : public Expr {
- enum { RECEIVER=0, ARGS_START=1 };
-
- // Bit-swizziling flags.
- enum { IsInstMeth=0, IsClsMethDeclUnknown, IsClsMethDeclKnown, Flags=0x3 };
-
+ // SubExprs - The receiver and arguments of the message expression.
Stmt **SubExprs;
+ // NumArgs - The number of arguments (not including the receiver) to the
+ // message expression.
unsigned NumArgs;
// A unigue name for this message.
@@ -243,13 +241,21 @@
ObjCMethodDecl *MethodProto;
SourceLocation LBracloc, RBracloc;
+
+ // Constants for indexing into SubExprs.
+ enum { RECEIVER=0, ARGS_START=1 };
+
+ // Bit-swizziling flags.
+ enum { IsInstMeth=0, IsClsMethDeclUnknown, IsClsMethDeclKnown, Flags=0x3 };
+ unsigned getFlag() const { return (uintptr_t) SubExprs[RECEIVER] & Flags; }
// constructor used during deserialization
ObjCMessageExpr(Selector selInfo, QualType retType,
SourceLocation LBrac, SourceLocation RBrac,
- Expr **ArgExprs, unsigned nargs)
- : Expr(ObjCMessageExprClass, retType), NumArgs(nargs), SelName(selInfo),
- MethodProto(NULL), LBracloc(LBrac), RBracloc(RBrac) {}
+ Stmt **subexprs, unsigned nargs)
+ : Expr(ObjCMessageExprClass, retType), SubExprs(subexprs),
+ NumArgs(nargs), SelName(selInfo), MethodProto(NULL),
+ LBracloc(LBrac), RBracloc(RBrac) {}
public:
/// This constructor is used to represent class messages where the
diff --git a/lib/AST/StmtSerialization.cpp b/lib/AST/StmtSerialization.cpp
index cc794f0..aad7e81 100644
--- a/lib/AST/StmtSerialization.cpp
+++ b/lib/AST/StmtSerialization.cpp
@@ -1017,7 +1017,7 @@
}
void ObjCMessageExpr::EmitImpl(Serializer& S) const {
- S.EmitBool(getReceiver() ? true : false);
+ S.EmitInt(getFlag());
S.Emit(getType());
S.Emit(SelName);
S.Emit(LBracloc);
@@ -1027,14 +1027,18 @@
if (getReceiver())
S.BatchEmitOwnedPtrs(NumArgs+1, SubExprs);
- else {
- S.EmitPtr(getClassName());
+ else {
+ ClassInfo Info = getClassInfo();
+
+ if (Info.first) S.EmitPtr(Info.first);
+ else S.EmitPtr(Info.second);
+
S.BatchEmitOwnedPtrs(NumArgs, &SubExprs[ARGS_START]);
}
}
ObjCMessageExpr* ObjCMessageExpr::CreateImpl(Deserializer& D, ASTContext& C) {
- bool isReceiver = D.ReadBool();
+ unsigned flags = D.ReadInt();
QualType t = QualType::ReadVal(D);
Selector S = Selector::ReadVal(D);
SourceLocation L = SourceLocation::ReadVal(D);
@@ -1042,7 +1046,7 @@
// Construct an array for the subexpressions.
unsigned NumArgs = D.ReadInt();
- Expr** SubExprs = new Expr*[NumArgs+1];
+ Stmt** SubExprs = new Stmt*[NumArgs+1];
// Construct the ObjCMessageExpr object using the special ctor.
ObjCMessageExpr* ME = new ObjCMessageExpr(S, t, L, R, SubExprs, NumArgs);
@@ -1053,12 +1057,12 @@
// Now read in the arguments.
- if (isReceiver)
+ if (flags & Flags == IsInstMeth)
D.BatchReadOwnedPtrs(NumArgs+1, SubExprs, C);
else {
- // Read the pointer for ClassName. The Deserializer will handle the
+ // Read the pointer for Cls/ClassName. The Deserializer will handle the
// bit-mangling automatically.
- SubExprs[RECEIVER] = (Expr*) ((uintptr_t) 0x1);
+ SubExprs[RECEIVER] = (Stmt*) ((uintptr_t) flags);
D.ReadUIntPtr((uintptr_t&) SubExprs[RECEIVER]);
// Read the arguments.