[cfe-commits] r71617 - in /cfe/trunk: clang.xcodeproj/project.pbxproj lib/CodeGen/CGBlocks.cpp

Chris Lattner sabre at nondot.org
Tue May 12 19:50:57 PDT 2009


Author: lattner
Date: Tue May 12 21:50:56 2009
New Revision: 71617

URL: http://llvm.org/viewvc/llvm-project?rev=71617&view=rev
Log:
Fix rdar://6880259 - invalid function name in block call (__NSConcreteGlobalBlock2)
by using the appropriate CGM interface instead of directly creating a global.

Modified:
    cfe/trunk/clang.xcodeproj/project.pbxproj
    cfe/trunk/lib/CodeGen/CGBlocks.cpp

Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=71617&r1=71616&r2=71617&view=diff

==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Tue May 12 21:50:56 2009
@@ -1231,8 +1231,8 @@
 				9063F2290F9E911F002F7251 /* SourceManagerInternals.h */,
 				DE46BF270AE0A82D00CC047C /* TargetInfo.h */,
 				9063F22A0F9E911F002F7251 /* TemplateKinds.h */,
-				DED7D7370A524295003AD0FB /* TokenKinds.def */,
 				DED7D7380A524295003AD0FB /* TokenKinds.h */,
+				DED7D7370A524295003AD0FB /* TokenKinds.def */,
 				DEB089EE0F12F1D900522C07 /* TypeTraits.h */,
 			);
 			name = Basic;

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=71617&r1=71616&r2=71617&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Tue May 12 21:50:56 2009
@@ -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 @@
 }
 
 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 @@
 
 /// 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();
 }
 





More information about the cfe-commits mailing list