mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-03 12:46:07 +00:00
Remove separator parameter from static local naming code
It was always set to ".", which was duplicated in a few places. llvm-svn: 214792
This commit is contained in:
parent
dd44a7fb0f
commit
fe5b4ed822
@ -146,8 +146,7 @@ void CodeGenFunction::EmitVarDecl(const VarDecl &D) {
|
|||||||
return EmitAutoVarDecl(D);
|
return EmitAutoVarDecl(D);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string GetStaticDeclName(CodeGenFunction &CGF, const VarDecl &D,
|
static std::string GetStaticDeclName(CodeGenFunction &CGF, const VarDecl &D) {
|
||||||
const char *Separator) {
|
|
||||||
CodeGenModule &CGM = CGF.CGM;
|
CodeGenModule &CGM = CGF.CGM;
|
||||||
|
|
||||||
if (CGF.getLangOpts().CPlusPlus)
|
if (CGF.getLangOpts().CPlusPlus)
|
||||||
@ -169,12 +168,11 @@ static std::string GetStaticDeclName(CodeGenFunction &CGF, const VarDecl &D,
|
|||||||
else
|
else
|
||||||
llvm_unreachable("Unknown context for static var decl");
|
llvm_unreachable("Unknown context for static var decl");
|
||||||
|
|
||||||
return ContextName.str() + Separator + D.getNameAsString();
|
return ContextName.str() + "." + D.getNameAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::Constant *
|
llvm::Constant *
|
||||||
CodeGenFunction::CreateStaticVarDecl(const VarDecl &D,
|
CodeGenFunction::CreateStaticVarDecl(const VarDecl &D,
|
||||||
const char *Separator,
|
|
||||||
llvm::GlobalValue::LinkageTypes Linkage) {
|
llvm::GlobalValue::LinkageTypes Linkage) {
|
||||||
QualType Ty = D.getType();
|
QualType Ty = D.getType();
|
||||||
assert(Ty->isConstantSizeType() && "VLAs can't be static");
|
assert(Ty->isConstantSizeType() && "VLAs can't be static");
|
||||||
@ -184,7 +182,7 @@ CodeGenFunction::CreateStaticVarDecl(const VarDecl &D,
|
|||||||
if (D.hasAttr<AsmLabelAttr>())
|
if (D.hasAttr<AsmLabelAttr>())
|
||||||
Name = CGM.getMangledName(&D);
|
Name = CGM.getMangledName(&D);
|
||||||
else
|
else
|
||||||
Name = GetStaticDeclName(*this, D, Separator);
|
Name = GetStaticDeclName(*this, D);
|
||||||
|
|
||||||
llvm::Type *LTy = CGM.getTypes().ConvertTypeForMem(Ty);
|
llvm::Type *LTy = CGM.getTypes().ConvertTypeForMem(Ty);
|
||||||
unsigned AddrSpace =
|
unsigned AddrSpace =
|
||||||
@ -302,7 +300,7 @@ void CodeGenFunction::EmitStaticVarDecl(const VarDecl &D,
|
|||||||
CGM.getStaticLocalDeclAddress(&D);
|
CGM.getStaticLocalDeclAddress(&D);
|
||||||
|
|
||||||
if (!addr)
|
if (!addr)
|
||||||
addr = CreateStaticVarDecl(D, ".", Linkage);
|
addr = CreateStaticVarDecl(D, Linkage);
|
||||||
|
|
||||||
// Store into LocalDeclMap before generating initializer to handle
|
// Store into LocalDeclMap before generating initializer to handle
|
||||||
// circular references.
|
// circular references.
|
||||||
@ -1129,7 +1127,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
|
|||||||
} else {
|
} else {
|
||||||
// Otherwise, create a temporary global with the initializer then
|
// Otherwise, create a temporary global with the initializer then
|
||||||
// memcpy from the global to the alloca.
|
// memcpy from the global to the alloca.
|
||||||
std::string Name = GetStaticDeclName(*this, D, ".");
|
std::string Name = GetStaticDeclName(*this, D);
|
||||||
llvm::GlobalVariable *GV =
|
llvm::GlobalVariable *GV =
|
||||||
new llvm::GlobalVariable(CGM.getModule(), constant->getType(), true,
|
new llvm::GlobalVariable(CGM.getModule(), constant->getType(), true,
|
||||||
llvm::GlobalValue::PrivateLinkage,
|
llvm::GlobalValue::PrivateLinkage,
|
||||||
|
@ -2425,7 +2425,6 @@ public:
|
|||||||
/// CreateStaticVarDecl - Create a zero-initialized LLVM global for
|
/// CreateStaticVarDecl - Create a zero-initialized LLVM global for
|
||||||
/// a static local variable.
|
/// a static local variable.
|
||||||
llvm::Constant *CreateStaticVarDecl(const VarDecl &D,
|
llvm::Constant *CreateStaticVarDecl(const VarDecl &D,
|
||||||
const char *Separator,
|
|
||||||
llvm::GlobalValue::LinkageTypes Linkage);
|
llvm::GlobalValue::LinkageTypes Linkage);
|
||||||
|
|
||||||
/// AddInitializerToStaticVarDecl - Add the initializer for 'D' to the
|
/// AddInitializerToStaticVarDecl - Add the initializer for 'D' to the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user