Do not directly use function names to construct new name for named metadata.

"llvm.dbg.lv.~A" is not a valid name.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106438 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2010-06-21 18:36:58 +00:00
parent c79e43aee3
commit 10de3bb4fd

View File

@ -1056,7 +1056,14 @@ DIVariable DIFactory::CreateVariable(unsigned Tag, DIDescriptor Context,
// to preserve variable info in such situation then stash it in a
// named mdnode.
DISubprogram Fn(getDISubprogram(Context));
const Twine FnLVName = Twine("llvm.dbg.lv.", Fn.getName());
StringRef FName = "fn";
if (Fn.getFunction())
FName = Fn.getFunction()->getName();
const Twine FnLVName = Twine("llvm.dbg.lv.", FName);
char One = '\1';
if (FName.startswith(StringRef(&One, 1)))
FName = FName.substr(1);
NamedMDNode *FnLocals = M.getNamedMetadataUsingTwine(FnLVName);
if (!FnLocals)
FnLocals = NamedMDNode::Create(VMContext, FnLVName, NULL, 0, &M);