Skip to content

Commit 34d15ea

Browse files
committed
[lld-macho][nfc] Sanity check on template type
Differential Revision: https://reviews.llvm.org/D114044
1 parent 209dadf commit 34d15ea

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lld/MachO/InputFiles.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
#include "llvm/TextAPI/Architecture.h"
7171
#include "llvm/TextAPI/InterfaceFile.h"
7272

73+
#include <type_traits>
74+
7375
using namespace llvm;
7476
using namespace llvm::MachO;
7577
using namespace llvm::support::endian;
@@ -358,6 +360,9 @@ void ObjFile::parseSections(ArrayRef<SectionHeader> sectionHeaders) {
358360
template <class T>
359361
static InputSection *findContainingSubsection(Subsections &subsections,
360362
T *offset) {
363+
static_assert(std::is_same<uint64_t, T>::value ||
364+
std::is_same<uint32_t, T>::value,
365+
"unexpected type for offset");
361366
auto it = std::prev(llvm::upper_bound(
362367
subsections, *offset,
363368
[](uint64_t value, Subsection subsec) { return value < subsec.offset; }));

0 commit comments

Comments
 (0)