r358200 - Add support for attributes on @implementations in Objective-C

Erik Pilkington via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 11 10:55:30 PDT 2019


Author: epilk
Date: Thu Apr 11 10:55:30 2019
New Revision: 358200

URL: http://llvm.org/viewvc/llvm-project?rev=358200&view=rev
Log:
Add support for attributes on @implementations in Objective-C

We want to make objc_nonlazy_class apply to implementations, but ran into this.
There doesn't seem to be any reason that this isn't supported.

Differential revision: https://reviews.llvm.org/D60542

Added:
    cfe/trunk/test/Parser/objc-implementation-attrs.m
Modified:
    cfe/trunk/include/clang/Basic/Attr.td
    cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
    cfe/trunk/include/clang/Parse/Parser.h
    cfe/trunk/include/clang/Sema/Sema.h
    cfe/trunk/lib/Parse/ParseObjc.cpp
    cfe/trunk/lib/Parse/Parser.cpp
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/test/FixIt/fixit-pragma-attribute.cpp
    cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
    cfe/trunk/test/Parser/attributes.mm
    cfe/trunk/test/Parser/placeholder-recovery.m
    cfe/trunk/test/Sema/pragma-attribute-strict-subjects.c
    cfe/trunk/test/SemaObjC/attr-objc-non-lazy.m
    cfe/trunk/test/SemaObjC/objc-asm-attribute-neg-test.m

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=358200&r1=358199&r2=358200&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Thu Apr 11 10:55:30 2019
@@ -419,6 +419,10 @@ def SubjectMatcherForObjCCategory : Attr
                                                            [ObjCCategory]> {
   let LangOpts = [ObjC];
 }
+def SubjectMatcherForObjCImplementation :
+    AttrSubjectMatcherRule<"objc_implementation", [ObjCImpl]> {
+  let LangOpts = [ObjC];
+}
 def SubjectMatcherForObjCMethod : AttrSubjectMatcherRule<"objc_method",
                                                          [ObjCMethod], [
   AttrSubjectMatcherSubRule<"is_instance", [ObjCInstanceMethod]>

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=358200&r1=358199&r2=358200&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Thu Apr 11 10:55:30 2019
@@ -433,7 +433,7 @@ def err_objc_expected_property_attr : Er
 def err_objc_properties_require_objc2 : Error<
   "properties are an Objective-C 2 feature">;
 def err_objc_unexpected_attr : Error<
-  "prefix attribute must be followed by an interface or protocol">;
+  "prefix attribute must be followed by an interface, protocol, or implementation">;
 def err_objc_postfix_attribute : Error <
   "postfix attributes are not allowed on Objective-C directives">;
 def err_objc_postfix_attribute_hint : Error <

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=358200&r1=358199&r2=358200&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Thu Apr 11 10:55:30 2019
@@ -1573,7 +1573,8 @@ private:
   ObjCImplParsingDataRAII *CurParsedObjCImpl;
   void StashAwayMethodOrFunctionBodyTokens(Decl *MDecl);
 
-  DeclGroupPtrTy ParseObjCAtImplementationDeclaration(SourceLocation AtLoc);
+  DeclGroupPtrTy ParseObjCAtImplementationDeclaration(SourceLocation AtLoc,
+                                                      ParsedAttributes &Attrs);
   DeclGroupPtrTy ParseObjCAtEndDeclaration(SourceRange atEnd);
   Decl *ParseObjCAtAliasDeclaration(SourceLocation atLoc);
   Decl *ParseObjCPropertySynthesize(SourceLocation atLoc);

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=358200&r1=358199&r2=358200&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Apr 11 10:55:30 2019
@@ -8105,17 +8105,19 @@ public:
       const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc,
       const ParsedAttributesView &AttrList);
 
-  Decl *ActOnStartClassImplementation(
-                    SourceLocation AtClassImplLoc,
-                    IdentifierInfo *ClassName, SourceLocation ClassLoc,
-                    IdentifierInfo *SuperClassname,
-                    SourceLocation SuperClassLoc);
+  Decl *ActOnStartClassImplementation(SourceLocation AtClassImplLoc,
+                                      IdentifierInfo *ClassName,
+                                      SourceLocation ClassLoc,
+                                      IdentifierInfo *SuperClassname,
+                                      SourceLocation SuperClassLoc,
+                                      const ParsedAttributesView &AttrList);
 
   Decl *ActOnStartCategoryImplementation(SourceLocation AtCatImplLoc,
                                          IdentifierInfo *ClassName,
                                          SourceLocation ClassLoc,
                                          IdentifierInfo *CatName,
-                                         SourceLocation CatLoc);
+                                         SourceLocation CatLoc,
+                                         const ParsedAttributesView &AttrList);
 
   DeclGroupPtrTy ActOnFinishObjCImplementation(Decl *ObjCImpDecl,
                                                ArrayRef<Decl *> Decls);

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=358200&r1=358199&r2=358200&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu Apr 11 10:55:30 2019
@@ -64,7 +64,7 @@ Parser::ParseObjCAtDirectives(ParsedAttr
   case tok::objc_protocol:
     return ParseObjCAtProtocolDeclaration(AtLoc, Attrs);
   case tok::objc_implementation:
-    return ParseObjCAtImplementationDeclaration(AtLoc);
+    return ParseObjCAtImplementationDeclaration(AtLoc, Attrs);
   case tok::objc_end:
     return ParseObjCAtEndDeclaration(AtLoc);
   case tok::objc_compatibility_alias:
@@ -2097,7 +2097,8 @@ Parser::ParseObjCAtProtocolDeclaration(S
 ///   objc-category-implementation-prologue:
 ///     @implementation identifier ( identifier )
 Parser::DeclGroupPtrTy
-Parser::ParseObjCAtImplementationDeclaration(SourceLocation AtLoc) {
+Parser::ParseObjCAtImplementationDeclaration(SourceLocation AtLoc,
+                                             ParsedAttributes &Attrs) {
   assert(Tok.isObjCAtKeyword(tok::objc_implementation) &&
          "ParseObjCAtImplementationDeclaration(): Expected @implementation");
   CheckNestedObjCContexts(AtLoc);
@@ -2174,8 +2175,7 @@ Parser::ParseObjCAtImplementationDeclara
                                         /*consumeLastToken=*/true);
     }
     ObjCImpDecl = Actions.ActOnStartCategoryImplementation(
-                                    AtLoc, nameId, nameLoc, categoryId,
-                                    categoryLoc);
+        AtLoc, nameId, nameLoc, categoryId, categoryLoc, Attrs);
 
   } else {
     // We have a class implementation
@@ -2189,8 +2189,7 @@ Parser::ParseObjCAtImplementationDeclara
       superClassLoc = ConsumeToken(); // Consume super class name
     }
     ObjCImpDecl = Actions.ActOnStartClassImplementation(
-                                    AtLoc, nameId, nameLoc,
-                                    superClassId, superClassLoc);
+        AtLoc, nameId, nameLoc, superClassId, superClassLoc, Attrs);
 
     if (Tok.is(tok::l_brace)) // we have ivars
       ParseObjCClassInstanceVariables(ObjCImpDecl, tok::objc_private, AtLoc);

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=358200&r1=358199&r2=358200&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Thu Apr 11 10:55:30 2019
@@ -980,9 +980,10 @@ Parser::ParseDeclOrFunctionDefInternal(P
   if (getLangOpts().ObjC && Tok.is(tok::at)) {
     SourceLocation AtLoc = ConsumeToken(); // the "@"
     if (!Tok.isObjCAtKeyword(tok::objc_interface) &&
-        !Tok.isObjCAtKeyword(tok::objc_protocol)) {
+        !Tok.isObjCAtKeyword(tok::objc_protocol) &&
+        !Tok.isObjCAtKeyword(tok::objc_implementation)) {
       Diag(Tok, diag::err_objc_unexpected_attr);
-      SkipUntil(tok::semi); // FIXME: better skip?
+      SkipUntil(tok::semi);
       return nullptr;
     }
 
@@ -997,6 +998,9 @@ Parser::ParseDeclOrFunctionDefInternal(P
     if (Tok.isObjCAtKeyword(tok::objc_protocol))
       return ParseObjCAtProtocolDeclaration(AtLoc, DS.getAttributes());
 
+    if (Tok.isObjCAtKeyword(tok::objc_implementation))
+      return ParseObjCAtImplementationDeclaration(AtLoc, DS.getAttributes());
+
     return Actions.ConvertDeclToDeclGroup(
             ParseObjCAtInterfaceDeclaration(AtLoc, DS.getAttributes()));
   }

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=358200&r1=358199&r2=358200&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Apr 11 10:55:30 2019
@@ -1892,7 +1892,8 @@ Decl *Sema::ActOnStartCategoryInterface(
 Decl *Sema::ActOnStartCategoryImplementation(
                       SourceLocation AtCatImplLoc,
                       IdentifierInfo *ClassName, SourceLocation ClassLoc,
-                      IdentifierInfo *CatName, SourceLocation CatLoc) {
+                      IdentifierInfo *CatName, SourceLocation CatLoc,
+                      const ParsedAttributesView &Attrs) {
   ObjCInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName, ClassLoc, true);
   ObjCCategoryDecl *CatIDecl = nullptr;
   if (IDecl && IDecl->hasDefinition()) {
@@ -1920,6 +1921,9 @@ Decl *Sema::ActOnStartCategoryImplementa
     CDecl->setInvalidDecl();
   }
 
+  ProcessDeclAttributeList(TUScope, CDecl, Attrs);
+  AddPragmaAttributes(TUScope, CDecl);
+
   // FIXME: PushOnScopeChains?
   CurContext->addDecl(CDecl);
 
@@ -1955,7 +1959,8 @@ Decl *Sema::ActOnStartClassImplementatio
                       SourceLocation AtClassImplLoc,
                       IdentifierInfo *ClassName, SourceLocation ClassLoc,
                       IdentifierInfo *SuperClassname,
-                      SourceLocation SuperClassLoc) {
+                      SourceLocation SuperClassLoc,
+                      const ParsedAttributesView &Attrs) {
   ObjCInterfaceDecl *IDecl = nullptr;
   // Check for another declaration kind with the same name.
   NamedDecl *PrevDecl
@@ -2049,6 +2054,9 @@ Decl *Sema::ActOnStartClassImplementatio
     ObjCImplementationDecl::Create(Context, CurContext, IDecl, SDecl,
                                    ClassLoc, AtClassImplLoc, SuperClassLoc);
 
+  ProcessDeclAttributeList(TUScope, IMPDecl, Attrs);
+  AddPragmaAttributes(TUScope, IMPDecl);
+
   if (CheckObjCDeclScope(IMPDecl))
     return ActOnObjCContainerStartDefinition(IMPDecl);
 

Modified: cfe/trunk/test/FixIt/fixit-pragma-attribute.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit-pragma-attribute.cpp?rev=358200&r1=358199&r2=358200&view=diff
==============================================================================
--- cfe/trunk/test/FixIt/fixit-pragma-attribute.cpp (original)
+++ cfe/trunk/test/FixIt/fixit-pragma-attribute.cpp Thu Apr 11 10:55:30 2019
@@ -16,8 +16,8 @@
 // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:133-[[@LINE-2]]:153}:""
 
 #pragma clang attribute push (__attribute__((annotate("subRuleContradictions"))), apply_to = any(variable, variable(is_parameter), function(is_member), variable(is_global)))
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:108-[[@LINE-1]]:132}:""
-// CHECK: fix-it:{{.*}}:{[[@LINE-2]]:153-[[@LINE-2]]:172}:""
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:153-[[@LINE-1]]:172}:""
+// CHECK: fix-it:{{.*}}:{[[@LINE-2]]:108-[[@LINE-2]]:132}:""
 
 #pragma clang attribute pop
 

Modified: cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test?rev=358200&r1=358199&r2=358200&view=diff
==============================================================================
--- cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test (original)
+++ cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test Thu Apr 11 10:55:30 2019
@@ -18,7 +18,7 @@
 // CHECK-NEXT: AnyX86NoCfCheck (SubjectMatchRule_hasType_functionType)
 // CHECK-NEXT: ArcWeakrefUnavailable (SubjectMatchRule_objc_interface)
 // CHECK-NEXT: AssumeAligned (SubjectMatchRule_objc_method, SubjectMatchRule_function)
-// CHECK-NEXT: Availability ((SubjectMatchRule_record, SubjectMatchRule_enum, SubjectMatchRule_enum_constant, SubjectMatchRule_field, SubjectMatchRule_function, SubjectMatchRule_namespace, SubjectMatchRule_objc_category, SubjectMatchRule_objc_interface, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, SubjectMatchRule_objc_protocol, SubjectMatchRule_record, SubjectMatchRule_type_alias, SubjectMatchRule_variable))
+// CHECK-NEXT: Availability ((SubjectMatchRule_record, SubjectMatchRule_enum, SubjectMatchRule_enum_constant, SubjectMatchRule_field, SubjectMatchRule_function, SubjectMatchRule_namespace, SubjectMatchRule_objc_category, SubjectMatchRule_objc_implementation, SubjectMatchRule_objc_interface, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, SubjectMatchRule_objc_protocol, SubjectMatchRule_record, SubjectMatchRule_type_alias, SubjectMatchRule_variable))
 // CHECK-NEXT: CFAuditedTransfer (SubjectMatchRule_function)
 // CHECK-NEXT: CFConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: CFUnknownTransfer (SubjectMatchRule_function)
@@ -49,7 +49,7 @@
 // CHECK-NEXT: EnableIf (SubjectMatchRule_function)
 // CHECK-NEXT: EnumExtensibility (SubjectMatchRule_enum)
 // CHECK-NEXT: ExcludeFromExplicitInstantiation (SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_record)
-// CHECK-NEXT: ExternalSourceSymbol ((SubjectMatchRule_record, SubjectMatchRule_enum, SubjectMatchRule_enum_constant, SubjectMatchRule_field, SubjectMatchRule_function, SubjectMatchRule_namespace, SubjectMatchRule_objc_category, SubjectMatchRule_objc_interface, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, SubjectMatchRule_objc_protocol, SubjectMatchRule_record, SubjectMatchRule_type_alias, SubjectMatchRule_variable))
+// CHECK-NEXT: ExternalSourceSymbol ((SubjectMatchRule_record, SubjectMatchRule_enum, SubjectMatchRule_enum_constant, SubjectMatchRule_field, SubjectMatchRule_function, SubjectMatchRule_namespace, SubjectMatchRule_objc_category, SubjectMatchRule_objc_implementation, SubjectMatchRule_objc_interface, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, SubjectMatchRule_objc_protocol, SubjectMatchRule_record, SubjectMatchRule_type_alias, SubjectMatchRule_variable))
 // CHECK-NEXT: FlagEnum (SubjectMatchRule_enum)
 // CHECK-NEXT: Flatten (SubjectMatchRule_function)
 // CHECK-NEXT: GNUInline (SubjectMatchRule_function)

Modified: cfe/trunk/test/Parser/attributes.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/attributes.mm?rev=358200&r1=358199&r2=358200&view=diff
==============================================================================
--- cfe/trunk/test/Parser/attributes.mm (original)
+++ cfe/trunk/test/Parser/attributes.mm Thu Apr 11 10:55:30 2019
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -verify -fsyntax-only -Wno-objc-root-class %s
 
-__attribute__((deprecated)) @class B; // expected-error {{prefix attribute must be followed by an interface or protocol}}
+// FIXME: Why isn't this supported? Seems useful for availability attributes at
+// the very least.
+__attribute__((deprecated)) @class B; // expected-error {{prefix attribute must be followed by an interface, protocol, or implementation}}
 
 __attribute__((deprecated)) @interface A @end
 __attribute__((deprecated)) @protocol P0;
@@ -15,11 +17,10 @@ EXP class C2 {}; // expected-warning {{a
 EXP @interface I2 @end
 
 @implementation EXP I @end // expected-error-re {{postfix attributes are not allowed on Objective-C directives{{$}}}}
-// FIXME: Prefix attribute recovery skips until ';'
-EXP @implementation I2 @end; // expected-error {{prefix attribute must be followed by an interface or protocol}}
+EXP @implementation I2 @end
 
 @class EXP OC; // expected-error-re {{postfix attributes are not allowed on Objective-C directives{{$}}}}
-EXP @class OC2; // expected-error {{prefix attribute must be followed by an interface or protocol}}
+EXP @class OC2; // expected-error {{prefix attribute must be followed by an interface, protocol, or implementation}}
 
 @protocol EXP P @end // expected-error {{postfix attributes are not allowed on Objective-C directives, place them in front of '@protocol'}}
 EXP @protocol P2 @end

Added: cfe/trunk/test/Parser/objc-implementation-attrs.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-implementation-attrs.m?rev=358200&view=auto
==============================================================================
--- cfe/trunk/test/Parser/objc-implementation-attrs.m (added)
+++ cfe/trunk/test/Parser/objc-implementation-attrs.m Thu Apr 11 10:55:30 2019
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 -fsyntax-only -Wno-objc-root-class -verify %s
+
+ at interface I1 @end
+
+// expected-warning at +1 {{'always_inline' attribute only applies to functions}}
+__attribute__((always_inline))
+ at implementation I1 @end
+
+// expected-warning at +1 {{'always_inline' attribute only applies to functions}}
+__attribute__((always_inline))
+ at implementation I1 (MyCat) @end
+
+// expected-warning at +1 {{'always_inline' attribute only applies to functions}}
+__attribute__((always_inline))
+// expected-warning at +1 {{cannot find interface declaration for 'I2'}}
+ at implementation I2 @end
+
+// expected-error at +1 {{only applies to Objective-C interfaces}}
+__attribute__((objc_root_class))
+// expected-warning at +1 {{cannot find interface declaration for 'I3'}}
+ at implementation I3 @end
+
+#define AVAIL_ATTR __attribute__((availability(macos, introduced=1000)))
+
+typedef int AVAIL_ATTR unavail_int; // expected-note {{marked as being introduced}}
+
+ at interface I4 @end // expected-note {{annotate}}
+ at implementation I4 {
+  unavail_int x; // expected-warning {{'unavail_int' is only available on macOS 1000 or newer}}
+}
+ at end
+
+ at interface I5 @end
+
+#pragma clang attribute push (AVAIL_ATTR, apply_to=objc_implementation)
+ at implementation I5 {
+  unavail_int x;
+}
+ at end
+#pragma clang attribute pop
+
+I5 *i5;
+
+// expected-error at +1 2 {{'annotate' attribute takes one argument}}
+#pragma clang attribute push (__attribute__((annotate)), apply_to=objc_implementation)
+ at interface I6 @end
+ at interface I6 (MyCat) @end
+ at interface I6 () @end
+
+ at implementation I6 @end // expected-note {{when applied to this declaration}}
+ at implementation I6 (MyCat) @end // expected-note {{when applied to this declaration}}
+
+#pragma clang attribute pop

Modified: cfe/trunk/test/Parser/placeholder-recovery.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/placeholder-recovery.m?rev=358200&r1=358199&r2=358200&view=diff
==============================================================================
--- cfe/trunk/test/Parser/placeholder-recovery.m (original)
+++ cfe/trunk/test/Parser/placeholder-recovery.m Thu Apr 11 10:55:30 2019
@@ -11,4 +11,4 @@
 // bogus 'archaic' warnings with bad location info.
 <#methods#> // expected-error {{editor placeholder in source file}}
 
- at end // expected-error {{prefix attribute must be followed by an interface or protocol}} expected-error {{missing '@end'}}
+ at end // expected-error {{prefix attribute must be followed by an interface, protocol, or implementation}} expected-error {{missing '@end'}}

Modified: cfe/trunk/test/Sema/pragma-attribute-strict-subjects.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/pragma-attribute-strict-subjects.c?rev=358200&r1=358199&r2=358200&view=diff
==============================================================================
--- cfe/trunk/test/Sema/pragma-attribute-strict-subjects.c (original)
+++ cfe/trunk/test/Sema/pragma-attribute-strict-subjects.c Thu Apr 11 10:55:30 2019
@@ -56,7 +56,8 @@
 #pragma clang attribute pop
 
 #pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = any(enum_constant, function, record(unless(is_union)), variable, variable(is_parameter)))
-// expected-error at -1 {{attribute 'abi_tag' can't be applied to 'variable(is_parameter)', and 'enum_constant'}}
+// FIXME: comma in this diagnostic is wrong.
+// expected-error at -2 {{attribute 'abi_tag' can't be applied to 'enum_constant', and 'variable(is_parameter)'}}
 #pragma clang attribute pop
 
 #pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = any(function, record(unless(is_union)), enum))

Modified: cfe/trunk/test/SemaObjC/attr-objc-non-lazy.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-objc-non-lazy.m?rev=358200&r1=358199&r2=358200&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/attr-objc-non-lazy.m (original)
+++ cfe/trunk/test/SemaObjC/attr-objc-non-lazy.m Thu Apr 11 10:55:30 2019
@@ -29,6 +29,7 @@ void foo();
 
 @interface E
 @end
+// expected-error at +1 {{'objc_nonlazy_class' attribute only applies to Objective-C interfaces}}
 __attribute__((objc_nonlazy_class))
- at implementation E // expected-error {{prefix attribute must be followed by an interface or protocol}}
+ at implementation E
 @end

Modified: cfe/trunk/test/SemaObjC/objc-asm-attribute-neg-test.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/objc-asm-attribute-neg-test.m?rev=358200&r1=358199&r2=358200&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/objc-asm-attribute-neg-test.m (original)
+++ cfe/trunk/test/SemaObjC/objc-asm-attribute-neg-test.m Thu Apr 11 10:55:30 2019
@@ -19,7 +19,7 @@ __attribute__((objc_runtime_name("MySecr
   id MyIVAR;
 }
 __attribute__((objc_runtime_name("MySecretNamespace.Message")))
- at property int MyProperty; // expected-error {{prefix attribute must be followed by an interface or protocol}}}}
+ at property int MyProperty; // expected-error {{prefix attribute must be followed by an interface, protocol, or implementation}}}}
 
 - (int) getMyProperty __attribute__((objc_runtime_name("MySecretNamespace.Message"))); // expected-error {{'objc_runtime_name' attribute only applies to}}
 
@@ -28,7 +28,7 @@ __attribute__((objc_runtime_name("MySecr
 @end
 
 __attribute__((objc_runtime_name("MySecretNamespace.ForwardClass")))
- at class ForwardClass; // expected-error {{prefix attribute must be followed by an interface or protocol}}
+ at class ForwardClass; // expected-error {{prefix attribute must be followed by an interface, protocol, or implementation}}
 
 __attribute__((objc_runtime_name("MySecretNamespace.ForwardProtocol")))
 @protocol ForwardProtocol;
@@ -45,6 +45,6 @@ __attribute__((objc_runtime_name("MySecr
 
 @interface NoImpl @end
 
+// expected-error at +1 {{'objc_runtime_name' attribute only applies to Objective-C interfaces and Objective-C protocols}}
 __attribute__((objc_runtime_name("MySecretNamespace.Message")))
-// expected-error at +1 {{prefix attribute must be followed by an interface or protocol}}
 @implementation NoImpl @end




More information about the cfe-commits mailing list