diff options
author | Chris Lattner <sabre@nondot.org> | 2009-05-13 02:50:56 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-05-13 02:50:56 +0000 |
commit | 46813bbfa2f3dae9671067f3ef175f1b7514debb (patch) | |
tree | 60a3eb2017feca81354e6c4b07f6b5163ff7e11f /clang/lib | |
parent | f160b5f9e1dac84896494398e49dbbd4d76d1860 (diff) | |
download | bcm5719-llvm-46813bbfa2f3dae9671067f3ef175f1b7514debb.tar.gz bcm5719-llvm-46813bbfa2f3dae9671067f3ef175f1b7514debb.zip |
Fix rdar://6880259 - invalid function name in block call (__NSConcreteGlobalBlock2)
by using the appropriate CGM interface instead of directly creating a global.
llvm-svn: 71617
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGBlocks.cpp | 39 |
1 files changed, 7 insertions, 32 deletions
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index dee9d4ce9b4..b04a942e4fa 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -16,16 +16,10 @@ #include "clang/AST/DeclObjC.h" #include "llvm/Module.h" #include "llvm/Target/TargetData.h" - #include <algorithm> - using namespace clang; using namespace CodeGen; -// Temporary code to enable testing of __block variables -// #include "clang/Frontend/CompileOptions.h" -#include "llvm/Support/CommandLine.h" - llvm::Constant *CodeGenFunction:: BuildDescriptorBlockDecl(bool BlockHasCopyDispose, uint64_t Size, const llvm::StructType* Ty, @@ -63,34 +57,16 @@ BuildDescriptorBlockDecl(bool BlockHasCopyDispose, uint64_t Size, } llvm::Constant *BlockModule::getNSConcreteGlobalBlock() { - if (NSConcreteGlobalBlock) - return NSConcreteGlobalBlock; - - // FIXME: We should have a CodeGenModule::AddRuntimeVariable that does the - // same thing as CreateRuntimeFunction if there's already a variable with the - // same name. - NSConcreteGlobalBlock - = new llvm::GlobalVariable(PtrToInt8Ty, false, - llvm::GlobalValue::ExternalLinkage, - 0, "_NSConcreteGlobalBlock", - &getModule()); - + if (NSConcreteGlobalBlock == 0) + NSConcreteGlobalBlock = CGM.CreateRuntimeVariable(PtrToInt8Ty, + "_NSConcreteGlobalBlock"); return NSConcreteGlobalBlock; } llvm::Constant *BlockModule::getNSConcreteStackBlock() { - if (NSConcreteStackBlock) - return NSConcreteStackBlock; - - // FIXME: We should have a CodeGenModule::AddRuntimeVariable that does the - // same thing as CreateRuntimeFunction if there's already a variable with the - // same name. - NSConcreteStackBlock - = new llvm::GlobalVariable(PtrToInt8Ty, false, - llvm::GlobalValue::ExternalLinkage, - 0, "_NSConcreteStackBlock", - &getModule()); - + if (NSConcreteStackBlock == 0) + NSConcreteStackBlock = CGM.CreateRuntimeVariable(PtrToInt8Ty, + "_NSConcreteStackBlock"); return NSConcreteStackBlock; } @@ -115,8 +91,7 @@ static void CollectBlockDeclRefInfo(const Stmt *S, /// CanBlockBeGlobal - Given a BlockInfo struct, determines if a block can be /// declared as a global variable instead of on the stack. -static bool CanBlockBeGlobal(const CodeGenFunction::BlockInfo &Info) -{ +static bool CanBlockBeGlobal(const CodeGenFunction::BlockInfo &Info) { return Info.ByRefDeclRefs.empty() && Info.ByCopyDeclRefs.empty(); } |