[PATCH] D79214: [ADT] Fix SmallVector unused template instantiation on 32-bit systems.
Andrew via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 30 15:39:05 PDT 2020
browneee created this revision.
browneee added reviewers: dblaikie, dexonsmith, nikic.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
This was introduced in dda3c19a3618dce94 <https://reviews.llvm.org/rGdda3c19a3618dce9492687f8e880e7a73486ee98> aka D77621 <https://reviews.llvm.org/D77621>.
The unused template instantiation causes a warning on 32 bit systems
about truncating a uint64_t to 32-bit size_t.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D79214
Files:
llvm/lib/Support/SmallVector.cpp
Index: llvm/lib/Support/SmallVector.cpp
===================================================================
--- llvm/lib/Support/SmallVector.cpp
+++ llvm/lib/Support/SmallVector.cpp
@@ -78,4 +78,18 @@
}
template class llvm::SmallVectorBase<uint32_t>;
+
+// Disable the uint64_t instantiation for 32-bit builds.
+// Both uint32_t and uint64_t instantations are needed for 64-bit builds.
+// This instantiation will never be used in 32-bit builds, and will cause
+// warnings when sizeof(Size_T) > sizeof(size_t).
+#if SIZE_MAX > UINT32_MAX
template class llvm::SmallVectorBase<uint64_t>;
+
+// Assertions to ensure this #if stays in sync with SmallVectorSizeType.
+static_assert(sizeof(SmallVectorSizeType<char>) == sizeof(uint64_t),
+ "Expected SmallVectorBase<uint64_t> variant to be in use.");
+#else
+static_assert(sizeof(SmallVectorSizeType<char>) == sizeof(uint32_t),
+ "Expected SmallVectorBase<uint32_t> variant to be in use.");
+#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79214.261378.patch
Type: text/x-patch
Size: 975 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200430/770a1d49/attachment.bin>
More information about the llvm-commits
mailing list