aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2007-11-03 16:37:59 +0000
committerSteve Naroff <snaroff@apple.com>2007-11-03 16:37:59 +0000
commitdb611d556f71f98b66b69514d45958d76e5727ab (patch)
tree27221aab0de073c1252838fbe09792e9ab1f7f1b
parentbeaf299a2701c5559a4e5d76b0c40f805afb8e6a (diff)
Add a method prototype slot/getter to the ObjCMessageExpr AST.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43666 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--AST/Expr.cpp12
-rw-r--r--Sema/SemaExpr.cpp12
-rw-r--r--include/clang/AST/Expr.h14
3 files changed, 27 insertions, 11 deletions
diff --git a/AST/Expr.cpp b/AST/Expr.cpp
index 14ef48c7de..ffb34f59ca 100644
--- a/AST/Expr.cpp
+++ b/AST/Expr.cpp
@@ -871,9 +871,11 @@ unsigned OCUVectorElementExpr::getEncodedElementAccess() const {
// constructor for instance messages.
ObjCMessageExpr::ObjCMessageExpr(Expr *receiver, Selector selInfo,
- QualType retType, SourceLocation LBrac, SourceLocation RBrac,
+ QualType retType, ObjcMethodDecl *mproto,
+ SourceLocation LBrac, SourceLocation RBrac,
Expr **ArgExprs)
- : Expr(ObjCMessageExprClass, retType), SelName(selInfo), ClassName(0) {
+ : Expr(ObjCMessageExprClass, retType), SelName(selInfo),
+ MethodProto(mproto), ClassName(0) {
unsigned numArgs = selInfo.getNumArgs();
SubExprs = new Expr*[numArgs+1];
SubExprs[RECEIVER] = receiver;
@@ -888,9 +890,11 @@ ObjCMessageExpr::ObjCMessageExpr(Expr *receiver, Selector selInfo,
// constructor for class messages.
// FIXME: clsName should be typed to ObjCInterfaceType
ObjCMessageExpr::ObjCMessageExpr(IdentifierInfo *clsName, Selector selInfo,
- QualType retType, SourceLocation LBrac, SourceLocation RBrac,
+ QualType retType, ObjcMethodDecl *mproto,
+ SourceLocation LBrac, SourceLocation RBrac,
Expr **ArgExprs)
- : Expr(ObjCMessageExprClass, retType), SelName(selInfo), ClassName(clsName) {
+ : Expr(ObjCMessageExprClass, retType), SelName(selInfo),
+ MethodProto(mproto), ClassName(clsName) {
unsigned numArgs = selInfo.getNumArgs();
SubExprs = new Expr*[numArgs+1];
SubExprs[RECEIVER] = 0;
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index 30aa7b3001..bc371c77d0 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -2074,8 +2074,8 @@ Sema::ExprResult Sema::ActOnClassMessage(
return true;
}
}
- return new ObjCMessageExpr(receiverName, Sel, returnType, lbrac, rbrac,
- ArgExprs);
+ return new ObjCMessageExpr(receiverName, Sel, returnType, Method,
+ lbrac, rbrac, ArgExprs);
}
// ActOnInstanceMessage - used for both unary and keyword messages.
@@ -2091,9 +2091,10 @@ Sema::ExprResult Sema::ActOnInstanceMessage(
Expr *RExpr = static_cast<Expr *>(receiver);
QualType receiverType = RExpr->getType();
QualType returnType;
+ ObjcMethodDecl *Method;
if (receiverType == Context.getObjcIdType()) {
- ObjcMethodDecl *Method = InstanceMethodPool[Sel].Method;
+ Method = InstanceMethodPool[Sel].Method;
if (!Method) {
Diag(lbrac, diag::warn_method_not_found, std::string("-"), Sel.getName(),
SourceRange(lbrac, rbrac));
@@ -2119,7 +2120,7 @@ Sema::ExprResult Sema::ActOnInstanceMessage(
// FIXME: consider using InstanceMethodPool, since it will be faster
// than the following method (which can do *many* linear searches). The
// idea is to add class info to InstanceMethodPool...
- ObjcMethodDecl *Method = ClassDecl->lookupInstanceMethod(Sel);
+ Method = ClassDecl->lookupInstanceMethod(Sel);
if (!Method) {
Diag(lbrac, diag::warn_method_not_found, std::string("-"), Sel.getName(),
SourceRange(lbrac, rbrac));
@@ -2131,5 +2132,6 @@ Sema::ExprResult Sema::ActOnInstanceMessage(
return true;
}
}
- return new ObjCMessageExpr(RExpr, Sel, returnType, lbrac, rbrac, ArgExprs);
+ return new ObjCMessageExpr(RExpr, Sel, returnType, Method, lbrac, rbrac,
+ ArgExprs);
}
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index f4d2af485f..3b8a1c0138 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -1181,6 +1181,11 @@ class ObjCMessageExpr : public Expr {
// A unigue name for this message.
Selector SelName;
+ // A method prototype for this message (optional).
+ // FIXME: Since method decls contain the selector, and most messages have a
+ // prototype, consider devising a scheme for unifying SelName/MethodProto.
+ ObjcMethodDecl *MethodProto;
+
IdentifierInfo *ClassName; // optional - 0 for instance messages.
SourceLocation LBracloc, RBracloc;
@@ -1188,11 +1193,13 @@ public:
// constructor for class messages.
// FIXME: clsName should be typed to ObjCInterfaceType
ObjCMessageExpr(IdentifierInfo *clsName, Selector selInfo,
- QualType retType, SourceLocation LBrac, SourceLocation RBrac,
+ QualType retType, ObjcMethodDecl *methDecl,
+ SourceLocation LBrac, SourceLocation RBrac,
Expr **ArgExprs);
// constructor for instance messages.
ObjCMessageExpr(Expr *receiver, Selector selInfo,
- QualType retType, SourceLocation LBrac, SourceLocation RBrac,
+ QualType retType, ObjcMethodDecl *methDecl,
+ SourceLocation LBrac, SourceLocation RBrac,
Expr **ArgExprs);
~ObjCMessageExpr() {
delete [] SubExprs;
@@ -1203,6 +1210,9 @@ public:
const Selector &getSelector() const { return SelName; }
Selector &getSelector() { return SelName; }
+
+ const ObjcMethodDecl *getMethodDecl() const { return MethodProto; }
+ ObjcMethodDecl *getMethodDecl() { return MethodProto; }
const IdentifierInfo *getClassName() const { return ClassName; }
IdentifierInfo *getClassName() { return ClassName; }