[cfe-commits] r43948 - in /cfe/trunk: Sema/SemaDecl.cpp Sema/SemaType.cpp test/Sema/method-encoding-2.m
Chris Lattner
clattner at apple.com
Tue Dec 11 23:15:08 PST 2007
On Nov 9, 2007, at 9:18 AM, Fariborz Jahanian wrote:
> Author: fjahanian
> Date: Fri Nov 9 11:18:29 2007
> New Revision: 43948
>
> Insert invisble arguments to method definition header.
Hi Fariborz,
The code for handling self etc evolved into:
void Sema::ObjcActOnStartOfMethodDef(Scope *FnBodyScope, DeclTy *D) {
...
// Create Decl objects for each parameter, entrring them in the
scope for
// binding to their use.
struct DeclaratorChunk::ParamInfo PI;
// Insert the invisible arguments, self and _cmd!
PI.Ident = &Context.Idents.get("self");
PI.IdentLoc = SourceLocation(); // synthesized vars have a null
location.
PI.InvalidType = false;
if (MDecl->isInstance()) {
QualType selfTy = Context.getObjcInterfaceType(MDecl-
>getClassInterface());
selfTy = Context.getPointerType(selfTy);
PI.TypeInfo = selfTy.getAsOpaquePtr();
} else
PI.TypeInfo = Context.getObjcIdType().getAsOpaquePtr();
CurMethodDecl->setSelfDecl(ActOnParamDeclarator(PI, FnBodyScope));
similarly for _cmd.
Questions:
1. Why are these turning into ParamVarDecls? These are not parameters
in the source language, they are magic variables.
2. Why are you setting up a declarator chunk and passing stuff through
ActOnParamDeclarator? This code is in Sema already, so it seems like
this layer of indirection is not needed.
-Chris
More information about the cfe-commits
mailing list