diff options
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Parse/ParseObjc.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Sema/Sema.h | 4 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 34 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 4 |
4 files changed, 43 insertions, 3 deletions
diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp index fc243270604..2e0df826bb2 100644 --- a/clang/lib/Parse/ParseObjc.cpp +++ b/clang/lib/Parse/ParseObjc.cpp @@ -705,7 +705,7 @@ 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, + 0, CargNames, ReturnAttrs, MethodAttrs, MethodImplKind); } @@ -779,7 +779,7 @@ Parser::DeclPtrTy Parser::ParseObjCMethodDecl(SourceLocation mLoc, &KeyIdents[0]); return Actions.ActOnMethodDeclaration(mLoc, Tok.getLocation(), mType, IDecl, DSRet, ReturnType, Sel, - &ArgInfos[0], CargNames, + &ArgInfos[0], CargNames, ReturnAttrs, MethodAttrs, MethodImplKind, isVariadic); } diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h index d04394d94fd..e4746372a51 100644 --- a/clang/lib/Sema/Sema.h +++ b/clang/lib/Sema/Sema.h @@ -1071,6 +1071,9 @@ 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); @@ -2186,6 +2189,7 @@ public: // from the Sel.getNumArgs(). ObjCArgInfo *ArgInfo, llvm::SmallVectorImpl<Declarator> &Cdecls, + AttributeList *ReturnAttrList, AttributeList *AttrList, tok::ObjCKeywordKind MethodImplKind, bool isVariadic = false); diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index df4fd4dd430..4853028ba36 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -1697,7 +1697,6 @@ void Sema::ProcessDeclAttributeList(Decl *D, const AttributeList *AttrList) { } } - /// ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in /// it, apply them to D. This is a bit tricky because PD can have attributes /// specified in many different places, and we need to find and apply them all. @@ -1719,3 +1718,36 @@ void Sema::ProcessDeclAttributes(Decl *D, const Declarator &PD) { 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(); + } +} diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 170efec5f37..61f62cd4bf7 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -1509,6 +1509,7 @@ 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>(); @@ -1590,6 +1591,9 @@ 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 |

