[OutputSection] Work around GCC not being able to deduce auto.

The build otherwise fails with:
[ 39%] Building CXX object
tools/lld/ELF/CMakeFiles/lldELF.dir/OutputSections.cpp.o
/export/gnu/import/git/llvm/tools/lld/ELF/OutputSections.cpp: In
member function ‘void
lld:🧝:GnuHashTableSection<ELFT>::addSymbols(std::vector<std::pair<lld:🧝:SymbolBody*,
long unsigned int> >&)’:
/export/gnu/import/git/llvm/tools/lld/ELF/OutputSections.cpp:585:8:
error: inconsistent deduction for ‘auto’: ‘auto’ and then
‘__gnu_cxx::__normal_iterator<std::pair<lld:🧝:SymbolBody*, long
unsigned int>*, std::vector<std::pair<lld:🧝:SymbolBody*, long
unsigned int> > >’

Reported by:  H. J. Liu

llvm-svn: 274518
This commit is contained in:
Davide Italiano 2016-07-04 19:49:55 +00:00
parent 991dfd7b07
commit b4b68b64fd
1 changed files with 10 additions and 5 deletions

View File

@ -576,13 +576,18 @@ void GnuHashTableSection<ELFT>::writeHashTable(uint8_t *Buf) {
template <class ELFT>
void GnuHashTableSection<ELFT>::addSymbols(
std::vector<std::pair<SymbolBody *, size_t>> &V) {
auto Mid = std::stable_partition(V.begin(), V.end(),
[](std::pair<SymbolBody *, size_t> &P) {
return P.first->isUndefined();
});
// Ideally this will just be 'auto' but GCC 6.1 is not able
// to deduce it correctly.
std::vector<std::pair<SymbolBody *, size_t>>::iterator Mid =
std::stable_partition(V.begin(), V.end(),
[](std::pair<SymbolBody *, size_t> &P) {
return P.first->isUndefined();
});
if (Mid == V.end())
return;
for (auto I = Mid, E = V.end(); I != E; ++I) {
for (std::vector<std::pair<SymbolBody *, size_t>>::iterator I = Mid,
E = V.end();
I != E; ++I) {
SymbolBody *B = I->first;
size_t StrOff = I->second;
Symbols.push_back({B, StrOff, hashGnu(B->getName())});