From: George Rimar Date: Mon, 16 Jul 2018 15:29:35 +0000 (+0000) Subject: [ELF] - Eliminate ObjFile::getLineInfo. NFC. X-Git-Tag: llvmorg-7.0.0-rc1~1341 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=484aabc81897b724441afc5a030ebb41c9684a72;p=platform%2Fupstream%2Fllvm.git [ELF] - Eliminate ObjFile::getLineInfo. NFC. Flow is the same, but a bit shorter after this change. llvm-svn: 337183 --- diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index f679b5f..d5e6daa 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -221,14 +221,6 @@ Optional ObjFile::getDILineInfo(InputSectionBase *S, return None; } -// Returns source line information for a given offset using DWARF debug info. -template -std::string ObjFile::getLineInfo(InputSectionBase *S, uint64_t Offset) { - if (Optional Info = getDILineInfo(S, Offset)) - return Info->FileName + ":" + std::to_string(Info->Line); - return ""; -} - // Returns "", "foo.a(bar.o)" or "baz.o". std::string lld::toString(const InputFile *F) { if (!F) diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h index 4f5df6f..c4ec5c9 100644 --- a/lld/ELF/InputFiles.h +++ b/lld/ELF/InputFiles.h @@ -194,9 +194,6 @@ public: return getSymbol(SymIndex); } - // Returns source line information for a given offset. - // If no information is available, returns "". - std::string getLineInfo(InputSectionBase *S, uint64_t Offset); llvm::Optional getDILineInfo(InputSectionBase *, uint64_t); llvm::Optional> getVariableLoc(StringRef Name); diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 1f963e6..1c98fbd 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -221,9 +221,8 @@ std::string InputSectionBase::getLocation(uint64_t Offset) { .str(); // First check if we can get desired values from debugging information. - std::string LineInfo = getFile()->getLineInfo(this, Offset); - if (!LineInfo.empty()) - return LineInfo; + if (Optional Info = getFile()->getDILineInfo(this, Offset)) + return Info->FileName + ":" + std::to_string(Info->Line); // File->SourceFile contains STT_FILE symbol that contains a // source file name. If it's missing, we use an object file name.