]> granicus.if.org Git - clang/commitdiff
Finish renaming ObjC declaration actions.
authorSteve Naroff <snaroff@apple.com>
Wed, 3 Oct 2007 21:00:46 +0000 (21:00 +0000)
committerSteve Naroff <snaroff@apple.com>
Wed, 3 Oct 2007 21:00:46 +0000 (21:00 +0000)
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

Parse/MinimalAction.cpp
Parse/ParseObjc.cpp
Sema/Sema.h
Sema/SemaDecl.cpp
clang.xcodeproj/project.pbxproj
include/clang/Parse/Action.h

index dc0a9cc4e9e77ed580821b2cbb37e48d47d47601..5e2fac2979efd6e57302e4755bfbd02428dc9b2b 100644 (file)
@@ -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) {
index eaf198fc92960c405c09fb12750898d0da36e320..c55768704dfa1eee5138cabb8a75206c8feab8df 100644 (file)
@@ -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();
   }
index 6e87331b966e43a4d8a7c2ea2a814e87b431ebf2..04da4019d34e256c4295103832340468e61a95ce 100644 (file)
@@ -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,
index 3aaa112e02ed7410684e579931c14bf95aed921e..c44ca81bdee17b468c31dba359de964fa43592b9 100644 (file)
@@ -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;
 }
 
index 6389e5fbc4b52a5bf259edca2edaf14c4c7a7ad6..314ed3ea3cf698d8d382b2bd0ea6ae5b1523a2b3 100644 (file)
                08FB7793FE84155DC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
-                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
                        projectDirPath = "";
index f353dff24e436dcb9eb7e7fd7ae806657a357cd4..515935c4f090ce9f0ed8f92ddb31fb0540d5c949 100644 (file)
@@ -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);