[PATCH] D26411: Simplify getLocation() function.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 8 12:39:56 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286287: Simplify getLocation() function. (authored by ruiu).
Changed prior to commit:
https://reviews.llvm.org/D26411?vs=77235&id=77241#toc
Repository:
rL LLVM
https://reviews.llvm.org/D26411
Files:
lld/trunk/ELF/Relocations.cpp
lld/trunk/ELF/Relocations.h
lld/trunk/ELF/SymbolTable.cpp
Index: lld/trunk/ELF/Relocations.cpp
===================================================================
--- lld/trunk/ELF/Relocations.cpp
+++ lld/trunk/ELF/Relocations.cpp
@@ -539,20 +539,20 @@
}
template <class ELFT>
-std::string getLocation(SymbolBody *Sym, InputSectionBase<ELFT> &S,
- typename ELFT::uint Offset) {
+std::string getLocation(InputSectionBase<ELFT> &S, typename ELFT::uint Offset) {
ObjectFile<ELFT> *File = S.getFile();
// First check if we can get desired values from debugging information.
std::string LineInfo = File->getLineInfo(&S, Offset);
if (!LineInfo.empty())
return LineInfo;
- // If don't have STT_FILE typed symbol in object file then
- // use object file name.
+ // File->SourceFile contains STT_FILE symbol contents which is a
+ // filename. Compilers usually create STT_FILE symbols. If it's
+ // missing, we use an actual filename.
std::string SrcFile = File->SourceFile;
if (SrcFile.empty())
- SrcFile = Sym && Sym->File ? getFilename(Sym->File) : getFilename(File);
+ SrcFile = getFilename(File);
// Find a symbol at a given location.
DefinedRegular<ELFT> *Encl = getSymbolAt(&S, Offset);
@@ -576,7 +576,7 @@
Config->UnresolvedSymbols != UnresolvedPolicy::NoUndef)
return;
- std::string Msg = getLocation(&Sym, S, Offset) + ": undefined symbol '" +
+ std::string Msg = getLocation(S, Offset) + ": undefined symbol '" +
maybeDemangle(Sym.getName()) + "'";
if (Config->UnresolvedSymbols == UnresolvedPolicy::Warn)
@@ -854,17 +854,13 @@
template void createThunks<ELF64BE>(InputSectionBase<ELF64BE> &,
const ELF64BE::Shdr &);
-template std::string getLocation<ELF32LE>(SymbolBody *Sym,
- InputSectionBase<ELF32LE> &S,
+template std::string getLocation<ELF32LE>(InputSectionBase<ELF32LE> &S,
uint32_t Offset);
-template std::string getLocation<ELF32BE>(SymbolBody *Sym,
- InputSectionBase<ELF32BE> &S,
+template std::string getLocation<ELF32BE>(InputSectionBase<ELF32BE> &S,
uint32_t Offset);
-template std::string getLocation<ELF64LE>(SymbolBody *Sym,
- InputSectionBase<ELF64LE> &S,
+template std::string getLocation<ELF64LE>(InputSectionBase<ELF64LE> &S,
uint64_t Offset);
-template std::string getLocation<ELF64BE>(SymbolBody *Sym,
- InputSectionBase<ELF64BE> &S,
+template std::string getLocation<ELF64BE>(InputSectionBase<ELF64BE> &S,
uint64_t Offset);
}
}
Index: lld/trunk/ELF/Relocations.h
===================================================================
--- lld/trunk/ELF/Relocations.h
+++ lld/trunk/ELF/Relocations.h
@@ -88,8 +88,7 @@
void createThunks(InputSectionBase<ELFT> &, const typename ELFT::Shdr &);
template <class ELFT>
-std::string getLocation(SymbolBody *Sym, InputSectionBase<ELFT> &S,
- typename ELFT::uint Offset);
+std::string getLocation(InputSectionBase<ELFT> &S, typename ELFT::uint Offset);
template <class ELFT>
static inline typename ELFT::uint getAddend(const typename ELFT::Rel &Rel) {
Index: lld/trunk/ELF/SymbolTable.cpp
===================================================================
--- lld/trunk/ELF/SymbolTable.cpp
+++ lld/trunk/ELF/SymbolTable.cpp
@@ -386,8 +386,8 @@
return;
}
- std::string OldLoc = getLocation(Existing, *D->Section, D->Value);
- std::string NewLoc = getLocation(nullptr, *ErrSec, ErrOffset);
+ std::string OldLoc = getLocation(*D->Section, D->Value);
+ std::string NewLoc = getLocation(*ErrSec, ErrOffset);
print(NewLoc + ": duplicate symbol '" + maybeDemangle(Existing->getName()) +
"'");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26411.77241.patch
Type: text/x-patch
Size: 3945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161108/2b777c4e/attachment.bin>
More information about the llvm-commits
mailing list