[PATCH] D114044: [lld-macho][nfc] Sanity check on template type
Vy Nguyen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 16 16:58:34 PST 2021
oontvoo created this revision.
oontvoo added a reviewer: smeenai.
Herald added a project: lld-macho.
Herald added a reviewer: lld-macho.
oontvoo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D114044
Files:
lld/MachO/InputFiles.cpp
Index: lld/MachO/InputFiles.cpp
===================================================================
--- lld/MachO/InputFiles.cpp
+++ lld/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; }));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114044.387791.patch
Type: text/x-patch
Size: 860 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211117/8c860aed/attachment.bin>
More information about the llvm-commits
mailing list