Use StringRef.startswith().

llvm-svn: 92671
This commit is contained in:
Devang Patel 2010-01-05 01:46:14 +00:00
parent c976131fe9
commit 43ef34d2a5
1 changed files with 20 additions and 37 deletions

View File

@ -1032,6 +1032,16 @@ DIE *DwarfDebug::constructEnumTypeDIE(DIEnumerator *ETy) {
return Enumerator; return Enumerator;
} }
/// getRealLinkageName - If special LLVM prefix that is used to inform the asm
/// printer to not emit usual symbol prefix before the symbol name is used then
/// return linkage name after skipping this special LLVM prefix.
static StringRef getRealLinkageName(StringRef LinkageName) {
char One = '\1';
if (LinkageName.startswith(StringRef(&One, 1)))
return LinkageName.substr(1);
return LinkageName;
}
/// createGlobalVariableDIE - Create new DIE using GV. /// createGlobalVariableDIE - Create new DIE using GV.
DIE *DwarfDebug::createGlobalVariableDIE(const DIGlobalVariable &GV) { DIE *DwarfDebug::createGlobalVariableDIE(const DIGlobalVariable &GV) {
// If the global variable was optmized out then no need to create debug info // If the global variable was optmized out then no need to create debug info
@ -1044,16 +1054,10 @@ DIE *DwarfDebug::createGlobalVariableDIE(const DIGlobalVariable &GV) {
GV.getDisplayName()); GV.getDisplayName());
StringRef LinkageName = GV.getLinkageName(); StringRef LinkageName = GV.getLinkageName();
if (!LinkageName.empty()) { if (!LinkageName.empty())
// Skip special LLVM prefix that is used to inform the asm printer to not
// emit usual symbol prefix before the symbol name. This happens for
// Objective-C symbol names and symbol whose name is replaced using GCC's
// __asm__ attribute.
if (LinkageName[0] == 1)
LinkageName = LinkageName.substr(1);
addString(GVDie, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string, addString(GVDie, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string,
LinkageName); getRealLinkageName(LinkageName));
}
addType(GVDie, GV.getType()); addType(GVDie, GV.getType());
if (!GV.isLocalToUnit()) if (!GV.isLocalToUnit())
addUInt(GVDie, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1); addUInt(GVDie, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1);
@ -1130,16 +1134,10 @@ DIE *DwarfDebug::createSubprogramDIE(const DISubprogram &SP, bool MakeDecl) {
addString(SPDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, SP.getName()); addString(SPDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, SP.getName());
StringRef LinkageName = SP.getLinkageName(); StringRef LinkageName = SP.getLinkageName();
if (!LinkageName.empty()) { if (!LinkageName.empty())
// Skip special LLVM prefix that is used to inform the asm printer to not
// emit usual symbol prefix before the symbol name. This happens for
// Objective-C symbol names and symbol whose name is replaced using GCC's
// __asm__ attribute.
if (LinkageName[0] == 1)
LinkageName = LinkageName.substr(1);
addString(SPDie, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string, addString(SPDie, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string,
LinkageName); getRealLinkageName(LinkageName));
}
addSourceLine(SPDie, &SP); addSourceLine(SPDie, &SP);
// Add prototyped tag, if C or ObjC. // Add prototyped tag, if C or ObjC.
@ -1393,16 +1391,8 @@ DIE *DwarfDebug::constructInlinedScopeDIE(DbgScope *Scope) {
I->second.push_back(std::make_pair(StartID, ScopeDIE)); I->second.push_back(std::make_pair(StartID, ScopeDIE));
StringPool.insert(InlinedSP.getName()); StringPool.insert(InlinedSP.getName());
StringRef LinkageName = InlinedSP.getLinkageName(); StringPool.insert(getRealLinkageName(InlinedSP.getLinkageName()));
if (!LinkageName.empty()) {
// Skip special LLVM prefix that is used to inform the asm printer to not
// emit usual symbol prefix before the symbol name. This happens for
// Objective-C symbol names and symbol whose name is replaced using GCC's
// __asm__ attribute.
if (LinkageName[0] == 1)
LinkageName = LinkageName.substr(1);
}
StringPool.insert(LinkageName);
DILocation DL(Scope->getInlinedAt()); DILocation DL(Scope->getInlinedAt());
addUInt(ScopeDIE, dwarf::DW_AT_call_file, 0, ModuleCU->getID()); addUInt(ScopeDIE, dwarf::DW_AT_call_file, 0, ModuleCU->getID());
addUInt(ScopeDIE, dwarf::DW_AT_call_line, 0, DL.getLineNumber()); addUInt(ScopeDIE, dwarf::DW_AT_call_line, 0, DL.getLineNumber());
@ -2937,17 +2927,10 @@ void DwarfDebug::emitDebugInlineInfo() {
if (LName.empty()) if (LName.empty())
Asm->EmitString(Name); Asm->EmitString(Name);
else { else
// Skip special LLVM prefix that is used to inform the asm printer to not
// emit usual symbol prefix before the symbol name. This happens for
// Objective-C symbol names and symbol whose name is replaced using GCC's
// __asm__ attribute.
if (LName[0] == 1)
LName = LName.substr(1);
EmitSectionOffset("string", "section_str", EmitSectionOffset("string", "section_str",
StringPool.idFor(LName), false, true); StringPool.idFor(getRealLinkageName(LName)), false, true);
}
Asm->EOL("MIPS linkage name"); Asm->EOL("MIPS linkage name");
EmitSectionOffset("string", "section_str", EmitSectionOffset("string", "section_str",
StringPool.idFor(Name), false, true); StringPool.idFor(Name), false, true);