From 6362803cfed99bc008b12b488d2c2a682df0cc2d Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 26 Jun 2012 16:06:38 +0000 Subject: block literal irgen: several improvements on naming block literal helper functions. All helper functions (global and locals) use block_invoke as their prefix. Local literal helper names are prefixed by their enclosing mangled function names. Blocks in non-local initializers (e.g. a global variable or a C++11 field) are prefixed by their mangled variable name. The descriminator number added to end of the name starts off with blank (for first block) and _ (for the N+2-th block). llvm-svn: 159206 --- clang/lib/CodeGen/CodeGenModule.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 8c1588b174e..8f769d90204 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -347,7 +347,8 @@ StringRef CodeGenModule::getMangledName(GlobalDecl GD) { else if (const CXXDestructorDecl *D = dyn_cast(ND)) getCXXABI().getMangleContext().mangleCXXDtor(D, GD.getDtorType(), Out); else if (const BlockDecl *BD = dyn_cast(ND)) - getCXXABI().getMangleContext().mangleBlock(BD, Out); + getCXXABI().getMangleContext().mangleBlock(BD, Out, + dyn_cast_or_null(initializedGlobalDecl.getDecl())); else getCXXABI().getMangleContext().mangleName(ND, Out); @@ -368,7 +369,8 @@ void CodeGenModule::getBlockMangledName(GlobalDecl GD, MangleBuffer &Buffer, const Decl *D = GD.getDecl(); llvm::raw_svector_ostream Out(Buffer.getBuffer()); if (D == 0) - MangleCtx.mangleGlobalBlock(BD, Out); + MangleCtx.mangleGlobalBlock(BD, + dyn_cast_or_null(initializedGlobalDecl.getDecl()), Out); else if (const CXXConstructorDecl *CD = dyn_cast(D)) MangleCtx.mangleCtorBlock(CD, GD.getCtorType(), BD, Out); else if (const CXXDestructorDecl *DD = dyn_cast(D)) @@ -1551,8 +1553,10 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { // FIXME: It does so in a global constructor, which is *not* what we // want. - if (!Init) + if (!Init) { + initializedGlobalDecl = GlobalDecl(D); Init = EmitConstantInit(*InitDecl); + } if (!Init) { QualType T = InitExpr->getType(); if (D->getType()->isReferenceType()) -- cgit v1.2.3