From 351ca3328452abed9de58723fbcbe42e7a08903e Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Tue, 5 Jan 2010 01:46:14 +0000 Subject: [PATCH] Use StringRef.startswith(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92671 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 57 ++++++++++++----------------------- 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index a65a385f440..61536d5d32f 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1032,6 +1032,16 @@ DIE *DwarfDebug::constructEnumTypeDIE(DIEnumerator *ETy) { 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. DIE *DwarfDebug::createGlobalVariableDIE(const DIGlobalVariable &GV) { // 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()); StringRef LinkageName = GV.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); + if (!LinkageName.empty()) addString(GVDie, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string, - LinkageName); - } + getRealLinkageName(LinkageName)); + addType(GVDie, GV.getType()); if (!GV.isLocalToUnit()) 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()); StringRef LinkageName = SP.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); + if (!LinkageName.empty()) addString(SPDie, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string, - LinkageName); - } + getRealLinkageName(LinkageName)); + addSourceLine(SPDie, &SP); // 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)); StringPool.insert(InlinedSP.getName()); - StringRef LinkageName = 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); + StringPool.insert(getRealLinkageName(InlinedSP.getLinkageName())); + DILocation DL(Scope->getInlinedAt()); addUInt(ScopeDIE, dwarf::DW_AT_call_file, 0, ModuleCU->getID()); addUInt(ScopeDIE, dwarf::DW_AT_call_line, 0, DL.getLineNumber()); @@ -2937,17 +2927,10 @@ void DwarfDebug::emitDebugInlineInfo() { if (LName.empty()) Asm->EmitString(Name); - 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); + else EmitSectionOffset("string", "section_str", - StringPool.idFor(LName), false, true); + StringPool.idFor(getRealLinkageName(LName)), false, true); - } Asm->EOL("MIPS linkage name"); EmitSectionOffset("string", "section_str", StringPool.idFor(Name), false, true); -- 2.11.0