[cfe-commits] r70044 - in /cfe/trunk: include/clang/AST/ExprObjC.h include/clang/Frontend/PCHBitCodes.h lib/Frontend/PCHReader.cpp lib/Frontend/PCHWriter.cpp
Steve Naroff
snaroff at apple.com
Sat Apr 25 07:04:43 PDT 2009
Author: snaroff
Date: Sat Apr 25 09:04:28 2009
New Revision: 70044
URL: http://llvm.org/viewvc/llvm-project?rev=70044&view=rev
Log:
Add PCH support for ObjCMessageExpr (needed to build Mail).
Modified:
cfe/trunk/include/clang/AST/ExprObjC.h
cfe/trunk/include/clang/Frontend/PCHBitCodes.h
cfe/trunk/lib/Frontend/PCHReader.cpp
cfe/trunk/lib/Frontend/PCHWriter.cpp
Modified: cfe/trunk/include/clang/AST/ExprObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprObjC.h?rev=70044&r1=70043&r2=70044&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprObjC.h (original)
+++ cfe/trunk/include/clang/AST/ExprObjC.h Sat Apr 25 09:04:28 2009
@@ -357,6 +357,9 @@
QualType retType, ObjCMethodDecl *methDecl,
SourceLocation LBrac, SourceLocation RBrac,
Expr **ArgExprs, unsigned NumArgs);
+
+ explicit ObjCMessageExpr(EmptyShell Empty)
+ : Expr(ObjCMessageExprClass, Empty) {}
~ObjCMessageExpr() {
delete [] SubExprs;
@@ -373,12 +376,15 @@
const Expr *getReceiver() const {
return const_cast<ObjCMessageExpr*>(this)->getReceiver();
}
-
+ // FIXME: need setters for different receiver types.
+ void setReceiver(Expr *rec) { SubExprs[RECEIVER] = rec; }
Selector getSelector() const { return SelName; }
-
+ void setSelector(Selector S) { SelName = S; }
+
const ObjCMethodDecl *getMethodDecl() const { return MethodProto; }
ObjCMethodDecl *getMethodDecl() { return MethodProto; }
-
+ void setMethodDecl(ObjCMethodDecl *MD) { MethodProto = MD; }
+
typedef std::pair<ObjCInterfaceDecl*, IdentifierInfo*> ClassInfo;
/// getClassInfo - For class methods, this returns both the ObjCInterfaceDecl*
@@ -396,7 +402,8 @@
/// getNumArgs - Return the number of actual arguments to this call.
unsigned getNumArgs() const { return NumArgs; }
-
+ void setNumArgs(unsigned nArgs) { NumArgs = nArgs; }
+
/// getArg - Return the specified argument.
Expr *getArg(unsigned Arg) {
assert(Arg < NumArgs && "Arg access out of range!");
@@ -412,6 +419,10 @@
SubExprs[Arg+ARGS_START] = ArgExpr;
}
+ void setSourceRange(SourceRange R) {
+ LBracloc = R.getBegin();
+ RBracloc = R.getEnd();
+ }
virtual SourceRange getSourceRange() const {
return SourceRange(LBracloc, RBracloc);
}
Modified: cfe/trunk/include/clang/Frontend/PCHBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHBitCodes.h?rev=70044&r1=70043&r2=70044&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHBitCodes.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHBitCodes.h Sat Apr 25 09:04:28 2009
@@ -563,10 +563,12 @@
/// \brief A ObjCSelectorExpr record.
EXPR_OBJC_SELECTOR_EXPR,
/// \brief A ObjCProtocolExpr record.
- EXPR_OBJC_PROTOCOL_EXPR
-
+ EXPR_OBJC_PROTOCOL_EXPR,
+ /// \brief A ObjCMessageExpr record.
+ EXPR_OBJC_MESSAGE_EXPR
+
// FIXME: From ExprObjC.h: ObjCIvarRefExpr, ObjCPropertyRefExpr,
- // ObjCKVCRefExpr, ObjCMessageExpr, ObjCSuperExpr
+ // ObjCKVCRefExpr, ObjCSuperExpr
};
/// \brief The kinds of designators that can occur in a
Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=70044&r1=70043&r2=70044&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Sat Apr 25 09:04:28 2009
@@ -497,6 +497,7 @@
unsigned VisitObjCEncodeExpr(ObjCEncodeExpr *E);
unsigned VisitObjCSelectorExpr(ObjCSelectorExpr *E);
unsigned VisitObjCProtocolExpr(ObjCProtocolExpr *E);
+ unsigned VisitObjCMessageExpr(ObjCMessageExpr *E);
};
}
@@ -1080,6 +1081,21 @@
return 0;
}
+unsigned PCHStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
+ VisitExpr(E);
+ E->setNumArgs(Record[Idx++]);
+ SourceRange SR(SourceLocation::getFromRawEncoding(Record[Idx++]),
+ SourceLocation::getFromRawEncoding(Record[Idx++]));
+ E->setSourceRange(SR);
+ E->setSelector(Reader.GetSelector(Record, Idx));
+ E->setMethodDecl(cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++])));
+ // FIXME: deal with class messages.
+ E->setReceiver(cast<Expr>(StmtStack[StmtStack.size() - E->getNumArgs() - 1]));
+ for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
+ E->setArg(I, cast<Expr>(StmtStack[StmtStack.size() - N + I]));
+ return E->getNumArgs() + 1;
+}
+
//===----------------------------------------------------------------------===//
// PCH reader implementation
@@ -3368,6 +3384,9 @@
case pch::EXPR_OBJC_PROTOCOL_EXPR:
S = new (Context) ObjCProtocolExpr(Empty);
break;
+ case pch::EXPR_OBJC_MESSAGE_EXPR:
+ S = new (Context) ObjCMessageExpr(Empty);
+ break;
}
// We hit a STMT_STOP, so we're done with this expression.
Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=70044&r1=70043&r2=70044&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Sat Apr 25 09:04:28 2009
@@ -672,6 +672,7 @@
void VisitObjCEncodeExpr(ObjCEncodeExpr *E);
void VisitObjCSelectorExpr(ObjCSelectorExpr *E);
void VisitObjCProtocolExpr(ObjCProtocolExpr *E);
+ void VisitObjCMessageExpr(ObjCMessageExpr *E);
};
}
@@ -1198,6 +1199,21 @@
Code = pch::EXPR_OBJC_PROTOCOL_EXPR;
}
+void PCHStmtWriter::VisitObjCMessageExpr(ObjCMessageExpr *E) {
+ VisitExpr(E);
+ Record.push_back(E->getNumArgs());
+ Writer.AddSourceLocation(E->getSourceRange().getBegin(), Record);
+ Writer.AddSourceLocation(E->getSourceRange().getEnd(), Record);
+ Writer.AddSelectorRef(E->getSelector(), Record);
+ Writer.AddDeclRef(E->getMethodDecl(), Record); // optional
+ // FIXME: deal with class messages.
+ Writer.WriteSubStmt(E->getReceiver());
+ for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end();
+ Arg != ArgEnd; ++Arg)
+ Writer.WriteSubStmt(*Arg);
+ Code = pch::EXPR_OBJC_MESSAGE_EXPR;
+}
+
//===----------------------------------------------------------------------===//
// PCHWriter Implementation
More information about the cfe-commits
mailing list