[PATCH] D135799: libcxxabi [PR58117][NFC]: Open code lower bound
Nathan Sidwell via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 20 06:11:34 PDT 2022
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc7ca21436d62: libcxxabi [PR58117][NFC]: Open code lower bound (authored by urnathan).
Herald added a project: libc++abi.
Herald added a subscriber: libcxx-commits.
Herald added 1 blocking reviewer(s): libc++abi.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D135799/new/
https://reviews.llvm.org/D135799
Files:
libcxxabi/src/demangle/ItaniumDemangle.h
llvm/include/llvm/Demangle/ItaniumDemangle.h
Index: llvm/include/llvm/Demangle/ItaniumDemangle.h
===================================================================
--- llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -3032,14 +3032,21 @@
if (numLeft() < 2)
return nullptr;
- auto Op = std::lower_bound(
- &Ops[0], &Ops[NumOps], First,
- [](const OperatorInfo &Op_, const char *Enc_) { return Op_ < Enc_; });
- if (Op == &Ops[NumOps] || *Op != First)
+ // We can't use lower_bound as that can link to symbols in the C++ library,
+ // and this must remain independant of that.
+ size_t lower = 0u, upper = NumOps - 1; // Inclusive bounds.
+ while (upper != lower) {
+ size_t middle = (upper + lower) / 2;
+ if (Ops[middle] < First)
+ lower = middle + 1;
+ else
+ upper = middle;
+ }
+ if (Ops[lower] != First)
return nullptr;
First += 2;
- return Op;
+ return &Ops[lower];
}
// <operator-name> ::= See parseOperatorEncoding()
Index: libcxxabi/src/demangle/ItaniumDemangle.h
===================================================================
--- libcxxabi/src/demangle/ItaniumDemangle.h
+++ libcxxabi/src/demangle/ItaniumDemangle.h
@@ -3032,14 +3032,21 @@
if (numLeft() < 2)
return nullptr;
- auto Op = std::lower_bound(
- &Ops[0], &Ops[NumOps], First,
- [](const OperatorInfo &Op_, const char *Enc_) { return Op_ < Enc_; });
- if (Op == &Ops[NumOps] || *Op != First)
+ // We can't use lower_bound as that can link to symbols in the C++ library,
+ // and this must remain independant of that.
+ size_t lower = 0u, upper = NumOps - 1; // Inclusive bounds.
+ while (upper != lower) {
+ size_t middle = (upper + lower) / 2;
+ if (Ops[middle] < First)
+ lower = middle + 1;
+ else
+ upper = middle;
+ }
+ if (Ops[lower] != First)
return nullptr;
First += 2;
- return Op;
+ return &Ops[lower];
}
// <operator-name> ::= See parseOperatorEncoding()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135799.469204.patch
Type: text/x-patch
Size: 1974 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221020/947c125a/attachment.bin>
More information about the llvm-commits
mailing list