[lld-macho][nfc] Sanity check on template type

Differential Revision: https://reviews.llvm.org/D114044
This commit is contained in:
Vy Nguyen 2021-11-16 19:57:24 -05:00
parent 209dadf269
commit 34d15eaced
1 changed files with 5 additions and 0 deletions

View File

@ -70,6 +70,8 @@
#include "llvm/TextAPI/Architecture.h"
#include "llvm/TextAPI/InterfaceFile.h"
#include <type_traits>
using namespace llvm;
using namespace llvm::MachO;
using namespace llvm::support::endian;
@ -358,6 +360,9 @@ void ObjFile::parseSections(ArrayRef<SectionHeader> sectionHeaders) {
template <class T>
static InputSection *findContainingSubsection(Subsections &subsections,
T *offset) {
static_assert(std::is_same<uint64_t, T>::value ||
std::is_same<uint32_t, T>::value,
"unexpected type for offset");
auto it = std::prev(llvm::upper_bound(
subsections, *offset,
[](uint64_t value, Subsection subsec) { return value < subsec.offset; }));