summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/CodeGen/CGObjCMac.cpp4
-rw-r--r--clang/test/CodeGenObjC/category-super-class-meth.m19
2 files changed, 22 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index dd722458aaa..03f7b78ec8e 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -1244,7 +1244,9 @@ llvm::Constant *CGObjCMac::EmitMetaClassRef(const ObjCInterfaceDecl *ID) {
// if know when we entered/exitted an implementation block.
// Check for an existing forward reference.
- if (llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name)) {
+ // Previously, metaclass with internal linkage may have been defined.
+ // pass 'true' as 2nd argument so it is returned.
+ if (llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name, true)) {
assert(GV->getType()->getElementType() == ObjCTypes.ClassTy &&
"Forward metaclass reference has incorrect type.");
return GV;
diff --git a/clang/test/CodeGenObjC/category-super-class-meth.m b/clang/test/CodeGenObjC/category-super-class-meth.m
new file mode 100644
index 00000000000..4385b56774e
--- /dev/null
+++ b/clang/test/CodeGenObjC/category-super-class-meth.m
@@ -0,0 +1,19 @@
+// RUN: clang -emit-llvm -o %t %s
+
+@interface BASE
++ (int) BaseMeth;
+@end
+
+@interface Child: BASE
+@end
+
+@interface Child (Categ)
++ (int) flushCache2;
+@end
+
+@implementation Child @end
+
+@implementation Child (Categ)
++ (int) flushCache2 { [super BaseMeth]; }
+@end
+
OpenPOWER on IntegriCloud