summaryrefslogtreecommitdiffstats
path: root/clang/test/Modules/objc-categories.m
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2013-01-16 23:00:23 +0000
committerDouglas Gregor <dgregor@apple.com>2013-01-16 23:00:23 +0000
commit048fbfa302717d66b549f77469500408ca682117 (patch)
tree9580828c2e508b6ad946be861a75c9c62cab5da8 /clang/test/Modules/objc-categories.m
parente8baf33712857bdb1deeb6100087cc3bc93861ea (diff)
downloadbcm5719-llvm-048fbfa302717d66b549f77469500408ca682117.tar.gz
bcm5719-llvm-048fbfa302717d66b549f77469500408ca682117.zip
Rework the traversal of Objective-C categories and extensions to
consider (sub)module visibility. The bulk of this change replaces myriad hand-rolled loops over the linked list of Objective-C categories/extensions attached to an interface declaration with loops using one of the four new category iterator kinds: visible_categories_iterator: Iterates over all visible categories and extensions, hiding any that have their "hidden" bit set. This is by far the most commonly used iterator. known_categories_iterator: Iterates over all categories and extensions, ignoring the "hidden" bit. This tends to be used for redeclaration-like traversals. visible_extensions_iterator: Iterates over all visible extensions, hiding any that have their "hidden" bit set. known_extensions_iterator: Iterates over all extensions, whether they are visible to normal name lookup or not. The effect of this change is that any uses of the visible_ iterators will respect module-import visibility. See the new tests for examples. Note that the old accessors for categories and extensions are gone; there are *Raw() forms for some of them, for those (few) areas of the compiler that have to manipulate the linked list of categories directly. This is generally discouraged. Part two of <rdar://problem/10634711>. llvm-svn: 172665
Diffstat (limited to 'clang/test/Modules/objc-categories.m')
-rw-r--r--clang/test/Modules/objc-categories.m31
1 files changed, 31 insertions, 0 deletions
diff --git a/clang/test/Modules/objc-categories.m b/clang/test/Modules/objc-categories.m
index f19dc7efcf0..05a66ca4ee5 100644
--- a/clang/test/Modules/objc-categories.m
+++ b/clang/test/Modules/objc-categories.m
@@ -39,3 +39,34 @@ void test(Foo *foo, LeftFoo *leftFoo) {
void test_other(Foo *foo) {
[foo other];
}
+
+// Make sure we don't see categories that should be hidden
+void test_hidden_all_errors(Foo *foo) {
+ [foo left_sub]; // expected-warning{{instance method '-left_sub' not found (return type defaults to 'id')}}
+ foo.right_sub_prop = foo; // expected-error{{property 'right_sub_prop' not found on object of type 'Foo *'}}
+ int i = foo->right_sub_ivar; // expected-error{{'Foo' does not have a member named 'right_sub_ivar'}}
+ id<P1> p1 = foo; // expected-warning{{initializing 'id<P1>' with an expression of incompatible type 'Foo *'}}
+ id<P2> p2 = foo; // expected-warning{{initializing 'id<P2>' with an expression of incompatible type 'Foo *'}}
+}
+
+@import category_left.sub;
+
+void test_hidden_right_errors(Foo *foo) {
+ // These are okay
+ [foo left_sub]; // okay
+ id<P1> p1 = foo;
+ // FIXME: these should fail
+ foo.right_sub_prop = foo; // expected-error{{property 'right_sub_prop' not found on object of type 'Foo *'}}
+ int i = foo->right_sub_ivar; // expected-error{{'Foo' does not have a member named 'right_sub_ivar'}}
+ id<P2> p2 = foo; // expected-warning{{initializing 'id<P2>' with an expression of incompatible type 'Foo *'}}
+}
+
+@import category_right.sub;
+
+void test_hidden_okay(Foo *foo) {
+ [foo left_sub];
+ foo.right_sub_prop = foo;
+ int i = foo->right_sub_ivar;
+ id<P1> p1 = foo;
+ id<P2> p2 = foo;
+}
OpenPOWER on IntegriCloud