[ELF] --gdb-index: fix odd variable name cUs after r365730 and replace lower_bound...
authorFangrui Song <maskray@google.com>
Wed, 14 Aug 2019 12:56:30 +0000 (12:56 +0000)
committerFangrui Song <maskray@google.com>
Wed, 14 Aug 2019 12:56:30 +0000 (12:56 +0000)
llvm-svn: 368845

lld/ELF/SyntheticSections.cpp

index 817f1e1..e8500de 100644 (file)
@@ -2508,7 +2508,7 @@ readAddressAreas(DWARFContext &dwarf, InputSection *sec) {
 template <class ELFT>
 static std::vector<GdbIndexSection::NameAttrEntry>
 readPubNamesAndTypes(const LLDDwarfObj<ELFT> &obj,
-                     const std::vector<GdbIndexSection::CuEntry> &cUs) {
+                     const std::vector<GdbIndexSection::CuEntry> &cus) {
   const DWARFSection &pubNames = obj.getGnuPubnamesSection();
   const DWARFSection &pubTypes = obj.getGnuPubtypesSection();
 
@@ -2520,12 +2520,11 @@ readPubNamesAndTypes(const LLDDwarfObj<ELFT> &obj,
       // don't know how many compilation units precede this object to compute
       // cuIndex, we compute (kind << 24 | cuIndexInThisObject) instead, and add
       // the number of preceding compilation units later.
-      uint32_t i =
-          lower_bound(cUs, set.Offset,
-                      [](GdbIndexSection::CuEntry cu, uint32_t offset) {
-                        return cu.cuOffset < offset;
-                      }) -
-          cUs.begin();
+      uint32_t i = llvm::partition_point(cus,
+                                         [&](GdbIndexSection::CuEntry cu) {
+                                           return cu.cuOffset < set.Offset;
+                                         }) -
+                   cus.begin();
       for (const DWARFDebugPubTable::Entry &ent : set.Entries)
         ret.push_back({{ent.Name, computeGdbHash(ent.Name)},
                        (ent.Descriptor.toBits() << 24) | i});