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

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

llvm-svn: 106438
This commit is contained in:
Devang Patel 2010-06-21 18:36:58 +00:00
parent 29a894dd64
commit e80de80270
1 changed files with 8 additions and 1 deletions

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 // to preserve variable info in such situation then stash it in a
// named mdnode. // named mdnode.
DISubprogram Fn(getDISubprogram(Context)); 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); NamedMDNode *FnLocals = M.getNamedMetadataUsingTwine(FnLVName);
if (!FnLocals) if (!FnLocals)
FnLocals = NamedMDNode::Create(VMContext, FnLVName, NULL, 0, &M); FnLocals = NamedMDNode::Create(VMContext, FnLVName, NULL, 0, &M);