[llvm] 4363ea6 - Fix C2975 error under MSVC

Nathan James via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 25 03:04:18 PDT 2020


Author: Nathan James
Date: 2020-07-25T11:03:59+01:00
New Revision: 4363ea61058b67fd6a86e3798ff7c21631270c6d

URL: https://github.com/llvm/llvm-project/commit/4363ea61058b67fd6a86e3798ff7c21631270c6d
DIFF: https://github.com/llvm/llvm-project/commit/4363ea61058b67fd6a86e3798ff7c21631270c6d.diff

LOG: Fix C2975 error under MSVC

Apparantly a constexpr value isn't a compile time constant under certain versions of MSVC.

Added: 
    

Modified: 
    llvm/unittests/ADT/STLExtrasTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/unittests/ADT/STLExtrasTest.cpp b/llvm/unittests/ADT/STLExtrasTest.cpp
index f09d5986c009..aaef46a2cf05 100644
--- a/llvm/unittests/ADT/STLExtrasTest.cpp
+++ b/llvm/unittests/ADT/STLExtrasTest.cpp
@@ -587,37 +587,35 @@ TEST(STLExtras, MoveRange) {
     }
     operator bool() const { return A; }
   };
-
-  constexpr size_t ItemCount = 4;
-  SmallVector<Foo, ItemCount> V1, V2, V3, V4;
+  SmallVector<Foo, 4U> V1, V2, V3, V4;
   auto HasVal = [](const Foo &Item) { return static_cast<bool>(Item); };
   auto Build = [&] {
-    SmallVector<Foo, ItemCount> Foos;
-    Foos.resize(ItemCount);
+    SmallVector<Foo, 4U> Foos;
+    Foos.resize(4U);
     return Foos;
   };
 
-  V1.resize(ItemCount);
+  V1.resize(4U);
   EXPECT_TRUE(llvm::all_of(V1, HasVal));
 
   llvm::move(V1, std::back_inserter(V2));
 
   // Ensure input container is same size, but its contents were moved out.
-  EXPECT_EQ(V1.size(), ItemCount);
+  EXPECT_EQ(V1.size(), 4U);
   EXPECT_TRUE(llvm::none_of(V1, HasVal));
 
   // Ensure output container has the contents of the input container.
-  EXPECT_EQ(V2.size(), ItemCount);
+  EXPECT_EQ(V2.size(), 4U);
   EXPECT_TRUE(llvm::all_of(V2, HasVal));
 
   llvm::move(std::move(V2), std::back_inserter(V3));
 
   EXPECT_TRUE(llvm::none_of(V2, HasVal));
-  EXPECT_EQ(V3.size(), ItemCount);
+  EXPECT_EQ(V3.size(), 4U);
   EXPECT_TRUE(llvm::all_of(V3, HasVal));
 
   llvm::move(Build(), std::back_inserter(V4));
-  EXPECT_EQ(V4.size(), ItemCount);
+  EXPECT_EQ(V4.size(), 4U);
   EXPECT_TRUE(llvm::all_of(V4, HasVal));
 }
 } // namespace


        


More information about the llvm-commits mailing list