[libc-commits] [libc] b5516be - [libc] Use std::optional instead of llvm::Optional (NFC)

Kazu Hirata via libc-commits libc-commits at lists.llvm.org
Sat Jan 14 20:52:06 PST 2023


Author: Kazu Hirata
Date: 2023-01-14T20:52:00-08:00
New Revision: b5516be05654ecdd4fd7e317b1f21f940c1a967b

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

LOG: [libc] Use std::optional instead of llvm::Optional (NFC)

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

Added: 
    

Modified: 
    libc/benchmarks/LibcBenchmark.h
    libc/benchmarks/LibcBenchmarkTest.cpp
    libc/benchmarks/automemcpy/include/automemcpy/FunctionDescriptor.h
    libc/benchmarks/automemcpy/include/automemcpy/RandomFunctionGenerator.h
    libc/benchmarks/automemcpy/lib/CodeGen.cpp

Removed: 
    


################################################################################
diff  --git a/libc/benchmarks/LibcBenchmark.h b/libc/benchmarks/LibcBenchmark.h
index 3b0a05136ca59..0a0b40f924e68 100644
--- a/libc/benchmarks/LibcBenchmark.h
+++ b/libc/benchmarks/LibcBenchmark.h
@@ -32,12 +32,12 @@
 
 #include "benchmark/benchmark.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include <array>
 #include <chrono>
 #include <cmath>
 #include <cstdint>
+#include <optional>
 
 namespace llvm {
 namespace libc_benchmarks {

diff  --git a/libc/benchmarks/LibcBenchmarkTest.cpp b/libc/benchmarks/LibcBenchmarkTest.cpp
index 41a246281efb5..f3d4564797416 100644
--- a/libc/benchmarks/LibcBenchmarkTest.cpp
+++ b/libc/benchmarks/LibcBenchmarkTest.cpp
@@ -8,12 +8,12 @@
 
 #include "LibcBenchmark.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include <chrono>
 #include <limits>
+#include <optional>
 #include <queue>
 #include <vector>
 

diff  --git a/libc/benchmarks/automemcpy/include/automemcpy/FunctionDescriptor.h b/libc/benchmarks/automemcpy/include/automemcpy/FunctionDescriptor.h
index 444d856a7260d..65477d9d72a0e 100644
--- a/libc/benchmarks/automemcpy/include/automemcpy/FunctionDescriptor.h
+++ b/libc/benchmarks/automemcpy/include/automemcpy/FunctionDescriptor.h
@@ -13,8 +13,8 @@
 #include <cstddef>
 #include <llvm/ADT/ArrayRef.h>
 #include <llvm/ADT/Hashing.h>
-#include <llvm/ADT/Optional.h>
 #include <llvm/ADT/StringRef.h>
+#include <optional>
 #include <tuple>
 
 namespace llvm {
@@ -127,11 +127,11 @@ enum class FunctionType {
 // every detail but is enough to uniquely identify the implementation.
 struct FunctionDescriptor {
   FunctionType Type;
-  Optional<Contiguous> Contiguous;
-  Optional<Overlap> Overlap;
-  Optional<Loop> Loop;
-  Optional<AlignedLoop> AlignedLoop;
-  Optional<Accelerator> Accelerator;
+  std::optional<Contiguous> Contiguous;
+  std::optional<Overlap> Overlap;
+  std::optional<Loop> Loop;
+  std::optional<AlignedLoop> AlignedLoop;
+  std::optional<Accelerator> Accelerator;
   ElementTypeClass ElementClass;
 
   COMPARABLE_AND_HASHABLE(FunctionDescriptor, Type, Contiguous, Overlap, Loop,

diff  --git a/libc/benchmarks/automemcpy/include/automemcpy/RandomFunctionGenerator.h b/libc/benchmarks/automemcpy/include/automemcpy/RandomFunctionGenerator.h
index 4fa1c3843a0ef..28756e8f86c0e 100644
--- a/libc/benchmarks/automemcpy/include/automemcpy/RandomFunctionGenerator.h
+++ b/libc/benchmarks/automemcpy/include/automemcpy/RandomFunctionGenerator.h
@@ -13,8 +13,8 @@
 #include <cstddef>
 #include <cstdint>
 #include <llvm/ADT/ArrayRef.h>
-#include <llvm/ADT/Optional.h>
 #include <llvm/ADT/StringRef.h>
+#include <optional>
 #include <vector>
 #include <z3++.h>
 
@@ -27,7 +27,7 @@ struct RandomFunctionGenerator {
   RandomFunctionGenerator();
 
   // Get the next valid FunctionDescriptor or std::nullopt.
-  Optional<FunctionDescriptor> next();
+  std::optional<FunctionDescriptor> next();
 
 private:
   // Returns an expression where `Variable` is forced to be one of the `Values`.

diff  --git a/libc/benchmarks/automemcpy/lib/CodeGen.cpp b/libc/benchmarks/automemcpy/lib/CodeGen.cpp
index d0a356d11265c..f4060099bddd7 100644
--- a/libc/benchmarks/automemcpy/lib/CodeGen.cpp
+++ b/libc/benchmarks/automemcpy/lib/CodeGen.cpp
@@ -37,11 +37,11 @@
 
 #include "automemcpy/CodeGen.h"
 #include <cassert>
-#include <llvm/ADT/Optional.h>
 #include <llvm/ADT/STLExtras.h>
 #include <llvm/ADT/StringSet.h>
 #include <llvm/Support/FormatVariadic.h>
 #include <llvm/Support/raw_ostream.h>
+#include <optional>
 #include <set>
 
 namespace llvm {
@@ -126,9 +126,9 @@ struct FunctionImplementation {
   StringRef Name;
   std::vector<Individual> Individuals;
   std::vector<Overlap> Overlaps;
-  Optional<Loop> Loop;
-  Optional<AlignedLoop> AlignedLoop;
-  Optional<Accelerator> Accelerator;
+  std::optional<Loop> Loop;
+  std::optional<AlignedLoop> AlignedLoop;
+  std::optional<Accelerator> Accelerator;
   ElementTypeClass ElementClass;
 };
 


        


More information about the libc-commits mailing list