diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-11-20 21:05:04 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-11-20 21:05:04 +0000 |
commit | 5c247db14566f4668efb63cf5184e62dd40039b5 (patch) | |
tree | ff898b20d53409b6c28e78bbf5c56cb87a752410 /lib/CodeGen/CGDecl.cpp | |
parent | 1c2e9332fa69727425a3a2b912e36e2ab62083f8 (diff) |
CodeGen: allow __asm renaming on static local variables.
Fixes PR4777.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145015 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-rw-r--r-- | lib/CodeGen/CGDecl.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index d685847155..3935df02df 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +#include "CGCXXABI.h" #include "CGDebugInfo.h" #include "CodeGenFunction.h" #include "CodeGenModule.h" @@ -177,7 +178,14 @@ CodeGenFunction::CreateStaticVarDecl(const VarDecl &D, QualType Ty = D.getType(); assert(Ty->isConstantSizeType() && "VLAs can't be static"); - std::string Name = GetStaticDeclName(*this, D, Separator); + // Use the label if the variable is renamed with the asm-label extension. + std::string Name; + if (D.hasAttr<AsmLabelAttr>()) { + llvm::raw_string_ostream Out(Name); + CGM.getCXXABI().getMangleContext().mangleName(&D, Out); + } else { + Name = GetStaticDeclName(*this, D, Separator); + } llvm::Type *LTy = CGM.getTypes().ConvertTypeForMem(Ty); llvm::GlobalVariable *GV = |