[libc] Use std::optional instead of llvm::Optional (NFC)
authorKazu Hirata <kazu@google.com>
Sun, 15 Jan 2023 04:52:00 +0000 (20:52 -0800)
committerKazu Hirata <kazu@google.com>
Sun, 15 Jan 2023 04:52:00 +0000 (20:52 -0800)
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

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

index 3b0a051..0a0b40f 100644 (file)
 
 #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 {
index 41a2462..f3d4564 100644 (file)
@@ -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>
 
index 444d856..65477d9 100644 (file)
@@ -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,
index 4fa1c38..28756e8 100644 (file)
@@ -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`.
index d0a356d..f406009 100644 (file)
 
 #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;
 };