[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 16:40:27 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG25e2e92297e2: [ADT] Fix SmallVector unused template instantiation on 32-bit systems. (authored by browneee).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79214/new/

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.261391.patch
Type: text/x-patch
Size: 975 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200430/be1b4ee0/attachment.bin>


More information about the llvm-commits mailing list