From a58f92f09d217ca978621ccfa630474f919345a3 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Tue, 11 Oct 2016 21:18:20 +0000 Subject: [PATCH] Module: for ObjectiveC, be consistent when checking hidden decls. In MatchAllMethodDeclarations, when checking a hidden decl, be sure to allow hidden when searching for methods. rdar://28699972 llvm-svn: 283943 --- clang/lib/Sema/SemaDeclObjC.cpp | 4 ++-- .../Headers/FakeUnavailableObjCFramework.h | 7 +++++++ .../Modules/module.modulemap | 5 +++++ clang/test/Modules/Inputs/objc-hidden/System/X.h | 5 +++++ clang/test/Modules/Inputs/objc-hidden/System/module.map | 4 ++++ clang/test/Modules/objc-hidden.m | 11 +++++++++++ 6 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 clang/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h create mode 100644 clang/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap create mode 100644 clang/test/Modules/Inputs/objc-hidden/System/X.h create mode 100644 clang/test/Modules/Inputs/objc-hidden/System/module.map create mode 100644 clang/test/Modules/objc-hidden.m diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index a1d795d..79cdd6e 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -2741,7 +2741,7 @@ void Sema::MatchAllMethodDeclarations(const SelectorSet &InsMap, } else { ObjCMethodDecl *ImpMethodDecl = IMPDecl->getInstanceMethod(I->getSelector()); - assert(CDecl->getInstanceMethod(I->getSelector()) && + assert(CDecl->getInstanceMethod(I->getSelector(), true/*AllowHidden*/) && "Expected to find the method through lookup as well"); // ImpMethodDecl may be null as in a @dynamic property. if (ImpMethodDecl) { @@ -2767,7 +2767,7 @@ void Sema::MatchAllMethodDeclarations(const SelectorSet &InsMap, } else { ObjCMethodDecl *ImpMethodDecl = IMPDecl->getClassMethod(I->getSelector()); - assert(CDecl->getClassMethod(I->getSelector()) && + assert(CDecl->getClassMethod(I->getSelector(), true/*AllowHidden*/) && "Expected to find the method through lookup as well"); // ImpMethodDecl may be null as in a @dynamic property. if (ImpMethodDecl) { diff --git a/clang/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h b/clang/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h new file mode 100644 index 0000000..2ae08a3 --- /dev/null +++ b/clang/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h @@ -0,0 +1,7 @@ +#include + +__attribute__((availability(macosx,introduced=1066.0))) __attribute__((availability(ios,introduced=1066.0))) +@interface UnavailableObjCClass : NSObject +- (void)someMethod; +@end + diff --git a/clang/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap b/clang/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap new file mode 100644 index 0000000..e99c0fa --- /dev/null +++ b/clang/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap @@ -0,0 +1,5 @@ +framework module FakeUnavailableObjCFramework { + umbrella header "FakeUnavailableObjCFramework.h" + // Do not export to test hidden decls. + // export * +} diff --git a/clang/test/Modules/Inputs/objc-hidden/System/X.h b/clang/test/Modules/Inputs/objc-hidden/System/X.h new file mode 100644 index 0000000..c86cc58 --- /dev/null +++ b/clang/test/Modules/Inputs/objc-hidden/System/X.h @@ -0,0 +1,5 @@ +@protocol NSObject +@property (readonly) int hash; +@end +@interface NSObject +@end diff --git a/clang/test/Modules/Inputs/objc-hidden/System/module.map b/clang/test/Modules/Inputs/objc-hidden/System/module.map new file mode 100644 index 0000000..8fe4c92 --- /dev/null +++ b/clang/test/Modules/Inputs/objc-hidden/System/module.map @@ -0,0 +1,4 @@ +module X { + header "X.h" + export * +} diff --git a/clang/test/Modules/objc-hidden.m b/clang/test/Modules/objc-hidden.m new file mode 100644 index 0000000..6e40e0d --- /dev/null +++ b/clang/test/Modules/objc-hidden.m @@ -0,0 +1,11 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fsyntax-only -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/objc-hidden/System -F %S/Inputs/objc-hidden -verify -x objective-c %s +// expected-no-diagnostics + +// Make sure we don't crash with hidden decls. +@import FakeUnavailableObjCFramework; + +@implementation UnavailableObjCClass +- (void)someMethod { } +@end + -- 2.7.4