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 _<N> (for the N+2-th block). llvm-svn: 159206
This commit is contained in:
@@ -347,7 +347,8 @@ StringRef CodeGenModule::getMangledName(GlobalDecl GD) {
|
||||
else if (const CXXDestructorDecl *D = dyn_cast<CXXDestructorDecl>(ND))
|
||||
getCXXABI().getMangleContext().mangleCXXDtor(D, GD.getDtorType(), Out);
|
||||
else if (const BlockDecl *BD = dyn_cast<BlockDecl>(ND))
|
||||
getCXXABI().getMangleContext().mangleBlock(BD, Out);
|
||||
getCXXABI().getMangleContext().mangleBlock(BD, Out,
|
||||
dyn_cast_or_null<VarDecl>(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<VarDecl>(initializedGlobalDecl.getDecl()), Out);
|
||||
else if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(D))
|
||||
MangleCtx.mangleCtorBlock(CD, GD.getCtorType(), BD, Out);
|
||||
else if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(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())
|
||||
|
||||
Reference in New Issue
Block a user