From: Steve Naroff Date: Wed, 3 Oct 2007 21:00:46 +0000 (+0000) Subject: Finish renaming ObjC declaration actions. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3a165b066e665870c163af64844073a664c042d0;p=clang Finish renaming ObjC declaration actions. Add comments. Switch to new indentation style for the Action class. Since many actions take many arguments, the new style will... - make it easier to add/remove arguments without messing up the indentation... - make it easier to add comments to each argument (see ActOnMethodDeclaration for an example)... - in general, just makes it easier to see what is being passed. The rest of Actions will be converted "lazily"...there is no immediate need to hack all the existing methods. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42587 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Parse/MinimalAction.cpp b/Parse/MinimalAction.cpp index dc0a9cc4e9..5e2fac2979 100644 --- a/Parse/MinimalAction.cpp +++ b/Parse/MinimalAction.cpp @@ -68,7 +68,7 @@ MinimalAction::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup) { } Action::DeclTy * -MinimalAction::ObjcStartClassInterface(Scope* S, SourceLocation AtInterafceLoc, +MinimalAction::ActOnStartClassInterface(Scope* S, SourceLocation AtInterafceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *SuperName, SourceLocation SuperLoc, IdentifierInfo **ProtocolNames, unsigned NumProtocols, @@ -81,7 +81,7 @@ MinimalAction::ObjcStartClassInterface(Scope* S, SourceLocation AtInterafceLoc, } Action::DeclTy * -MinimalAction::ObjcStartProtoInterface(Scope* S, +MinimalAction::ActOnStartProtocolInterface(Scope* S, SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs) { diff --git a/Parse/ParseObjc.cpp b/Parse/ParseObjc.cpp index eaf198fc92..c55768704d 100644 --- a/Parse/ParseObjc.cpp +++ b/Parse/ParseObjc.cpp @@ -154,11 +154,9 @@ Parser::DeclTy *Parser::ParseObjCAtInterfaceDeclaration( if (attrList) // categories don't support attributes. Diag(Tok, diag::err_objc_no_attributes_on_category); - DeclTy *CategoryType = Actions.ObjcStartCatInterface(CurScope, atLoc, - nameId, nameLoc, - categoryId, categoryLoc, - &ProtocolRefs[0], - ProtocolRefs.size()); + DeclTy *CategoryType = Actions.ActOnStartCategoryInterface(CurScope, atLoc, + nameId, nameLoc, categoryId, categoryLoc, + &ProtocolRefs[0], ProtocolRefs.size()); ParseObjCInterfaceDeclList(CategoryType, tok::objc_not_keyword); @@ -189,7 +187,7 @@ Parser::DeclTy *Parser::ParseObjCAtInterfaceDeclaration( if (ParseObjCProtocolReferences(ProtocolRefs)) return 0; } - DeclTy *ClsType = Actions.ObjcStartClassInterface(CurScope, + DeclTy *ClsType = Actions.ActOnStartClassInterface(CurScope, atLoc, nameId, nameLoc, superClassId, superClassLoc, &ProtocolRefs[0], ProtocolRefs.size(), attrList); @@ -268,8 +266,8 @@ void Parser::ParseObjCInterfaceDeclList(DeclTy *interfaceDecl, } } /// Insert collected methods declarations into the @interface object. - Actions.ObjcAddMethodsToClass(CurScope, - interfaceDecl,&allMethods[0],allMethods.size()); + Actions.ActOnAddMethodsToObjcDecl(CurScope, interfaceDecl, + &allMethods[0], allMethods.size()); } /// Parse property attribute declarations. @@ -875,7 +873,7 @@ Parser::DeclTy *Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc) { return 0; } - DeclTy *ProtoType = Actions.ObjcStartProtoInterface(CurScope, AtLoc, + DeclTy *ProtoType = Actions.ActOnStartProtocolInterface(CurScope, AtLoc, protocolName, nameLoc, &ProtocolRefs[0], ProtocolRefs.size()); @@ -934,7 +932,7 @@ Parser::DeclTy *Parser::ParseObjCAtImplementationDeclaration( return 0; } rparenLoc = ConsumeParen(); - DeclTy *ImplCatType = Actions.ObjcStartCategoryImplementation(CurScope, + DeclTy *ImplCatType = Actions.ActOnStartCategoryImplementation(CurScope, atLoc, nameId, nameLoc, categoryId, categoryLoc); return ImplCatType; @@ -952,9 +950,8 @@ Parser::DeclTy *Parser::ParseObjCAtImplementationDeclaration( superClassId = Tok.getIdentifierInfo(); superClassLoc = ConsumeToken(); // Consume super class name } - DeclTy *ImplClsType = Actions.ObjcStartClassImplementation(CurScope, - atLoc, - nameId, nameLoc, + DeclTy *ImplClsType = Actions.ActOnStartClassImplementation(CurScope, + atLoc, nameId, nameLoc, superClassId, superClassLoc); if (Tok.getKind() == tok::l_brace) @@ -971,8 +968,8 @@ Parser::DeclTy *Parser::ParseObjCAtEndDeclaration(SourceLocation atLoc) { // @implementation not to have been parsed to completion and ObjcImpDecl // could be 0. /// Insert collected methods declarations into the @interface object. - Actions.ObjcAddMethodsToClass(CurScope, ObjcImpDecl, - &AllImplMethods[0],AllImplMethods.size()); + Actions.ActOnAddMethodsToObjcDecl(CurScope, ObjcImpDecl, + &AllImplMethods[0],AllImplMethods.size()); ObjcImpDecl = 0; AllImplMethods.clear(); } diff --git a/Sema/Sema.h b/Sema/Sema.h index 6e87331b96..04da4019d3 100644 --- a/Sema/Sema.h +++ b/Sema/Sema.h @@ -384,31 +384,31 @@ public: SourceLocation RParenLoc); // Objective-C declarations. - virtual DeclTy *ObjcStartClassInterface(Scope* S, + virtual DeclTy *ActOnStartClassInterface(Scope* S, SourceLocation AtInterafceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *SuperName, SourceLocation SuperLoc, IdentifierInfo **ProtocolNames, unsigned NumProtocols, AttributeList *AttrList); - virtual DeclTy *ObjcStartProtoInterface(Scope* S, + virtual DeclTy *ActOnStartProtocolInterface(Scope* S, SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs); - virtual DeclTy *ObjcStartCatInterface(Scope* S, + virtual DeclTy *ActOnStartCategoryInterface(Scope* S, SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *CategoryName, SourceLocation CategoryLoc, IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs); - virtual DeclTy *ObjcStartClassImplementation(Scope* S, + virtual DeclTy *ActOnStartClassImplementation(Scope* S, SourceLocation AtClassImplLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *SuperClassname, SourceLocation SuperClassLoc); - virtual DeclTy *ObjcStartCategoryImplementation(Scope* S, + virtual DeclTy *ActOnStartCategoryImplementation(Scope* S, SourceLocation AtCatImplLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, @@ -424,8 +424,8 @@ public: IdentifierInfo **IdentList, unsigned NumElts); - virtual void ObjcAddMethodsToClass(Scope* S, DeclTy *ClassDecl, - DeclTy **allMethods, unsigned allNum); + virtual void ActOnAddMethodsToObjcDecl(Scope* S, DeclTy *ClassDecl, + DeclTy **allMethods, unsigned allNum); virtual DeclTy *ActOnMethodDeclaration(SourceLocation MethodLoc, tok::TokenKind MethodType, TypeTy *ReturnType, Selector Sel, diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp index 3aaa112e02..c44ca81bde 100644 --- a/Sema/SemaDecl.cpp +++ b/Sema/SemaDecl.cpp @@ -894,7 +894,7 @@ TypedefDecl *Sema::ParseTypedefDecl(Scope *S, Declarator &D, return NewTD; } -Sema::DeclTy *Sema::ObjcStartClassInterface(Scope* S, +Sema::DeclTy *Sema::ActOnStartClassInterface(Scope* S, SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *SuperName, SourceLocation SuperLoc, @@ -967,7 +967,7 @@ Sema::DeclTy *Sema::ObjcStartClassInterface(Scope* S, return IDecl; } -Sema::DeclTy *Sema::ObjcStartProtoInterface(Scope* S, +Sema::DeclTy *Sema::ActOnStartProtocolInterface(Scope* S, SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs) { @@ -1031,7 +1031,7 @@ Sema::ActOnForwardProtocolDeclaration(Scope *S, SourceLocation AtProtocolLoc, return FDecl; } -Sema::DeclTy *Sema::ObjcStartCatInterface(Scope* S, +Sema::DeclTy *Sema::ActOnStartCategoryInterface(Scope* S, SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *CategoryName, SourceLocation CategoryLoc, @@ -1075,10 +1075,10 @@ Sema::DeclTy *Sema::ObjcStartCatInterface(Scope* S, return CDecl; } -/// ObjcStartCategoryImplementation - Perform semantic checks on the +/// ActOnStartCategoryImplementation - Perform semantic checks on the /// category implementation declaration and build an ObjcCategoryImplDecl /// object. -Sema::DeclTy *Sema::ObjcStartCategoryImplementation(Scope* S, +Sema::DeclTy *Sema::ActOnStartCategoryImplementation(Scope* S, SourceLocation AtCatImplLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *CatName, SourceLocation CatLoc) { @@ -1094,7 +1094,7 @@ Sema::DeclTy *Sema::ObjcStartCategoryImplementation(Scope* S, return CDecl; } -Sema::DeclTy *Sema::ObjcStartClassImplementation(Scope *S, +Sema::DeclTy *Sema::ActOnStartClassImplementation(Scope *S, SourceLocation AtClassImplLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *SuperClassname, @@ -1683,8 +1683,8 @@ void Sema::ActOnFields(Scope* S, } } -void Sema::ObjcAddMethodsToClass(Scope* S, DeclTy *ClassDecl, - DeclTy **allMethods, unsigned allNum) { +void Sema::ActOnAddMethodsToObjcDecl(Scope* S, DeclTy *ClassDecl, + DeclTy **allMethods, unsigned allNum) { // FIXME: Fix this when we can handle methods declared in protocols. // See Parser::ParseObjCAtProtocolDeclaration if (!ClassDecl) @@ -1747,7 +1747,7 @@ void Sema::ObjcAddMethodsToClass(Scope* S, DeclTy *ClassDecl, } } else - assert(0 && "Sema::ObjcAddMethodsToClass(): Unknown DeclTy"); + assert(0 && "Sema::ActOnAddMethodsToObjcDecl(): Unknown DeclTy"); return; } diff --git a/clang.xcodeproj/project.pbxproj b/clang.xcodeproj/project.pbxproj index 6389e5fbc4..314ed3ea3c 100644 --- a/clang.xcodeproj/project.pbxproj +++ b/clang.xcodeproj/project.pbxproj @@ -737,7 +737,6 @@ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */; - compatibilityVersion = "Xcode 2.4"; hasScannedForEncodings = 1; mainGroup = 08FB7794FE84155DC02AAC07 /* clang */; projectDirPath = ""; diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h index f353dff24e..515935c4f0 100644 --- a/include/clang/Parse/Action.h +++ b/include/clang/Parse/Action.h @@ -437,59 +437,99 @@ public: } //===----------------------- Obj-C Declarations -------------------------===// - virtual DeclTy *ObjcStartClassInterface(Scope* S, SourceLocation AtInterafceLoc, - IdentifierInfo *ClassName, SourceLocation ClassLoc, - IdentifierInfo *SuperName, SourceLocation SuperLoc, - IdentifierInfo **ProtocolNames, unsigned NumProtocols, - AttributeList *AttrList) { - return 0; - } - virtual void ObjcAddMethodsToClass(Scope* S, DeclTy *ClassDecl, - DeclTy **allMethods, unsigned allNum) { - return; - } - virtual DeclTy *ObjcStartProtoInterface(Scope* S, - SourceLocation AtProtoInterfaceLoc, - IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, - IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs) { - return 0; - } - virtual DeclTy *ObjcStartCatInterface(Scope* S, - SourceLocation AtInterfaceLoc, - IdentifierInfo *ClassName, SourceLocation ClassLoc, - IdentifierInfo *CategoryName, SourceLocation CategoryLoc, - IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs) { - return 0; - } - virtual DeclTy *ObjcStartClassImplementation(Scope* S, - SourceLocation AtClassImplLoc, - IdentifierInfo *ClassName, SourceLocation ClassLoc, - IdentifierInfo *SuperClassname, - SourceLocation SuperClassLoc) { - return 0; - } - virtual DeclTy *ObjcStartCategoryImplementation(Scope* S, - SourceLocation AtCatImplLoc, - IdentifierInfo *ClassName, - SourceLocation ClassLoc, - IdentifierInfo *CatName, - SourceLocation CatLoc) { + // ActOnStartClassInterface - this action is called immdiately after parsing + // the prologue for a class interface (before parsing the instance + // variables). Instance variables are processed by ActOnFields(). + virtual DeclTy *ActOnStartClassInterface( + Scope* S, + SourceLocation AtInterafceLoc, + IdentifierInfo *ClassName, + SourceLocation ClassLoc, + IdentifierInfo *SuperName, + SourceLocation SuperLoc, + IdentifierInfo **ProtocolNames, + unsigned NumProtocols, + AttributeList *AttrList) { + return 0; + } + // ActOnStartProtocolInterface - this action is called immdiately after + // parsing the prologue for a protocol interface. + virtual DeclTy *ActOnStartProtocolInterface( + Scope* S, + SourceLocation AtProtoInterfaceLoc, + IdentifierInfo *ProtocolName, + SourceLocation ProtocolLoc, + IdentifierInfo **ProtoRefNames, + unsigned NumProtoRefs) { + return 0; + } + // ActOnStartCategoryInterface - this action is called immdiately after + // parsing the prologue for a category interface. + virtual DeclTy *ActOnStartCategoryInterface( + Scope* S, + SourceLocation AtInterfaceLoc, + IdentifierInfo *ClassName, + SourceLocation ClassLoc, + IdentifierInfo *CategoryName, + SourceLocation CategoryLoc, + IdentifierInfo **ProtoRefNames, + unsigned NumProtoRefs) { + return 0; + } + // ActOnStartClassImplementation - this action is called immdiately after + // parsing the prologue for a class implementation. Instance variables are + // processed by ActOnFields(). + virtual DeclTy *ActOnStartClassImplementation( + Scope* S, + SourceLocation AtClassImplLoc, + IdentifierInfo *ClassName, + SourceLocation ClassLoc, + IdentifierInfo *SuperClassname, + SourceLocation SuperClassLoc) { + return 0; + } + // ActOnStartCategoryImplementation - this action is called immdiately after + // parsing the prologue for a category implementation. + virtual DeclTy *ActOnStartCategoryImplementation( + Scope* S, + SourceLocation AtCatImplLoc, + IdentifierInfo *ClassName, + SourceLocation ClassLoc, + IdentifierInfo *CatName, + SourceLocation CatLoc) { return 0; } - virtual DeclTy *ActOnMethodDeclaration(SourceLocation MethodLoc, - tok::TokenKind MethodType, TypeTy *ReturnType, Selector Sel, - // optional arguments. The number of types/arguments is obtained - // from the Sel.getNumArgs(). - TypeTy **ArgTypes, IdentifierInfo **ArgNames, - AttributeList *AttrList, tok::ObjCKeywordKind MethodImplKind) { - return 0; + // ActOnMethodDeclaration - called for all method declarations. + virtual DeclTy *ActOnMethodDeclaration( + SourceLocation MethodLoc, + tok::TokenKind MethodType, // tok::minus for instance, tok::plus for class. + TypeTy *ReturnType, // the method return type. + Selector Sel, // a unique name for the method. + TypeTy **ArgTypes, // non-zero when Sel.getNumArgs() > 0 + IdentifierInfo **ArgNames, // non-zero when Sel.getNumArgs() > 0 + AttributeList *AttrList, // optional + // tok::objc_not_keyword, tok::objc_optional, tok::objc_required + tok::ObjCKeywordKind impKind) { + return 0; + } + // ActOnAddMethodsToObjcDecl - called to associate methods with an interface, + // protocol, category, or implementation. + virtual void ActOnAddMethodsToObjcDecl( + Scope* S, + DeclTy *ClassDecl, + DeclTy **allMethods, + unsigned allNum) { + return; } // ActOnClassMessage - used for both unary and keyword messages. // ArgExprs is optional - if it is present, the number of expressions // is obtained from Sel.getNumArgs(). virtual ExprResult ActOnClassMessage( - IdentifierInfo *receivingClassName, Selector Sel, - SourceLocation lbrac, SourceLocation rbrac, ExprTy **ArgExprs) { + IdentifierInfo *receivingClassName, + Selector Sel, + SourceLocation lbrac, + SourceLocation rbrac, + ExprTy **ArgExprs) { return 0; } // ActOnInstanceMessage - used for both unary and keyword messages. @@ -500,17 +540,18 @@ public: SourceLocation lbrac, SourceLocation rbrac, ExprTy **ArgExprs) { return 0; } - virtual DeclTy *ActOnForwardClassDeclaration(Scope *S, - SourceLocation AtClassLoc, - IdentifierInfo **IdentList, - unsigned NumElts) { + virtual DeclTy *ActOnForwardClassDeclaration( + Scope *S, + SourceLocation AtClassLoc, + IdentifierInfo **IdentList, + unsigned NumElts) { return 0; } - - virtual DeclTy *ActOnForwardProtocolDeclaration(Scope *S, - SourceLocation AtProtocolLoc, - IdentifierInfo **IdentList, - unsigned NumElts) { + virtual DeclTy *ActOnForwardProtocolDeclaration( + Scope *S, + SourceLocation AtProtocolLoc, + IdentifierInfo **IdentList, + unsigned NumElts) { return 0; } @@ -559,12 +600,12 @@ public: IdentifierInfo **IdentList, unsigned NumElts); - virtual DeclTy *ObjcStartClassInterface(Scope* S, SourceLocation AtInterafceLoc, + virtual DeclTy *ActOnStartClassInterface(Scope* S, SourceLocation AtInterafceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *SuperName, SourceLocation SuperLoc, IdentifierInfo **ProtocolNames, unsigned NumProtocols, AttributeList *AttrList); - virtual DeclTy *ObjcStartProtoInterface(Scope *S, + virtual DeclTy *ActOnStartProtocolInterface(Scope *S, SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs);