]> granicus.if.org Git - clang/commitdiff
Remove support for ObjCMethodDecl attributes that appear between the
authorTed Kremenek <kremenek@apple.com>
Mon, 4 May 2009 17:04:30 +0000 (17:04 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 4 May 2009 17:04:30 +0000 (17:04 +0000)
return type and the selector.  This is inconsistent with C functions
(where such attributes would be placed on the return type, not the the
FunctionDecl), and is inconsistent with what people are use to seeing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70878 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Parse/Action.h
lib/Parse/ParseObjc.cpp
lib/Sema/Sema.h
lib/Sema/SemaDeclAttr.cpp
lib/Sema/SemaDeclObjC.cpp
test/Analysis/retain-release.m

index 60cc7cf1548cffb91198288c6dbb7afafe33d43a..fdd2b2abacf1a3c50a209b89240c3ebc945c396e 100644 (file)
@@ -1439,7 +1439,6 @@ public:
     Selector Sel,              // a unique name for the method.
     ObjCArgInfo *ArgInfo,      // ArgInfo: Has 'Sel.getNumArgs()' entries.
     llvm::SmallVectorImpl<Declarator> &Cdecls, // c-style args
-    AttributeList *ReturnAttrList, // optional
     AttributeList *MethodAttrList, // optional
     // tok::objc_not_keyword, tok::objc_optional, tok::objc_required    
     tok::ObjCKeywordKind impKind,
index 2e0df826bb25d421d8c85499283ebfccc8157f76..6c42f429ccdb7296f9c8590892f1f532b00e0a12 100644 (file)
@@ -677,12 +677,6 @@ Parser::DeclPtrTy Parser::ParseObjCMethodDecl(SourceLocation mLoc,
   if (Tok.is(tok::l_paren))
     ReturnType = ParseObjCTypeName(DSRet);
   
-  // Parse attributes that can appear before the selector.
-  AttributeList *ReturnAttrs = 0;
-
-  if (getLang().ObjC2 && Tok.is(tok::kw___attribute)) 
-    ReturnAttrs = ParseAttributes();  
-  
   SourceLocation selLoc;
   IdentifierInfo *SelIdent = ParseObjCSelectorPiece(selLoc);
 
@@ -705,8 +699,8 @@ Parser::DeclPtrTy Parser::ParseObjCMethodDecl(SourceLocation mLoc,
     Selector Sel = PP.getSelectorTable().getNullarySelector(SelIdent);
     return Actions.ActOnMethodDeclaration(mLoc, Tok.getLocation(),
                                           mType, IDecl, DSRet, ReturnType, Sel,
-                                          0, CargNames, ReturnAttrs, 
-                                          MethodAttrs, MethodImplKind);
+                                          0, CargNames, MethodAttrs,
+                                          MethodImplKind);
   }
 
   llvm::SmallVector<IdentifierInfo *, 12> KeyIdents;
@@ -779,8 +773,7 @@ Parser::DeclPtrTy Parser::ParseObjCMethodDecl(SourceLocation mLoc,
                                                    &KeyIdents[0]);
   return Actions.ActOnMethodDeclaration(mLoc, Tok.getLocation(),
                                         mType, IDecl, DSRet, ReturnType, Sel, 
-                                        &ArgInfos[0], CargNames, ReturnAttrs,
-                                        MethodAttrs,
+                                        &ArgInfos[0], CargNames, MethodAttrs,
                                         MethodImplKind, isVariadic);
 }
 
index 1c652114e36106228c6321635dc56050ab1f2eee..3ca00ca1433c407f6a3682b57b2eac58d27a0265 100644 (file)
@@ -1098,9 +1098,6 @@ public:
   // Decl attributes - this routine is the top level dispatcher. 
   void ProcessDeclAttributes(Decl *D, const Declarator &PD);
   void ProcessDeclAttributeList(Decl *D, const AttributeList *AttrList);
-  
-  void ProcessObjCMethDeclReturnAttributeList(ObjCMethodDecl *D,
-                                              const AttributeList *AttrList);
 
   void WarnUndefinedMethod(SourceLocation ImpLoc, ObjCMethodDecl *method,
                            bool &IncompleteImpl);
@@ -2227,7 +2224,6 @@ public:
     // from the Sel.getNumArgs().
     ObjCArgInfo *ArgInfo,
     llvm::SmallVectorImpl<Declarator> &Cdecls,
-    AttributeList *ReturnAttrList,
     AttributeList *AttrList, tok::ObjCKeywordKind MethodImplKind,
     bool isVariadic = false);
 
index 1e3a7e58bb121c7391e675226806954a7e5b0c4b..68d682ddab8995aaa4a6c2b0d37f8a8b5e582151 100644 (file)
@@ -1719,37 +1719,3 @@ void Sema::ProcessDeclAttributes(Decl *D, const Declarator &PD) {
   if (const AttributeList *Attrs = PD.getAttributes())
     ProcessDeclAttributeList(D, Attrs);
 }
-
-
-/// ProcessObjCMethDeclReturnAttribute - Apply the specific attribute to the
-///   specified ObjCMethodDecl.  This is a separate codepath because it
-///   corresponds to attributes applied essentially to the return type of
-///   an Objective-C method declaration (as opposed to attributes that hang off
-///   the end of the method declaration).
-static void ProcessObjCMethDeclReturnAttribute(Decl *D,
-                                               const AttributeList &Attr,
-                                               Sema &S) {
-  switch (Attr.getKind()) {
-      // Checker-specific.
-    case AttributeList::AT_objc_ownership_returns:
-      HandleObjCOwnershipReturnsAttr(D, Attr, S); break;
-      break;
-    default:
-      S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
-      break;
-  }
-}
-
-/// ProcessObjCMethDeclAttributeList - Apply all the decl attributes in the
-///  specified attribute list to the specified ObjCMethodDecl.  This is
-///  a separate codepath because it corresponds to attributes applied
-///  essentiallyto the return type of an Objective-C method declaration
-///  (as opposed to attributes that hang off the end of the method declaration).
-void Sema::ProcessObjCMethDeclReturnAttributeList(ObjCMethodDecl *D,
-                                                  const AttributeList *AttrList)
-{
-  while (AttrList) {
-    ProcessObjCMethDeclReturnAttribute(D, *AttrList, *this);
-    AttrList = AttrList->getNext();
-  }
-}
index 80b30bdb74c223787c0ac08183c6f3e32e72e6a3..0e655a493da9ae0d0c661fd12e00d508450be76e 100644 (file)
@@ -1557,7 +1557,6 @@ Sema::DeclPtrTy Sema::ActOnMethodDeclaration(
     // from the Sel.getNumArgs().
     ObjCArgInfo *ArgInfo,
     llvm::SmallVectorImpl<Declarator> &Cdecls,
-    AttributeList *ReturnAttrList,                                             
     AttributeList *AttrList, tok::ObjCKeywordKind MethodDeclKind,
     bool isVariadic) {
   Decl *ClassDecl = classDecl.getAs<Decl>();
@@ -1640,9 +1639,6 @@ Sema::DeclPtrTy Sema::ActOnMethodDeclaration(
   if (AttrList)
     ProcessDeclAttributeList(ObjCMethod, AttrList);
   
-  if (ReturnAttrList)
-    ProcessObjCMethDeclReturnAttributeList(ObjCMethod, ReturnAttrList);
   // For implementations (which can be very "coarse grain"), we add the 
   // method now. This allows the AST to implement lookup methods that work 
   // incrementally (without waiting until we parse the @end). It also allows 
index c01da9cabb6303812274362695cde39a0dec9a78..93d461329b27ac7ccd5879863fa260361b5ffb42 100644 (file)
@@ -431,11 +431,7 @@ void rdar6704930(unsigned char *s, unsigned int length) {
 //===----------------------------------------------------------------------===//
 
 @interface TestOwnershipAttr : NSObject
-- (NSString*)  __attribute__((objc_ownership_returns)) returnsAnOwnedString;
-// Soon we won't accept __attribute__((objc_ownership_returns)) at the end
-// of a method decl.
-- (NSString*) returnsAnOwnedString2 __attribute__((objc_ownership_returns));
-
+- (NSString*) returnsAnOwnedString  __attribute__((objc_ownership_returns));
 - (void) myRetain:(id)__attribute__((objc_ownership_retain))obj;
 - (void) myCFRetain:(id)__attribute__((objc_ownership_cfretain))obj;
 - (void) myRelease:(id)__attribute__((objc_ownership_release))obj;