[ELF] - Eliminate ObjFile<ELFT>::getLineInfo. NFC.
authorGeorge Rimar <grimar@accesssoftek.com>
Mon, 16 Jul 2018 15:29:35 +0000 (15:29 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Mon, 16 Jul 2018 15:29:35 +0000 (15:29 +0000)
Flow is the same, but a bit shorter after this change.

llvm-svn: 337183

lld/ELF/InputFiles.cpp
lld/ELF/InputFiles.h
lld/ELF/InputSection.cpp

index f679b5f..d5e6daa 100644 (file)
@@ -221,14 +221,6 @@ Optional<DILineInfo> ObjFile<ELFT>::getDILineInfo(InputSectionBase *S,
   return None;
 }
 
-// Returns source line information for a given offset using DWARF debug info.
-template <class ELFT>
-std::string ObjFile<ELFT>::getLineInfo(InputSectionBase *S, uint64_t Offset) {
-  if (Optional<DILineInfo> Info = getDILineInfo(S, Offset))
-    return Info->FileName + ":" + std::to_string(Info->Line);
-  return "";
-}
-
 // Returns "<internal>", "foo.a(bar.o)" or "baz.o".
 std::string lld::toString(const InputFile *F) {
   if (!F)
index 4f5df6f..c4ec5c9 100644 (file)
@@ -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<llvm::DILineInfo> getDILineInfo(InputSectionBase *, uint64_t);
   llvm::Optional<std::pair<std::string, unsigned>> getVariableLoc(StringRef Name);
 
index 1f963e6..1c98fbd 100644 (file)
@@ -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<ELFT>()->getLineInfo(this, Offset);
-  if (!LineInfo.empty())
-    return LineInfo;
+  if (Optional<DILineInfo> Info = getFile<ELFT>()->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.