]> granicus.if.org Git - clang/commitdiff
Insert invisble arguments to method definition header.
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 9 Nov 2007 17:18:29 +0000 (17:18 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 9 Nov 2007 17:18:29 +0000 (17:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43948 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaDecl.cpp
Sema/SemaType.cpp
test/Sema/method-encoding-2.m

index 4f7ffc335c3d7cddb3b05824561b80f2ce5f995e..0098f8b9cb37ae8c0fbc94dfcf5e02002589f730 100644 (file)
@@ -1045,9 +1045,26 @@ Sema::DeclTy *Sema::ObjcActOnStartOfFunctionDef(Scope *FnBodyScope, DeclTy *D) {
   
   // Create Decl objects for each parameter, adding them to the FunctionDecl.
   llvm::SmallVector<ParmVarDecl*, 16> Params;
+  ParmVarDecl *PDecl;
+  // Insert the invisible arguments!
+  if (MDecl->isInstance())
+    // FIXME: type is wrong.
+    PDecl = new ParmVarDecl(SourceLocation(/*FIXME*/), 
+                            &Context.Idents.get("self"),
+                            Context.getObjcIdType(), VarDecl::None, 0);
+  else
+    PDecl = new ParmVarDecl(SourceLocation(/*FIXME*/), 
+                            &Context.Idents.get("self"),
+                            Context.getObjcIdType(), VarDecl::None, 0);
+  Params.push_back(ObjcParseParamDeclarator(PDecl, FnBodyScope));
+  PDecl = new ParmVarDecl(SourceLocation(/*FIXME*/), 
+                          &Context.Idents.get("_cmd"),
+                          Context.getObjcSelType(), VarDecl::None, 0);
+  Params.push_back(ObjcParseParamDeclarator(PDecl, FnBodyScope));
   
+    
   for (int i = 0; i <  MDecl->getNumParams(); i++) {
-    ParmVarDecl *PDecl = MDecl->getParamDecl(i);
+    PDecl = MDecl->getParamDecl(i);
     Params.push_back(ObjcParseParamDeclarator(PDecl, FnBodyScope));
   }
 
index 8c18a2f27b50fc998fcb597ba72fc70cbc5be763..6398c6f71ea4ca621851fe59f23142ed6bdbbce3 100644 (file)
@@ -325,13 +325,21 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S) {
   return T;
 }
 
-/// GetTypeForDeclarator - Convert the type for the specified declarator to Type
+/// ObjcGetTypeForDeclarator - Convert the type for the specified declarator to Type
 /// instances.
 QualType Sema::ObjcGetTypeForDeclarator(DeclTy *D, Scope *S) {
   ObjcMethodDecl *MDecl = dyn_cast<ObjcMethodDecl>(static_cast<Decl *>(D));
   QualType T = MDecl->getResultType();
   llvm::SmallVector<QualType, 16> ArgTys;
   
+  // Add the first two invisible argument types for self and _cmd.
+  if (MDecl->isInstance())
+    // FIXME: interface-name *
+    ArgTys.push_back(Context.getObjcIdType());
+  else
+    ArgTys.push_back(Context.getObjcIdType());
+  ArgTys.push_back(Context.getObjcSelType());
+      
   for (int i = 0; i <  MDecl->getNumParams(); i++) {
     ParmVarDecl *PDecl = MDecl->getParamDecl(i);
     QualType ArgTy = PDecl->getType();
index b7a5e733dae4a8b10f55c8e6d4eff332a25ba1d8..08a579b0a8786321215f2b0642c78f0c0f197a84 100644 (file)
@@ -1,4 +1,5 @@
-// RUN: clang -rewrite-test %s
+// RUN: clang %s
+// TODO: We don't support rewrite of method definitions
 
 @interface Intf 
 - (in out bycopy id) address:(byref inout void *)location with:(out oneway unsigned **)arg2;