[lld-macho][nfc] Sanity check on template type
Differential Revision: https://reviews.llvm.org/D114044
GitOrigin-RevId: 34d15eaced9db0a9769a7cdb1899ffa534b6ed44
diff --git a/MachO/InputFiles.cpp b/MachO/InputFiles.cpp
index 9fb6cd3..7bc4322 100644
--- a/MachO/InputFiles.cpp
+++ b/MachO/InputFiles.cpp
@@ -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 @@
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; }));