[clang] 5c9013e - Use std::optional instead of llvm::Optional (NFC)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 28 00:45:26 PST 2023


Author: Kazu Hirata
Date: 2023-01-28T00:45:19-08:00
New Revision: 5c9013e2664141d3b4071c37b3cbb8cd09a008d8

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

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

Added: 
    

Modified: 
    clang/lib/Analysis/UnsafeBufferUsage.cpp
    clang/unittests/Analysis/FlowSensitive/TestingSupport.h
    mlir/include/mlir/Interfaces/Utils/InferIntRangeCommon.h
    mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
    mlir/lib/Dialect/Arith/IR/InferIntRangeInterfaceImpls.cpp
    mlir/lib/Dialect/Index/IR/InferIntRangeInterfaceImpls.cpp
    mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 2f1417487967d..54e3fb17efe45 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -615,7 +615,7 @@ getFixIts(FixableGadgetSets &FixablesForUnsafeVars, const Strategy &S) {
     bool ImpossibleToFix = false;
     llvm::SmallVector<FixItHint, 16> FixItsForVD;
     for (const auto &F : Fixables) {
-      llvm::Optional<FixItList> Fixits = F->getFixits(S);
+      std::optional<FixItList> Fixits = F->getFixits(S);
       if (!Fixits) {
         ImpossibleToFix = true;
         break;

diff  --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
index b40bcbf76ad06..bc089f141850a 100644
--- a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -262,7 +262,7 @@ checkDataflow(AnalysisInputs<AnalysisT> AI,
 
     // If successful, the dataflow analysis returns a mapping from block IDs to
     // the post-analysis states for the CFG blocks that have been evaluated.
-    llvm::Expected<std::vector<llvm::Optional<TypeErasedDataflowAnalysisState>>>
+    llvm::Expected<std::vector<std::optional<TypeErasedDataflowAnalysisState>>>
         MaybeBlockStates = runTypeErasedDataflowAnalysis(
             CFCtx, Analysis, InitEnv, TypeErasedPostVisitCFG);
     if (!MaybeBlockStates) return MaybeBlockStates.takeError();

diff  --git a/mlir/include/mlir/Interfaces/Utils/InferIntRangeCommon.h b/mlir/include/mlir/Interfaces/Utils/InferIntRangeCommon.h
index 7ee059cf342ce..97c97c23ba82a 100644
--- a/mlir/include/mlir/Interfaces/Utils/InferIntRangeCommon.h
+++ b/mlir/include/mlir/Interfaces/Utils/InferIntRangeCommon.h
@@ -16,6 +16,7 @@
 
 #include "mlir/Interfaces/InferIntRangeInterface.h"
 #include "llvm/ADT/ArrayRef.h"
+#include <optional>
 
 namespace mlir {
 namespace intrange {
@@ -117,8 +118,9 @@ enum class CmpPredicate : uint64_t {
 /// Returns a boolean value if `pred` is statically true or false for
 /// anypossible inputs falling within `lhs` and `rhs`, and std::nullopt if the
 /// value of the predicate cannot be determined.
-Optional<bool> evaluatePred(CmpPredicate pred, const ConstantIntRanges &lhs,
-                            const ConstantIntRanges &rhs);
+std::optional<bool> evaluatePred(CmpPredicate pred,
+                                 const ConstantIntRanges &lhs,
+                                 const ConstantIntRanges &rhs);
 
 } // namespace intrange
 } // namespace mlir

diff  --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
index a80c024ceb248..08ea2cae4cd7c 100644
--- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
+++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
@@ -33,6 +33,7 @@
 #include "../GPUCommon/GPUOpsLowering.h"
 #include "../GPUCommon/IndexIntrinsicsOpLowering.h"
 #include "../GPUCommon/OpToFuncCallLowering.h"
+#include <optional>
 
 namespace mlir {
 #define GEN_PASS_DEF_CONVERTGPUOPSTONVVMOPS
@@ -58,7 +59,7 @@ static NVVM::ShflKind convertShflKind(gpu::ShuffleMode mode) {
   llvm_unreachable("unknown shuffle mode");
 }
 
-static Optional<NVVM::ReduxKind>
+static std::optional<NVVM::ReduxKind>
 convertReduxKind(gpu::AllReduceOperation mode) {
   switch (mode) {
   case gpu::AllReduceOperation::ADD:
@@ -95,7 +96,7 @@ struct GPUSubgroupReduceOpLowering
     if (!op.getValue().getType().isInteger(32))
       return rewriter.notifyMatchFailure(op, "unsupported data type");
 
-    Optional<NVVM::ReduxKind> mode = convertReduxKind(op.getOp());
+    std::optional<NVVM::ReduxKind> mode = convertReduxKind(op.getOp());
     if (!mode.has_value())
       return rewriter.notifyMatchFailure(
           op, "unsupported reduction mode for redux");

diff  --git a/mlir/lib/Dialect/Arith/IR/InferIntRangeInterfaceImpls.cpp b/mlir/lib/Dialect/Arith/IR/InferIntRangeInterfaceImpls.cpp
index 971477fa94cb9..179d0883f691d 100644
--- a/mlir/lib/Dialect/Arith/IR/InferIntRangeInterfaceImpls.cpp
+++ b/mlir/lib/Dialect/Arith/IR/InferIntRangeInterfaceImpls.cpp
@@ -269,7 +269,7 @@ void arith::CmpIOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
   APInt min = APInt::getZero(1);
   APInt max = APInt::getAllOnesValue(1);
 
-  Optional<bool> truthValue = intrange::evaluatePred(pred, lhs, rhs);
+  std::optional<bool> truthValue = intrange::evaluatePred(pred, lhs, rhs);
   if (truthValue.has_value() && *truthValue)
     min = max;
   else if (truthValue.has_value() && !(*truthValue))

diff  --git a/mlir/lib/Dialect/Index/IR/InferIntRangeInterfaceImpls.cpp b/mlir/lib/Dialect/Index/IR/InferIntRangeInterfaceImpls.cpp
index 6daa7640b017e..0c2ee71edb633 100644
--- a/mlir/lib/Dialect/Index/IR/InferIntRangeInterfaceImpls.cpp
+++ b/mlir/lib/Dialect/Index/IR/InferIntRangeInterfaceImpls.cpp
@@ -11,6 +11,7 @@
 #include "mlir/Interfaces/Utils/InferIntRangeCommon.h"
 
 #include "llvm/Support/Debug.h"
+#include <optional>
 
 #define DEBUG_TYPE "int-range-analysis"
 
@@ -222,11 +223,11 @@ void CmpOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
   APInt min = APInt::getZero(1);
   APInt max = APInt::getAllOnesValue(1);
 
-  Optional<bool> truthValue64 = intrange::evaluatePred(pred, lhs, rhs);
+  std::optional<bool> truthValue64 = intrange::evaluatePred(pred, lhs, rhs);
 
   ConstantIntRanges lhsTrunc = truncRange(lhs, indexMinWidth),
                     rhsTrunc = truncRange(rhs, indexMinWidth);
-  Optional<bool> truthValue32 =
+  std::optional<bool> truthValue32 =
       intrange::evaluatePred(pred, lhsTrunc, rhsTrunc);
 
   if (truthValue64 == truthValue32) {

diff  --git a/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp b/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
index cfaac283cd81f..003d2d055da2c 100644
--- a/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
+++ b/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
@@ -24,6 +24,7 @@
 #include "mlir/Interfaces/DestinationStyleOpInterface.h"
 #include "mlir/Interfaces/TilingInterface.h"
 #include "llvm/Support/Debug.h"
+#include <optional>
 
 #define DEBUG_TYPE "tile-using-interface"
 
@@ -579,7 +580,7 @@ mlir::scf::tileAndFuseProducerOfSlice(RewriterBase &rewriter,
   // TODO: This can be modeled better if the `DestinationStyleOpInterface`.
   // Update to use that when it does become available.
   scf::ForOp outerMostLoop = loops.front();
-  Optional<unsigned> iterArgNumber;
+  std::optional<unsigned> iterArgNumber;
   if (destinationIterArg) {
     iterArgNumber =
         outerMostLoop.getIterArgNumberForOpOperand(*destinationIterArg.value());


        


More information about the cfe-commits mailing list