aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGObjCGNU.cpp
diff options
context:
space:
mode:
authorDavid Chisnall <csdavec@swan.ac.uk>2011-06-30 10:14:37 +0000
committerDavid Chisnall <csdavec@swan.ac.uk>2011-06-30 10:14:37 +0000
commitd3fc7296ae95353173bae25ee4dd3ecf4d6dced1 (patch)
tree499e1e4c06a59e25eade2a5a1638f47dc58c4315 /lib/CodeGen/CGObjCGNU.cpp
parentbfbdcd861a4364bfc21a9e5047bdbd56812d6693 (diff)
Add support for weakly imported classes (GNU runtime).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134140 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGObjCGNU.cpp')
-rw-r--r--lib/CodeGen/CGObjCGNU.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp
index 81a3ffacbd..0f53cd668f 100644
--- a/lib/CodeGen/CGObjCGNU.cpp
+++ b/lib/CodeGen/CGObjCGNU.cpp
@@ -393,7 +393,8 @@ private:
/// is no class of the matching name.
void EmitClassRef(const std::string &className);
/// Emits a pointer to the named class
- llvm::Value *GetClassNamed(CGBuilderTy &Builder, const std::string &Name);
+ llvm::Value *GetClassNamed(CGBuilderTy &Builder, const std::string &Name,
+ bool isWeak);
protected:
/// Looks up the method for sending a message to the specified object. This
/// mechanism differs between the GCC and GNU runtimes, so this method must be
@@ -776,7 +777,8 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion,
}
llvm::Value *CGObjCGNU::GetClassNamed(CGBuilderTy &Builder,
- const std::string &Name) {
+ const std::string &Name,
+ bool isWeak) {
llvm::Value *ClassName = CGM.GetAddrOfConstantCString(Name);
// With the incompatible ABI, this will need to be replaced with a direct
// reference to the class symbol. For the compatible nonfragile ABI we are
@@ -785,7 +787,8 @@ llvm::Value *CGObjCGNU::GetClassNamed(CGBuilderTy &Builder,
//
// Libobjc2 contains an LLVM pass that replaces calls to objc_lookup_class
// with memoized versions or with static references if it's safe to do so.
- EmitClassRef(Name);
+ if (!isWeak)
+ EmitClassRef(Name);
ClassName = Builder.CreateStructGEP(ClassName, 0);
llvm::Constant *ClassLookupFn =
@@ -798,10 +801,10 @@ llvm::Value *CGObjCGNU::GetClassNamed(CGBuilderTy &Builder,
// techniques can modify the name -> class mapping.
llvm::Value *CGObjCGNU::GetClass(CGBuilderTy &Builder,
const ObjCInterfaceDecl *OID) {
- return GetClassNamed(Builder, OID->getNameAsString());
+ return GetClassNamed(Builder, OID->getNameAsString(), OID->isWeakImported());
}
llvm::Value *CGObjCGNU::EmitNSAutoreleasePoolClassRef(CGBuilderTy &Builder) {
- return GetClassNamed(Builder, "NSAutoreleasePool");
+ return GetClassNamed(Builder, "NSAutoreleasePool", false);
}
llvm::Value *CGObjCGNU::GetSelector(CGBuilderTy &Builder, Selector Sel,