summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclObjC.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-03-29 21:51:48 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-03-29 21:51:48 +0000
commitbd8cd3ed85c8b2b88c336b65f6f5d4b8effc37e7 (patch)
treebf1ca9b0946a8317b9de23db813eb687b19cd891 /clang/lib/AST/DeclObjC.cpp
parent828f4d4b9fa9d525b7fab146ed8dbb011a8681fe (diff)
downloadbcm5719-llvm-bd8cd3ed85c8b2b88c336b65f6f5d4b8effc37e7.tar.gz
bcm5719-llvm-bd8cd3ed85c8b2b88c336b65f6f5d4b8effc37e7.zip
When looking for overridden ObjC methods, don't ignore 'hidden' ones.
When using modules we should not ignore overridden methods from categories that are hidden because the module is not visible. This will give more consistent results (when imports change) and it's more correct since the methods are indeed overridden even if they are not "visible" for lookup purposes. rdar://13350796 llvm-svn: 178374
Diffstat (limited to 'clang/lib/AST/DeclObjC.cpp')
-rw-r--r--clang/lib/AST/DeclObjC.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index 50bf121af38..5f5ba52947d 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -65,12 +65,13 @@ ObjCContainerDecl::getIvarDecl(IdentifierInfo *Id) const {
// Get the local instance/class method declared in this interface.
ObjCMethodDecl *
-ObjCContainerDecl::getMethod(Selector Sel, bool isInstance) const {
+ObjCContainerDecl::getMethod(Selector Sel, bool isInstance,
+ bool AllowHidden) const {
// If this context is a hidden protocol definition, don't find any
// methods there.
if (const ObjCProtocolDecl *Proto = dyn_cast<ObjCProtocolDecl>(this)) {
if (const ObjCProtocolDecl *Def = Proto->getDefinition())
- if (Def->isHidden())
+ if (Def->isHidden() && !AllowHidden)
return 0;
}
@@ -854,7 +855,8 @@ static void CollectOverriddenMethodsRecurse(const ObjCContainerDecl *Container,
if (MovedToSuper)
if (ObjCMethodDecl *
Overridden = Container->getMethod(Method->getSelector(),
- Method->isInstanceMethod()))
+ Method->isInstanceMethod(),
+ /*AllowHidden=*/true))
if (Method != Overridden) {
// We found an override at this category; there is no need to look
// into its protocols.
@@ -872,7 +874,8 @@ static void CollectOverriddenMethodsRecurse(const ObjCContainerDecl *Container,
// Check whether we have a matching method at this level.
if (const ObjCMethodDecl *
Overridden = Container->getMethod(Method->getSelector(),
- Method->isInstanceMethod()))
+ Method->isInstanceMethod(),
+ /*AllowHidden=*/true))
if (Method != Overridden) {
// We found an override at this level; there is no need to look
// into other protocols or categories.
@@ -894,9 +897,9 @@ static void CollectOverriddenMethodsRecurse(const ObjCContainerDecl *Container,
P != PEnd; ++P)
CollectOverriddenMethodsRecurse(*P, Method, Methods, MovedToSuper);
- for (ObjCInterfaceDecl::visible_categories_iterator
- Cat = Interface->visible_categories_begin(),
- CatEnd = Interface->visible_categories_end();
+ for (ObjCInterfaceDecl::known_categories_iterator
+ Cat = Interface->known_categories_begin(),
+ CatEnd = Interface->known_categories_end();
Cat != CatEnd; ++Cat) {
CollectOverriddenMethodsRecurse(*Cat, Method, Methods,
MovedToSuper);
@@ -931,7 +934,8 @@ static void collectOverriddenMethodsSlow(const ObjCMethodDecl *Method,
// Start searching for overridden methods using the method from the
// interface as starting point.
if (const ObjCMethodDecl *IFaceMeth = ID->getMethod(Method->getSelector(),
- Method->isInstanceMethod()))
+ Method->isInstanceMethod(),
+ /*AllowHidden=*/true))
Method = IFaceMeth;
CollectOverriddenMethods(ID, Method, overridden);
@@ -943,7 +947,8 @@ static void collectOverriddenMethodsSlow(const ObjCMethodDecl *Method,
// Start searching for overridden methods using the method from the
// interface as starting point.
if (const ObjCMethodDecl *IFaceMeth = ID->getMethod(Method->getSelector(),
- Method->isInstanceMethod()))
+ Method->isInstanceMethod(),
+ /*AllowHidden=*/true))
Method = IFaceMeth;
CollectOverriddenMethods(ID, Method, overridden);
@@ -962,9 +967,9 @@ static void collectOnCategoriesAfterLocation(SourceLocation Loc,
if (!Class)
return;
- for (ObjCInterfaceDecl::visible_categories_iterator
- Cat = Class->visible_categories_begin(),
- CatEnd = Class->visible_categories_end();
+ for (ObjCInterfaceDecl::known_categories_iterator
+ Cat = Class->known_categories_begin(),
+ CatEnd = Class->known_categories_end();
Cat != CatEnd; ++Cat) {
if (SM.isBeforeInTranslationUnit(Loc, Cat->getLocation()))
CollectOverriddenMethodsRecurse(*Cat, Method, Methods, true);
OpenPOWER on IntegriCloud