From 208ff5e8a073de2a5d15cbe03cab8a4c0d935e28 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Mon, 11 Aug 2008 18:12:00 +0000 Subject: Change CodeGenModule to only create ObjC runtime for ObjC files - Changed CodeGenModule::getObjCRuntime to return reference. - Added CodeGenModule::hasObjCRuntime predicate. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54645 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'lib/CodeGen/CodeGenModule.cpp') diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index b3e721308d..347f4d24f9 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -33,13 +33,16 @@ CodeGenModule::CodeGenModule(ASTContext &C, const LangOptions &LO, Diagnostic &diags, bool GenerateDebugInfo, bool UseMacObjCRuntime) : Context(C), Features(LO), TheModule(M), TheTargetData(TD), Diags(diags), - Types(C, M, TD), MemCpyFn(0), MemMoveFn(0), MemSetFn(0), + Types(C, M, TD), Runtime(0), MemCpyFn(0), MemMoveFn(0), MemSetFn(0), CFConstantStringClassRef(0) { - //TODO: Make this selectable at runtime - if (UseMacObjCRuntime) { - Runtime = CreateMacObjCRuntime(*this); - } else { - Runtime = CreateGNUObjCRuntime(*this); + + if (Features.ObjC1) { + // TODO: Make this selectable at runtime + if (UseMacObjCRuntime) { + Runtime = CreateMacObjCRuntime(*this); + } else { + Runtime = CreateGNUObjCRuntime(*this); + } } // If debug info generation is enabled, create the CGDebugInfo object. @@ -53,9 +56,9 @@ CodeGenModule::~CodeGenModule() { void CodeGenModule::Release() { EmitStatics(); - llvm::Function *ObjCInitFunction = Runtime->ModuleInitFunction(); - if (ObjCInitFunction) - AddGlobalCtor(ObjCInitFunction); + if (Runtime) + if (llvm::Function *ObjCInitFunction = Runtime->ModuleInitFunction()) + AddGlobalCtor(ObjCInitFunction); EmitCtorList(GlobalCtors, "llvm.global_ctors"); EmitCtorList(GlobalDtors, "llvm.global_dtors"); EmitAnnotations(); -- cgit v1.2.3-70-g09d2