From 8d480594cf8405215f888454141dce10f84748db 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. llvm-svn: 54645 --- clang/lib/CodeGen/CodeGenModule.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index b3e721308d65..347f4d24f903 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/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