Index: include/clang/Basic/Attr.td =================================================================== --- include/clang/Basic/Attr.td +++ include/clang/Basic/Attr.td @@ -1127,13 +1127,13 @@ } def IBOutlet : InheritableAttr { - let Spellings = [Clang<"iboutlet">]; + let Spellings = [Clang<"iboutlet", 1>]; // let Subjects = [ObjCIvar, ObjCProperty]; let Documentation = [Undocumented]; } def IBOutletCollection : InheritableAttr { - let Spellings = [Clang<"iboutletcollection">]; + let Spellings = [Clang<"iboutletcollection", 1>]; let Args = [TypeArgument<"Interface", 1>]; // let Subjects = [ObjCIvar, ObjCProperty]; let Documentation = [Undocumented]; @@ -1421,7 +1421,7 @@ } def NoEscape : Attr { - let Spellings = [Clang<"noescape">]; + let Spellings = [Clang<"noescape", 1>]; let Subjects = SubjectList<[ParmVar]>; let Documentation = [NoEscapeDocs]; } @@ -1473,14 +1473,14 @@ } def ObjCBridge : InheritableAttr { - let Spellings = [Clang<"objc_bridge">]; + let Spellings = [Clang<"objc_bridge", 1>]; let Subjects = SubjectList<[Record, TypedefName], ErrorDiag>; let Args = [IdentifierArgument<"BridgedType">]; let Documentation = [Undocumented]; } def ObjCBridgeMutable : InheritableAttr { - let Spellings = [Clang<"objc_bridge_mutable">]; + let Spellings = [Clang<"objc_bridge_mutable", 1>]; let Subjects = SubjectList<[Record], ErrorDiag>; let Args = [IdentifierArgument<"BridgedType">]; let Documentation = [Undocumented]; @@ -1517,7 +1517,7 @@ } def NSConsumesSelf : InheritableAttr { - let Spellings = [Clang<"ns_consumes_self">]; + let Spellings = [Clang<"ns_consumes_self", 1>]; let Subjects = SubjectList<[ObjCMethod]>; let Documentation = [Undocumented]; } @@ -1529,7 +1529,7 @@ } def ObjCException : InheritableAttr { - let Spellings = [Clang<"objc_exception">]; + let Spellings = [Clang<"objc_exception", 1>]; let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; let Documentation = [Undocumented]; } @@ -1561,7 +1561,7 @@ } def ObjCReturnsInnerPointer : InheritableAttr { - let Spellings = [Clang<"objc_returns_inner_pointer">]; + let Spellings = [Clang<"objc_returns_inner_pointer", 1>]; let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>; let Documentation = [Undocumented]; } @@ -1573,19 +1573,19 @@ } def ObjCRootClass : InheritableAttr { - let Spellings = [Clang<"objc_root_class">]; + let Spellings = [Clang<"objc_root_class", 1>]; let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; let Documentation = [Undocumented]; } def ObjCSubclassingRestricted : InheritableAttr { - let Spellings = [Clang<"objc_subclassing_restricted">]; + let Spellings = [Clang<"objc_subclassing_restricted", 1>]; let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; let Documentation = [ObjCSubclassingRestrictedDocs]; } def ObjCExplicitProtocolImpl : InheritableAttr { - let Spellings = [Clang<"objc_protocol_requires_explicit_implementation">]; + let Spellings = [Clang<"objc_protocol_requires_explicit_implementation", 1>]; let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>; let Documentation = [Undocumented]; } @@ -1597,20 +1597,20 @@ } def ObjCRuntimeName : Attr { - let Spellings = [Clang<"objc_runtime_name">]; + let Spellings = [Clang<"objc_runtime_name", 1>]; let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>; let Args = [StringArgument<"MetadataName">]; let Documentation = [ObjCRuntimeNameDocs]; } def ObjCRuntimeVisible : Attr { - let Spellings = [Clang<"objc_runtime_visible">]; + let Spellings = [Clang<"objc_runtime_visible", 1>]; let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; let Documentation = [ObjCRuntimeVisibleDocs]; } def ObjCBoxable : Attr { - let Spellings = [Clang<"objc_boxable">]; + let Spellings = [Clang<"objc_boxable", 1>]; let Subjects = SubjectList<[Record], ErrorDiag>; let Documentation = [ObjCBoxableDocs]; } @@ -1943,7 +1943,7 @@ } def ArcWeakrefUnavailable : InheritableAttr { - let Spellings = [Clang<"objc_arc_weak_reference_unavailable">]; + let Spellings = [Clang<"objc_arc_weak_reference_unavailable", 1>]; let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; let Documentation = [Undocumented]; } @@ -1962,7 +1962,7 @@ } def ObjCRequiresPropertyDefs : InheritableAttr { - let Spellings = [Clang<"objc_requires_property_definitions">]; + let Spellings = [Clang<"objc_requires_property_definitions", 1>]; let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; let Documentation = [Undocumented]; } Index: include/clang/Parse/Parser.h =================================================================== --- include/clang/Parse/Parser.h +++ include/clang/Parse/Parser.h @@ -1340,7 +1340,7 @@ // Objective-C External Declarations void MaybeSkipAttributes(tok::ObjCKeywordKind Kind); - DeclGroupPtrTy ParseObjCAtDirectives(); + DeclGroupPtrTy ParseObjCAtDirectives(ParsedAttributesWithRange &Attrs); DeclGroupPtrTy ParseObjCAtClassDeclaration(SourceLocation atLoc); Decl *ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc, ParsedAttributes &prefixAttrs); Index: lib/Parse/ParseObjc.cpp =================================================================== --- lib/Parse/ParseObjc.cpp +++ lib/Parse/ParseObjc.cpp @@ -45,7 +45,8 @@ /// [OBJC] objc-protocol-definition /// [OBJC] objc-method-definition /// [OBJC] '@' 'end' -Parser::DeclGroupPtrTy Parser::ParseObjCAtDirectives() { +Parser::DeclGroupPtrTy +Parser::ParseObjCAtDirectives(ParsedAttributesWithRange &Attrs) { SourceLocation AtLoc = ConsumeToken(); // the "@" if (Tok.is(tok::code_completion)) { @@ -58,15 +59,11 @@ switch (Tok.getObjCKeywordID()) { case tok::objc_class: return ParseObjCAtClassDeclaration(AtLoc); - case tok::objc_interface: { - ParsedAttributes attrs(AttrFactory); - SingleDecl = ParseObjCAtInterfaceDeclaration(AtLoc, attrs); + case tok::objc_interface: + SingleDecl = ParseObjCAtInterfaceDeclaration(AtLoc, Attrs); break; - } - case tok::objc_protocol: { - ParsedAttributes attrs(AttrFactory); - return ParseObjCAtProtocolDeclaration(AtLoc, attrs); - } + case tok::objc_protocol: + return ParseObjCAtProtocolDeclaration(AtLoc, Attrs); case tok::objc_implementation: return ParseObjCAtImplementationDeclaration(AtLoc); case tok::objc_end: @@ -1359,6 +1356,7 @@ ParsedAttributes methodAttrs(AttrFactory); if (getLangOpts().ObjC2) MaybeParseGNUAttributes(methodAttrs); + MaybeParseCXX11Attributes(methodAttrs); if (Tok.is(tok::code_completion)) { Actions.CodeCompleteObjCMethodDecl(getCurScope(), mType == tok::minus, @@ -1385,6 +1383,7 @@ // If attributes exist after the method, parse them. if (getLangOpts().ObjC2) MaybeParseGNUAttributes(methodAttrs); + MaybeParseCXX11Attributes(methodAttrs); Selector Sel = PP.getSelectorTable().getNullarySelector(SelIdent); Decl *Result @@ -1421,11 +1420,10 @@ // If attributes exist before the argument name, parse them. // Regardless, collect all the attributes we've parsed so far. - ArgInfo.ArgAttrs = nullptr; - if (getLangOpts().ObjC2) { + if (getLangOpts().ObjC2) MaybeParseGNUAttributes(paramAttrs); - ArgInfo.ArgAttrs = paramAttrs.getList(); - } + MaybeParseCXX11Attributes(paramAttrs); + ArgInfo.ArgAttrs = paramAttrs.getList(); // Code completion for the next piece of the selector. if (Tok.is(tok::code_completion)) { @@ -1508,7 +1506,8 @@ // If attributes exist after the method, parse them. if (getLangOpts().ObjC2) MaybeParseGNUAttributes(methodAttrs); - + MaybeParseCXX11Attributes(methodAttrs); + if (KeyIdents.size() == 0) return nullptr; Index: lib/Parse/Parser.cpp =================================================================== --- lib/Parse/Parser.cpp +++ lib/Parse/Parser.cpp @@ -741,7 +741,7 @@ break; } case tok::at: - return ParseObjCAtDirectives(); + return ParseObjCAtDirectives(attrs); case tok::minus: case tok::plus: if (!getLangOpts().ObjC1) { Index: test/Misc/ast-dump-attr.m =================================================================== --- test/Misc/ast-dump-attr.m +++ test/Misc/ast-dump-attr.m @@ -0,0 +1,57 @@ +// RUN: %clang_cc1 -fdouble-square-bracket-attributes -triple x86_64-apple-macosx10.10.0 -ast-dump -ast-dump-filter Test %s | FileCheck --strict-whitespace %s + +@interface NSObject +@end + +[[clang::objc_exception]] +@interface Test1 { +// CHECK: ObjCInterfaceDecl{{.*}} Test1 +// CHECK-NEXT: ObjCExceptionAttr{{.*}} + [[clang::iboutlet]] NSObject *Test2; +// CHECK: ObjCIvarDecl{{.*}} Test2 +// CHECK-NEXT: IBOutletAttr +} +@property (readonly) [[clang::objc_returns_inner_pointer]] void *Test3, *Test4; +// CHECK: ObjCPropertyDecl{{.*}} Test3 'void *' readonly +// CHECK-NEXT: ObjCReturnsInnerPointerAttr +// CHECK-NEXT: ObjCPropertyDecl{{.*}} Test4 'void *' readonly +// CHECK-NEXT: ObjCReturnsInnerPointerAttr + +@property (readonly) [[clang::iboutlet]] NSObject *Test5; +// CHECK: ObjCPropertyDecl{{.*}} Test5 'NSObject *' readonly +// CHECK-NEXT: IBOutletAttr + +// CHECK: ObjCMethodDecl{{.*}} implicit{{.*}} Test3 +// CHECK-NEXT: ObjCReturnsInnerPointerAttr +// CHECK: ObjCMethodDecl{{.*}} implicit{{.*}} Test4 +// CHECK-NEXT: ObjCReturnsInnerPointerAttr +// CHECK: ObjCMethodDecl{{.*}} implicit{{.*}} Test5 +// CHECK-NOT: IBOutletAttr +@end + +[[clang::objc_runtime_name("name")]] @protocol Test6; +// CHECK: ObjCProtocolDecl{{.*}} Test6 +// CHECK-NEXT: ObjCRuntimeNameAttr{{.*}} "name" + +[[clang::objc_protocol_requires_explicit_implementation]] +@protocol Test7 +// CHECK: ObjCProtocolDecl{{.*}} Test7 +// CHECK-NEXT: ObjCExplicitProtocolImplAttr +@end + +@interface Test8 +// CHECK: ObjCInterfaceDecl{{.*}} Test8 +-(void)Test9 [[clang::ns_consumes_self]]; +// CHECK: ObjCMethodDecl{{.*}} Test9 'void' +// CHECK-NEXT: NSConsumesSelfAttr +-(void) [[clang::ns_consumes_self]] Test10: (int)Test11; +// CHECK: ObjCMethodDecl{{.*}} Test10: 'void' +// CHECK-NEXT: |-ParmVarDecl{{.*}} Test11 'int' +// CHECK-NEXT: `-NSConsumesSelfAttr +-(void)Test12: (int *) [[clang::noescape]] Test13 to:(int)Test14 [[clang::ns_consumes_self]]; +// CHECK: ObjCMethodDecl{{.*}} Test12:to: 'void' +// CHECK-NEXT: |-ParmVarDecl{{.*}} Test13 'int *' +// CHECK-NEXT: | `-NoEscapeAttr +// CHECK-NEXT: |-ParmVarDecl{{.*}} Test14 'int' +// CHECK-NEXT: `-NSConsumesSelfAttr +@end Index: test/Parser/objc-attr.m =================================================================== --- test/Parser/objc-attr.m +++ test/Parser/objc-attr.m @@ -0,0 +1,28 @@ +// RUN: %clang_cc1 -fsyntax-only -fdouble-square-bracket-attributes -triple x86_64-apple-macosx10.10.0 -verify %s +// expected-no-diagnostics + +@interface NSObject +@end + +[[clang::objc_exception]] +@interface Foo { + [[clang::iboutlet]] NSObject *h; +} +@property (readonly) [[clang::objc_returns_inner_pointer]] void *i, *j; +@property (readonly) [[clang::iboutlet]] NSObject *k; +@end + +[[clang::objc_runtime_name("name")]] @protocol Bar; + +[[clang::objc_protocol_requires_explicit_implementation]] +@protocol Baz +@end + +@interface Quux +-(void)g1 [[clang::ns_consumes_self]]; +-(void)g2 __attribute__((ns_consumes_self)); +-(void)h1: (int)x [[clang::ns_consumes_self]]; +-(void)h2: (int)x __attribute__((ns_consumes_self)); +-(void) [[clang::ns_consumes_self]] i1; +-(void) __attribute__((ns_consumes_self)) i2; +@end