summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2013-12-18 23:09:57 +0000
committerFariborz Jahanian <fjahanian@apple.com>2013-12-18 23:09:57 +0000
commitcb8c7da2664ddc26b062d5034f345eabd29a773b (patch)
tree85350cc1444629fbfffa4cf27f1aa4209840b548 /clang
parent83a71c076c5a966b65a85c688df4b62b185c1771 (diff)
downloadbcm5719-llvm-cb8c7da2664ddc26b062d5034f345eabd29a773b.tar.gz
bcm5719-llvm-cb8c7da2664ddc26b062d5034f345eabd29a773b.zip
ObjectiveC. support "section" attribute on properties
and methods. rdar://15450637 llvm-svn: 197625
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Basic/Attr.td5
-rw-r--r--clang/include/clang/Sema/AttributeList.h2
-rw-r--r--clang/lib/Sema/SemaObjCProperty.cpp8
-rw-r--r--clang/test/CodeGenObjC/property-section-attribute.m13
4 files changed, 24 insertions, 4 deletions
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index 38cf10bee3d..f8e4eeb2224 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -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 {
diff --git a/clang/include/clang/Sema/AttributeList.h b/clang/include/clang/Sema/AttributeList.h
index f31435546ae..8d9fee4195d 100644
--- a/clang/include/clang/Sema/AttributeList.h
+++ b/clang/include/clang/Sema/AttributeList.h
@@ -912,7 +912,7 @@ enum AttributeDeclKind {
ExpectedObjCInterfaceDeclInitMethod,
ExpectedFunctionVariableOrClass,
ExpectedObjectiveCProtocol,
- ExpectedFunctionOrGlobalVar
+ ExpectedFunctionGlobalVarMethodOrProperty
};
} // end namespace clang
diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp
index 93791d7667c..61e58c4bef7 100644
--- a/clang/lib/Sema/SemaObjCProperty.cpp
+++ b/clang/lib/Sema/SemaObjCProperty.cpp
@@ -1934,6 +1934,10 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
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(ObjCPropertyDecl *property,
// 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)
diff --git a/clang/test/CodeGenObjC/property-section-attribute.m b/clang/test/CodeGenObjC/property-section-attribute.m
new file mode 100644
index 00000000000..5ba064c6126
--- /dev/null
+++ b/clang/test/CodeGenObjC/property-section-attribute.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// rdar://15450637.
+
+@interface NSObject @end
+
+@interface Foo : NSObject
+@property int p __attribute__((section("__TEXT,foo")));
+@end
+
+@implementation Foo @end
+
+// CHECK: define internal i32 @"\01-[Foo p]"({{.*}} section "__TEXT,foo" {
+// CHECK: define internal void @"\01-[Foo setP:]"({{.*}} section "__TEXT,foo" {
OpenPOWER on IntegriCloud