Uses more description name for method implementation kind argument.

Moves such argument as the last argument and uses defaul value.

llvm-svn: 42073
This commit is contained in:
Fariborz Jahanian 2007-09-18 00:25:23 +00:00
parent a9deb50918
commit 0c74e9d161
5 changed files with 41 additions and 42 deletions

View File

@ -216,7 +216,7 @@ Parser::DeclTy *Parser::ParseObjCAtInterfaceDeclaration(
void Parser::ParseObjCInterfaceDeclList(DeclTy *interfaceDecl, void Parser::ParseObjCInterfaceDeclList(DeclTy *interfaceDecl,
tok::ObjCKeywordKind contextKey) { tok::ObjCKeywordKind contextKey) {
llvm::SmallVector<DeclTy*, 32> allMethods; llvm::SmallVector<DeclTy*, 32> allMethods;
tok::ObjCKeywordKind pi = tok::objc_not_keyword; tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword;
while (1) { while (1) {
if (Tok.getKind() == tok::at) { if (Tok.getKind() == tok::at) {
SourceLocation AtLoc = ConsumeToken(); // the "@" SourceLocation AtLoc = ConsumeToken(); // the "@"
@ -226,12 +226,12 @@ void Parser::ParseObjCInterfaceDeclList(DeclTy *interfaceDecl,
break; break;
} else if (ocKind == tok::objc_required) { // protocols only } else if (ocKind == tok::objc_required) { // protocols only
ConsumeToken(); ConsumeToken();
pi = ocKind; MethodImplKind = ocKind;
if (contextKey != tok::objc_protocol) if (contextKey != tok::objc_protocol)
Diag(AtLoc, diag::err_objc_protocol_required); Diag(AtLoc, diag::err_objc_protocol_required);
} else if (ocKind == tok::objc_optional) { // protocols only } else if (ocKind == tok::objc_optional) { // protocols only
ConsumeToken(); ConsumeToken();
pi = ocKind; MethodImplKind = ocKind;
if (contextKey != tok::objc_protocol) if (contextKey != tok::objc_protocol)
Diag(AtLoc, diag::err_objc_protocol_optional); Diag(AtLoc, diag::err_objc_protocol_optional);
} else if (ocKind == tok::objc_property) { } else if (ocKind == tok::objc_property) {
@ -243,7 +243,7 @@ void Parser::ParseObjCInterfaceDeclList(DeclTy *interfaceDecl,
} }
} }
if (Tok.getKind() == tok::minus || Tok.getKind() == tok::plus) { if (Tok.getKind() == tok::minus || Tok.getKind() == tok::plus) {
DeclTy *methodPrototype = ParseObjCMethodPrototype(interfaceDecl, pi); DeclTy *methodPrototype = ParseObjCMethodPrototype(interfaceDecl, MethodImplKind);
allMethods.push_back(methodPrototype); allMethods.push_back(methodPrototype);
// Consume the ';' here, since ParseObjCMethodPrototype() is re-used for // Consume the ';' here, since ParseObjCMethodPrototype() is re-used for
// method definitions. // method definitions.
@ -368,14 +368,14 @@ void Parser::ParseObjCPropertyDecl(DeclTy *interfaceDecl) {
/// __attribute__((deprecated)) /// __attribute__((deprecated))
/// ///
Parser::DeclTy *Parser::ParseObjCMethodPrototype(DeclTy *IDecl, Parser::DeclTy *Parser::ParseObjCMethodPrototype(DeclTy *IDecl,
tok::ObjCKeywordKind& pi) { tok::ObjCKeywordKind MethodImplKind) {
assert((Tok.getKind() == tok::minus || Tok.getKind() == tok::plus) && assert((Tok.getKind() == tok::minus || Tok.getKind() == tok::plus) &&
"expected +/-"); "expected +/-");
tok::TokenKind methodType = Tok.getKind(); tok::TokenKind methodType = Tok.getKind();
SourceLocation methodLoc = ConsumeToken(); SourceLocation methodLoc = ConsumeToken();
DeclTy *MDecl = ParseObjCMethodDecl(pi, methodType, methodLoc); DeclTy *MDecl = ParseObjCMethodDecl(methodType, methodLoc, MethodImplKind);
// Since this rule is used for both method declarations and definitions, // Since this rule is used for both method declarations and definitions,
// the caller is (optionally) responsible for consuming the ';'. // the caller is (optionally) responsible for consuming the ';'.
return MDecl; return MDecl;
@ -484,8 +484,8 @@ Parser::TypeTy *Parser::ParseObjCTypeName() {
/// objc-keyword-attributes: [OBJC2] /// objc-keyword-attributes: [OBJC2]
/// __attribute__((unused)) /// __attribute__((unused))
/// ///
Parser::DeclTy *Parser::ParseObjCMethodDecl(tok::ObjCKeywordKind& pi, Parser::DeclTy *Parser::ParseObjCMethodDecl(tok::TokenKind mType, SourceLocation mLoc,
tok::TokenKind mType, SourceLocation mLoc) { tok::ObjCKeywordKind MethodImplKind) {
TypeTy *ReturnType = 0; TypeTy *ReturnType = 0;
AttributeList *methodAttrs = 0; AttributeList *methodAttrs = 0;
@ -551,10 +551,10 @@ Parser::DeclTy *Parser::ParseObjCMethodDecl(tok::ObjCKeywordKind& pi,
// If attributes exist after the method, parse them. // If attributes exist after the method, parse them.
if (getLang().ObjC2 && Tok.getKind() == tok::kw___attribute) if (getLang().ObjC2 && Tok.getKind() == tok::kw___attribute)
methodAttrs = ParseAttributes(); methodAttrs = ParseAttributes();
return Actions.ObjcBuildMethodDeclaration(pi, mLoc, mType, return Actions.ObjcBuildMethodDeclaration(mLoc, mType,
ReturnType, ReturnType,
&KeyInfo[0], KeyInfo.size(), &KeyInfo[0], KeyInfo.size(),
methodAttrs); methodAttrs, MethodImplKind);
} else if (!selIdent) { } else if (!selIdent) {
Diag(Tok, diag::err_expected_ident); // missing selector name. Diag(Tok, diag::err_expected_ident); // missing selector name.
} }
@ -562,9 +562,9 @@ Parser::DeclTy *Parser::ParseObjCMethodDecl(tok::ObjCKeywordKind& pi,
if (getLang().ObjC2 && Tok.getKind() == tok::kw___attribute) if (getLang().ObjC2 && Tok.getKind() == tok::kw___attribute)
methodAttrs = ParseAttributes(); methodAttrs = ParseAttributes();
return Actions.ObjcBuildMethodDeclaration(pi, return Actions.ObjcBuildMethodDeclaration(mLoc, mType, ReturnType,
mLoc, mType, ReturnType, selIdent, methodAttrs,
selIdent, methodAttrs); MethodImplKind);
} }
/// objc-protocol-refs: /// objc-protocol-refs:
@ -917,8 +917,7 @@ void Parser::ParseObjCInstanceMethodDefinition() {
assert(Tok.getKind() == tok::minus && assert(Tok.getKind() == tok::minus &&
"ParseObjCInstanceMethodDefinition(): Expected '-'"); "ParseObjCInstanceMethodDefinition(): Expected '-'");
// FIXME: @optional/@protocol?? // FIXME: @optional/@protocol??
tok::ObjCKeywordKind pi = tok::objc_not_keyword; ParseObjCMethodPrototype(ObjcImpDecl);
ParseObjCMethodPrototype(ObjcImpDecl, pi);
// parse optional ';' // parse optional ';'
if (Tok.getKind() == tok::semi) if (Tok.getKind() == tok::semi)
ConsumeToken(); ConsumeToken();
@ -937,8 +936,7 @@ void Parser::ParseObjCClassMethodDefinition() {
assert(Tok.getKind() == tok::plus && assert(Tok.getKind() == tok::plus &&
"ParseObjCClassMethodDefinition(): Expected '+'"); "ParseObjCClassMethodDefinition(): Expected '+'");
// FIXME: @optional/@protocol?? // FIXME: @optional/@protocol??
tok::ObjCKeywordKind pi = tok::objc_not_keyword; ParseObjCMethodPrototype(ObjcImpDecl);
ParseObjCMethodPrototype(ObjcImpDecl, pi);
// parse optional ';' // parse optional ';'
if (Tok.getKind() == tok::semi) if (Tok.getKind() == tok::semi)
ConsumeToken(); ConsumeToken();

View File

@ -368,15 +368,15 @@ public:
virtual void ObjcAddMethodsToClass(DeclTy *ClassDecl, virtual void ObjcAddMethodsToClass(DeclTy *ClassDecl,
DeclTy **allMethods, unsigned allNum); DeclTy **allMethods, unsigned allNum);
virtual DeclTy *ObjcBuildMethodDeclaration(tok::ObjCKeywordKind& pi, virtual DeclTy *ObjcBuildMethodDeclaration(SourceLocation MethodLoc,
SourceLocation MethodLoc,
tok::TokenKind MethodType, TypeTy *ReturnType, tok::TokenKind MethodType, TypeTy *ReturnType,
ObjcKeywordDecl *Keywords, unsigned NumKeywords, ObjcKeywordDecl *Keywords, unsigned NumKeywords,
AttributeList *AttrList); AttributeList *AttrList,
virtual DeclTy *ObjcBuildMethodDeclaration(tok::ObjCKeywordKind& pi, tok::ObjCKeywordKind MethodImplKind);
SourceLocation MethodLoc, virtual DeclTy *ObjcBuildMethodDeclaration(SourceLocation MethodLoc,
tok::TokenKind MethodType, TypeTy *ReturnType, tok::TokenKind MethodType, TypeTy *ReturnType,
IdentifierInfo *SelectorName, AttributeList *AttrList); IdentifierInfo *SelectorName, AttributeList *AttrList,
tok::ObjCKeywordKind MethodImplKind);
// This actions handles keyword message to classes. // This actions handles keyword message to classes.
virtual ExprResult ActOnKeywordMessage(IdentifierInfo *receivingClassName, virtual ExprResult ActOnKeywordMessage(IdentifierInfo *receivingClassName,

View File

@ -1264,11 +1264,11 @@ void Sema::ObjcAddMethodsToClass(DeclTy *ClassDecl,
return; return;
} }
Sema::DeclTy *Sema::ObjcBuildMethodDeclaration(tok::ObjCKeywordKind& pi, Sema::DeclTy *Sema::ObjcBuildMethodDeclaration(SourceLocation MethodLoc,
SourceLocation MethodLoc,
tok::TokenKind MethodType, TypeTy *ReturnType, tok::TokenKind MethodType, TypeTy *ReturnType,
ObjcKeywordDecl *Keywords, unsigned NumKeywords, ObjcKeywordDecl *Keywords, unsigned NumKeywords,
AttributeList *AttrList) { AttributeList *AttrList,
tok::ObjCKeywordKind MethodDeclKind) {
assert(NumKeywords && "Selector must be specified"); assert(NumKeywords && "Selector must be specified");
// Derive the selector name from the keyword declarations. // Derive the selector name from the keyword declarations.
@ -1306,17 +1306,17 @@ Sema::DeclTy *Sema::ObjcBuildMethodDeclaration(tok::ObjCKeywordKind& pi,
SelName, resultDeclType, SelName, resultDeclType,
0, -1, AttrList, MethodType == tok::minus); 0, -1, AttrList, MethodType == tok::minus);
ObjcMethod->setMethodParams(&Params[0], NumKeywords); ObjcMethod->setMethodParams(&Params[0], NumKeywords);
if (pi == tok::objc_optional) if (MethodDeclKind == tok::objc_optional)
ObjcMethod->setDeclImplementation(ObjcMethodDecl::Optional); ObjcMethod->setDeclImplementation(ObjcMethodDecl::Optional);
else else
ObjcMethod->setDeclImplementation(ObjcMethodDecl::Required); ObjcMethod->setDeclImplementation(ObjcMethodDecl::Required);
return ObjcMethod; return ObjcMethod;
} }
Sema::DeclTy *Sema::ObjcBuildMethodDeclaration(tok::ObjCKeywordKind& pi, Sema::DeclTy *Sema::ObjcBuildMethodDeclaration(SourceLocation MethodLoc,
SourceLocation MethodLoc,
tok::TokenKind MethodType, TypeTy *ReturnType, tok::TokenKind MethodType, TypeTy *ReturnType,
IdentifierInfo *SelectorName, AttributeList *AttrList) { IdentifierInfo *SelectorName, AttributeList *AttrList,
tok::ObjCKeywordKind MethodDeclKind) {
const char *methodName = SelectorName->getName(); const char *methodName = SelectorName->getName();
SelectorInfo &SelName = Context.getSelectorInfo(methodName, SelectorInfo &SelName = Context.getSelectorInfo(methodName,
methodName+strlen(methodName)); methodName+strlen(methodName));
@ -1324,7 +1324,7 @@ Sema::DeclTy *Sema::ObjcBuildMethodDeclaration(tok::ObjCKeywordKind& pi,
ObjcMethodDecl* ObjcMethod = new ObjcMethodDecl(MethodLoc, ObjcMethodDecl* ObjcMethod = new ObjcMethodDecl(MethodLoc,
SelName, resultDeclType, 0, -1, SelName, resultDeclType, 0, -1,
AttrList, MethodType == tok::minus); AttrList, MethodType == tok::minus);
if (pi == tok::objc_optional) if (MethodDeclKind == tok::objc_optional)
ObjcMethod->setDeclImplementation(ObjcMethodDecl::Optional); ObjcMethod->setDeclImplementation(ObjcMethodDecl::Optional);
else else
ObjcMethod->setDeclImplementation(ObjcMethodDecl::Required); ObjcMethod->setDeclImplementation(ObjcMethodDecl::Required);

View File

@ -453,15 +453,17 @@ public:
IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs) { IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs) {
return 0; return 0;
} }
virtual DeclTy *ObjcBuildMethodDeclaration(tok::ObjCKeywordKind& pi, virtual DeclTy *ObjcBuildMethodDeclaration(SourceLocation MethodLoc,
SourceLocation MethodLoc, tok::TokenKind MethodType, TypeTy *ReturnType, tok::TokenKind MethodType, TypeTy *ReturnType,
ObjcKeywordDecl *Keywords, unsigned NumKeywords, ObjcKeywordDecl *Keywords, unsigned NumKeywords,
AttributeList *AttrList) { AttributeList *AttrList,
tok::ObjCKeywordKind MethodImplKind) {
return 0; return 0;
} }
virtual DeclTy *ObjcBuildMethodDeclaration(tok::ObjCKeywordKind& pi, virtual DeclTy *ObjcBuildMethodDeclaration(SourceLocation MethodLoc,
SourceLocation MethodLoc, tok::TokenKind MethodType, TypeTy *ReturnType, tok::TokenKind MethodType, TypeTy *ReturnType,
IdentifierInfo *SelectorName, AttributeList *AttrList) { IdentifierInfo *SelectorName, AttributeList *AttrList,
tok::ObjCKeywordKind MethodImplKind) {
return 0; return 0;
} }
// This actions handles keyword message to classes. // This actions handles keyword message to classes.

View File

@ -290,10 +290,9 @@ private:
TypeTy *ParseObjCTypeName(); TypeTy *ParseObjCTypeName();
void ParseObjCMethodRequirement(); void ParseObjCMethodRequirement();
DeclTy *ParseObjCMethodPrototype(DeclTy *classOrCat, DeclTy *ParseObjCMethodPrototype(DeclTy *classOrCat,
tok::ObjCKeywordKind& pi); tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword);
DeclTy *ParseObjCMethodDecl(tok::ObjCKeywordKind& pi, DeclTy *ParseObjCMethodDecl(tok::TokenKind mType, SourceLocation mLoc,
tok::TokenKind mType, tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword);
SourceLocation mLoc);
void ParseObjCPropertyAttribute(DeclTy *interfaceDecl); void ParseObjCPropertyAttribute(DeclTy *interfaceDecl);
void ParseObjCPropertyDecl(DeclTy *interfaceDecl); void ParseObjCPropertyDecl(DeclTy *interfaceDecl);