[cfe-commits] r43666 - in /cfe/trunk: AST/Expr.cpp Sema/SemaExpr.cpp include/clang/AST/Expr.h

Steve Naroff snaroff at apple.com
Sat Nov 3 09:38:00 PDT 2007


Author: snaroff
Date: Sat Nov  3 11:37:59 2007
New Revision: 43666

URL: http://llvm.org/viewvc/llvm-project?rev=43666&view=rev
Log:

Add a method prototype slot/getter to the ObjCMessageExpr AST.


Modified:
    cfe/trunk/AST/Expr.cpp
    cfe/trunk/Sema/SemaExpr.cpp
    cfe/trunk/include/clang/AST/Expr.h

Modified: cfe/trunk/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Expr.cpp?rev=43666&r1=43665&r2=43666&view=diff

==============================================================================
--- cfe/trunk/AST/Expr.cpp (original)
+++ cfe/trunk/AST/Expr.cpp Sat Nov  3 11:37:59 2007
@@ -871,9 +871,11 @@
 
 // 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 @@
 // 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;

Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=43666&r1=43665&r2=43666&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Sat Nov  3 11:37:59 2007
@@ -2074,8 +2074,8 @@
         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 @@
   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 @@
     // 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 @@
           return true;
     }
   }
-  return new ObjCMessageExpr(RExpr, Sel, returnType, lbrac, rbrac, ArgExprs);
+  return new ObjCMessageExpr(RExpr, Sel, returnType, Method, lbrac, rbrac, 
+                             ArgExprs);
 }

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=43666&r1=43665&r2=43666&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sat Nov  3 11:37:59 2007
@@ -1181,6 +1181,11 @@
   // 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 @@
   // 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 @@
   
   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; }





More information about the cfe-commits mailing list