[llvm] 8f9d28d - [ADT] Use std::nullopt instead of llvm::None in OptionalTest.cpp

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 8 10:07:50 PST 2022


Author: Kazu Hirata
Date: 2022-12-08T10:07:43-08:00
New Revision: 8f9d28d8597766b4b8cc52857832ca4d905bcf3e

URL: https://github.com/llvm/llvm-project/commit/8f9d28d8597766b4b8cc52857832ca4d905bcf3e
DIFF: https://github.com/llvm/llvm-project/commit/8f9d28d8597766b4b8cc52857832ca4d905bcf3e.diff

LOG: [ADT] Use std::nullopt instead of llvm::None in OptionalTest.cpp

This patch updates the test for the streaming operator for
llvm::Optional to use std::nullopt instead of llvm::None.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Differential Revision: https://reviews.llvm.org/D139513

Added: 
    

Modified: 
    llvm/unittests/ADT/OptionalTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/unittests/ADT/OptionalTest.cpp b/llvm/unittests/ADT/OptionalTest.cpp
index 76e99bbf323bb..a98d230fd346b 100644
--- a/llvm/unittests/ADT/OptionalTest.cpp
+++ b/llvm/unittests/ADT/OptionalTest.cpp
@@ -813,16 +813,17 @@ struct Comparable {
 TEST(OptionalTest, UseInUnitTests) {
   // Test that we invoke the streaming operators when pretty-printing values in
   // EXPECT macros.
-  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(llvm::None, ComparableAndStreamable::get()),
-                          "Expected equality of these values:\n"
-                          "  llvm::None\n"
-                          "    Which is: None\n"
-                          "  ComparableAndStreamable::get()\n"
-                          "    Which is: ComparableAndStreamable");
+  EXPECT_NONFATAL_FAILURE(
+      EXPECT_EQ(std::nullopt, ComparableAndStreamable::get()),
+      "Expected equality of these values:\n"
+      "  std::nullopt\n"
+      "    Which is: None\n"
+      "  ComparableAndStreamable::get()\n"
+      "    Which is: ComparableAndStreamable");
 
   // Test that it is still possible to compare objects which do not have a
   // custom streaming operator.
-  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(llvm::None, Comparable::get()), "object");
+  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(std::nullopt, Comparable::get()), "object");
 }
 
 TEST(OptionalTest, HashValue) {


        


More information about the llvm-commits mailing list