r197625 - ObjectiveC. support "section" attribute on properties

Fariborz Jahanian fjahanian at apple.com
Wed Dec 18 15:09:58 PST 2013


Author: fjahanian
Date: Wed Dec 18 17:09:57 2013
New Revision: 197625

URL: http://llvm.org/viewvc/llvm-project?rev=197625&view=rev
Log:
ObjectiveC. support "section" attribute on properties
and methods. rdar://15450637

Added:
    cfe/trunk/test/CodeGenObjC/property-section-attribute.m
Modified:
    cfe/trunk/include/clang/Basic/Attr.td
    cfe/trunk/include/clang/Sema/AttributeList.h
    cfe/trunk/lib/Sema/SemaObjCProperty.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=197625&r1=197624&r2=197625&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Dec 18 17:09:57 2013
@@ -818,8 +818,9 @@ def InitPriority : InheritableAttr {
 def Section : InheritableAttr {
   let Spellings = [GNU<"section">, CXX11<"gnu", "section">];
   let Args = [StringArgument<"Name">];
-  let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
-                             "ExpectedFunctionOrGlobalVar">;
+  let Subjects = SubjectList<[Function, GlobalVar, 
+                              ObjCMethod, ObjCProperty], ErrorDiag,
+                             "ExpectedFunctionGlobalVarMethodOrProperty">;
 }
 
 def Sentinel : InheritableAttr {

Modified: cfe/trunk/include/clang/Sema/AttributeList.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=197625&r1=197624&r2=197625&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/AttributeList.h (original)
+++ cfe/trunk/include/clang/Sema/AttributeList.h Wed Dec 18 17:09:57 2013
@@ -912,7 +912,7 @@ enum AttributeDeclKind {
   ExpectedObjCInterfaceDeclInitMethod,
   ExpectedFunctionVariableOrClass,
   ExpectedObjectiveCProtocol,
-  ExpectedFunctionOrGlobalVar
+  ExpectedFunctionGlobalVarMethodOrProperty
 };
 
 }  // end namespace clang

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=197625&r1=197624&r2=197625&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Wed Dec 18 17:09:57 2013
@@ -1934,6 +1934,10 @@ void Sema::ProcessPropertyDecl(ObjCPrope
     if (property->hasAttr<ObjCReturnsInnerPointerAttr>())
       GetterMethod->addAttr(
         ::new (Context) ObjCReturnsInnerPointerAttr(Loc, Context));
+    
+    if (const SectionAttr *SA = property->getAttr<SectionAttr>())
+      GetterMethod->addAttr(::new (Context) SectionAttr(Loc,
+                                                        Context, SA->getName()));
 
     if (getLangOpts().ObjCAutoRefCount)
       CheckARCMethodDecl(GetterMethod);
@@ -1984,7 +1988,9 @@ void Sema::ProcessPropertyDecl(ObjCPrope
       // and the real context should be the same.
       if (lexicalDC)
         SetterMethod->setLexicalDeclContext(lexicalDC);
-
+      if (const SectionAttr *SA = property->getAttr<SectionAttr>())
+        SetterMethod->addAttr(::new (Context) SectionAttr(Loc,
+                                                          Context, SA->getName()));
       // It's possible for the user to have set a very odd custom
       // setter selector that causes it to have a method family.
       if (getLangOpts().ObjCAutoRefCount)

Added: cfe/trunk/test/CodeGenObjC/property-section-attribute.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/property-section-attribute.m?rev=197625&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/property-section-attribute.m (added)
+++ cfe/trunk/test/CodeGenObjC/property-section-attribute.m Wed Dec 18 17:09:57 2013
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// rdar://15450637.
+
+ at interface NSObject @end
+
+ at interface Foo : NSObject
+ at property int p __attribute__((section("__TEXT,foo")));
+ at end
+
+ at implementation Foo @end
+
+// CHECK: define internal i32 @"\01-[Foo p]"({{.*}} section "__TEXT,foo" {
+// CHECK: define internal void @"\01-[Foo setP:]"({{.*}} section "__TEXT,foo" {





More information about the cfe-commits mailing list