[llvm] d152e50 - [llvm] Don't use Optional::{hasValue, getValue} (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 25 11:24:29 PDT 2022


Author: Kazu Hirata
Date: 2022-06-25T11:24:23-07:00
New Revision: d152e50c15416c61220f218039c70f0c814e5651

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

LOG: [llvm] Don't use Optional::{hasValue,getValue} (NFC)

Added: 
    

Modified: 
    llvm/include/llvm/Testing/Support/SupportHelpers.h
    llvm/tools/llvm-objdump/XCOFFDump.cpp
    llvm/unittests/ADT/APIntTest.cpp
    llvm/unittests/Analysis/BasicAliasAnalysisTest.cpp
    llvm/unittests/Analysis/MemorySSATest.cpp
    llvm/unittests/Analysis/TensorSpecTest.cpp
    llvm/unittests/Analysis/ValueLatticeTest.cpp
    llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
    llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
    llvm/unittests/IR/ConstantRangeTest.cpp
    llvm/unittests/IR/InstructionsTest.cpp
    llvm/unittests/IR/MetadataTest.cpp
    llvm/unittests/InterfaceStub/ELFYAMLTest.cpp
    llvm/unittests/Object/XCOFFObjectFileTest.cpp
    llvm/unittests/Support/ARMAttributeParser.cpp
    llvm/unittests/Support/AlignmentTest.cpp
    llvm/unittests/Support/CSKYAttributeParserTest.cpp
    llvm/unittests/Support/Casting.cpp
    llvm/unittests/Support/RISCVAttributeParserTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Testing/Support/SupportHelpers.h b/llvm/include/llvm/Testing/Support/SupportHelpers.h
index ec1485bf0f16b..b1c59cf97f7f0 100644
--- a/llvm/include/llvm/Testing/Support/SupportHelpers.h
+++ b/llvm/include/llvm/Testing/Support/SupportHelpers.h
@@ -77,7 +77,7 @@ template <class InnerMatcher> class ValueIsMatcher {
 
     bool MatchAndExplain(const llvm::Optional<T> &Input,
                          testing::MatchResultListener *L) const override {
-      return Input && ValueMatcher.MatchAndExplain(Input.getValue(), L);
+      return Input && ValueMatcher.MatchAndExplain(*Input, L);
     }
 
     void DescribeTo(std::ostream *OS) const override {

diff  --git a/llvm/tools/llvm-objdump/XCOFFDump.cpp b/llvm/tools/llvm-objdump/XCOFFDump.cpp
index b8fb2ed3d0636..159741bebb67c 100644
--- a/llvm/tools/llvm-objdump/XCOFFDump.cpp
+++ b/llvm/tools/llvm-objdump/XCOFFDump.cpp
@@ -106,7 +106,7 @@ std::string objdump::getXCOFFSymbolDescription(const SymbolInfoTy &SymbolInfo,
   if (SymbolInfo.XCOFFSymInfo.StorageMappingClass &&
       !SymbolInfo.XCOFFSymInfo.IsLabel) {
     const XCOFF::StorageMappingClass Smc =
-        SymbolInfo.XCOFFSymInfo.StorageMappingClass.getValue();
+        *SymbolInfo.XCOFFSymInfo.StorageMappingClass;
     Result.append(("[" + XCOFF::getMappingClassString(Smc) + "]").str());
   }
 

diff  --git a/llvm/unittests/ADT/APIntTest.cpp b/llvm/unittests/ADT/APIntTest.cpp
index 607560aa7e019..e92754cc2ccd1 100644
--- a/llvm/unittests/ADT/APIntTest.cpp
+++ b/llvm/unittests/ADT/APIntTest.cpp
@@ -2897,7 +2897,7 @@ TEST(APIntTest, SolveQuadraticEquationWrap) {
           Optional<APInt> S = APIntOps::SolveQuadraticEquationWrap(
                                 APInt(Width, A), APInt(Width, B),
                                 APInt(Width, C), Width);
-          if (S.hasValue())
+          if (S)
             Validate(A, B, C, Width, S->getSExtValue());
         }
       }
@@ -2978,7 +2978,7 @@ TEST(APIntTest, GetMostSignificantDifferentBitExaustive) {
         auto Bit = APIntOps::GetMostSignificantDifferentBit(A, B);
         EXPECT_EQ(Bit, GetHighestDifferentBitBruteforce(A, B));
 
-        if (!Bit.hasValue())
+        if (!Bit)
           EXPECT_EQ(A, B);
         else {
           EXPECT_NE(A, B);

diff  --git a/llvm/unittests/Analysis/BasicAliasAnalysisTest.cpp b/llvm/unittests/Analysis/BasicAliasAnalysisTest.cpp
index 6933b7c19223b..be68bc91591f8 100644
--- a/llvm/unittests/Analysis/BasicAliasAnalysisTest.cpp
+++ b/llvm/unittests/Analysis/BasicAliasAnalysisTest.cpp
@@ -58,7 +58,7 @@ class BasicAATest : public testing::Test {
   TestAnalyses &setupAnalyses() {
     assert(F);
     Analyses.emplace(*this);
-    return Analyses.getValue();
+    return *Analyses;
   }
 
 public:

diff  --git a/llvm/unittests/Analysis/MemorySSATest.cpp b/llvm/unittests/Analysis/MemorySSATest.cpp
index 2ee208099261f..298a8bc5d9fc7 100644
--- a/llvm/unittests/Analysis/MemorySSATest.cpp
+++ b/llvm/unittests/Analysis/MemorySSATest.cpp
@@ -1039,8 +1039,7 @@ TEST_F(MemorySSATest, TestLoadMustAlias) {
   }
   for (LoadInst *V : {LA3, LA4}) {
     MemoryUse *MemUse = dyn_cast_or_null<MemoryUse>(MSSA.getMemoryAccess(V));
-    EXPECT_EQ(MemUse->getOptimizedAccessType().getValue(),
-              AliasResult::MustAlias)
+    EXPECT_EQ(*MemUse->getOptimizedAccessType(), AliasResult::MustAlias)
         << "Load " << I << " doesn't have the correct alias information";
     // EXPECT_EQ expands such that if we increment I above, it won't get
     // incremented except when we try to print the error message.
@@ -1089,8 +1088,7 @@ TEST_F(MemorySSATest, TestStoreMustAlias) {
       EXPECT_EQ(MemDef->getOptimizedAccessType(), None)
           << "Store " << I << " doesn't have the correct alias information";
     else
-      EXPECT_EQ(MemDef->getOptimizedAccessType().getValue(),
-                AliasResult::MustAlias)
+      EXPECT_EQ(*MemDef->getOptimizedAccessType(), AliasResult::MustAlias)
           << "Store " << I << " doesn't have the correct alias information";
     // EXPECT_EQ expands such that if we increment I above, it won't get
     // incremented except when we try to print the error message.
@@ -1125,8 +1123,7 @@ TEST_F(MemorySSATest, TestLoadMayAlias) {
   unsigned I = 0;
   for (LoadInst *V : {LA1, LB1}) {
     MemoryUse *MemUse = dyn_cast_or_null<MemoryUse>(MSSA.getMemoryAccess(V));
-    EXPECT_EQ(MemUse->getOptimizedAccessType().getValue(),
-              AliasResult::MayAlias)
+    EXPECT_EQ(*MemUse->getOptimizedAccessType(), AliasResult::MayAlias)
         << "Load " << I << " doesn't have the correct alias information";
     // EXPECT_EQ expands such that if we increment I above, it won't get
     // incremented except when we try to print the error message.
@@ -1134,8 +1131,7 @@ TEST_F(MemorySSATest, TestLoadMayAlias) {
   }
   for (LoadInst *V : {LA2, LB2}) {
     MemoryUse *MemUse = dyn_cast_or_null<MemoryUse>(MSSA.getMemoryAccess(V));
-    EXPECT_EQ(MemUse->getOptimizedAccessType().getValue(),
-              AliasResult::MustAlias)
+    EXPECT_EQ(*MemUse->getOptimizedAccessType(), AliasResult::MustAlias)
         << "Load " << I << " doesn't have the correct alias information";
     // EXPECT_EQ expands such that if we increment I above, it won't get
     // incremented except when we try to print the error message.

diff  --git a/llvm/unittests/Analysis/TensorSpecTest.cpp b/llvm/unittests/Analysis/TensorSpecTest.cpp
index e3f7b1939aa63..4f9575c90051a 100644
--- a/llvm/unittests/Analysis/TensorSpecTest.cpp
+++ b/llvm/unittests/Analysis/TensorSpecTest.cpp
@@ -26,7 +26,7 @@ TEST(TensorSpecTest, JSONParsing) {
   EXPECT_TRUE(!!Value);
   LLVMContext Ctx;
   Optional<TensorSpec> Spec = getTensorSpecFromJSON(Ctx, *Value);
-  EXPECT_TRUE(Spec.hasValue());
+  EXPECT_TRUE(Spec);
   EXPECT_EQ(*Spec, TensorSpec::createSpec<int32_t>("tensor_name", {1, 4}, 2));
 }
 
@@ -42,7 +42,7 @@ TEST(TensorSpecTest, JSONParsingInvalidTensorType) {
   EXPECT_TRUE(!!Value);
   LLVMContext Ctx;
   auto Spec = getTensorSpecFromJSON(Ctx, *Value);
-  EXPECT_FALSE(Spec.hasValue());
+  EXPECT_FALSE(Spec);
 }
 
 TEST(TensorSpecTest, TensorSpecSizesAndTypes) {

diff  --git a/llvm/unittests/Analysis/ValueLatticeTest.cpp b/llvm/unittests/Analysis/ValueLatticeTest.cpp
index 8ee2cf1ba34ad..b0b4b5e7bdc1d 100644
--- a/llvm/unittests/Analysis/ValueLatticeTest.cpp
+++ b/llvm/unittests/Analysis/ValueLatticeTest.cpp
@@ -65,7 +65,7 @@ TEST_F(ValueLatticeTest, MergeIn) {
   auto LV1 = ValueLatticeElement::get(C1);
   EXPECT_FALSE(LV1.mergeIn(ValueLatticeElement::get(C1)));
   EXPECT_TRUE(LV1.isConstantRange());
-  EXPECT_EQ(LV1.asConstantInteger().getValue().getLimitedValue(), 1U);
+  EXPECT_EQ(LV1.asConstantInteger()->getLimitedValue(), 1U);
 
   // Merge LV1 with 
diff erent integer constant.
   EXPECT_TRUE(

diff  --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
index e808eee1ae19d..367e89e4970d3 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
@@ -964,7 +964,7 @@ template <uint16_t Version, class AddrType> void TestAddresses() {
   EXPECT_EQ(SubprogramDieLowPC.getTag(), DW_TAG_subprogram);
   OptU64 = toAddress(SubprogramDieLowPC.find(DW_AT_low_pc));
   EXPECT_TRUE((bool)OptU64);
-  EXPECT_EQ(OptU64.getValue(), ActualLowPC);
+  EXPECT_EQ(*OptU64, ActualLowPC);
   OptU64 = toAddress(SubprogramDieLowPC.find(DW_AT_high_pc));
   EXPECT_FALSE((bool)OptU64);
   OptU64 = toUnsigned(SubprogramDieLowPC.find(DW_AT_high_pc));
@@ -981,7 +981,7 @@ template <uint16_t Version, class AddrType> void TestAddresses() {
   EXPECT_EQ(SubprogramDieLowHighPC.getTag(), DW_TAG_subprogram);
   OptU64 = toAddress(SubprogramDieLowHighPC.find(DW_AT_low_pc));
   EXPECT_TRUE((bool)OptU64);
-  EXPECT_EQ(OptU64.getValue(), ActualLowPC);
+  EXPECT_EQ(*OptU64, ActualLowPC);
   // Get the high PC as an address. This should succeed if the high PC was
   // encoded as an address and fail if the high PC was encoded as an offset.
   OptU64 = toAddress(SubprogramDieLowHighPC.find(DW_AT_high_pc));
@@ -1877,8 +1877,7 @@ TEST(DWARFDebugInfo, TestImplicitConstAbbrevs) {
     EXPECT_EQ(*AttrIndex, 0u);
     uint64_t OffsetVal =
         it->getAttributeOffsetFromIndex(*AttrIndex, /* offset */ 0, *U);
-    EXPECT_TRUE(
-        it->getAttributeValueFromOffset(*AttrIndex, OffsetVal, *U).hasValue());
+    EXPECT_TRUE(it->getAttributeValueFromOffset(*AttrIndex, OffsetVal, *U));
 
     auto FormValue = it->getAttributeValue(/* offset */ 0, A, *U);
     EXPECT_TRUE((bool)FormValue);

diff  --git a/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp b/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
index 67c004a2ccc47..977231d81143a 100644
--- a/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
+++ b/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
@@ -2097,7 +2097,7 @@ TEST(GSYMTest, TestDWARFNoLines) {
   auto ExpFI = GR->getFunctionInfo(0x1000);
   ASSERT_THAT_EXPECTED(ExpFI, Succeeded());
   ASSERT_EQ(ExpFI->Range, AddressRange(0x1000, 0x2000));
-  EXPECT_TRUE(ExpFI->OptLineTable.hasValue());
+  EXPECT_TRUE(ExpFI->OptLineTable);
   StringRef MethodName = GR->getString(ExpFI->Name);
   EXPECT_EQ(MethodName, "lines_no_decl");
   // Make sure have two line table entries and that get the first line entry
@@ -2109,7 +2109,7 @@ TEST(GSYMTest, TestDWARFNoLines) {
   ExpFI = GR->getFunctionInfo(0x2000);
   ASSERT_THAT_EXPECTED(ExpFI, Succeeded());
   ASSERT_EQ(ExpFI->Range, AddressRange(0x2000, 0x3000));
-  EXPECT_TRUE(ExpFI->OptLineTable.hasValue());
+  EXPECT_TRUE(ExpFI->OptLineTable);
   MethodName = GR->getString(ExpFI->Name);
   EXPECT_EQ(MethodName, "lines_with_decl");
   // Make sure have two line table entries and that we don't use line 20

diff  --git a/llvm/unittests/IR/ConstantRangeTest.cpp b/llvm/unittests/IR/ConstantRangeTest.cpp
index 8a543b1f7df41..ced38a28977b2 100644
--- a/llvm/unittests/IR/ConstantRangeTest.cpp
+++ b/llvm/unittests/IR/ConstantRangeTest.cpp
@@ -588,7 +588,7 @@ void testBinarySetOperationExhaustive(Fn1 OpFn, Fn2 ExactOpFn, Fn3 InResultFn) {
 
         Optional<ConstantRange> ExactCR = ExactOpFn(CR1, CR2);
         if (SmallestCR.isSizeLargerThan(Elems.count())) {
-          EXPECT_TRUE(!ExactCR.hasValue());
+          EXPECT_TRUE(!ExactCR);
         } else {
           EXPECT_EQ(SmallestCR, *ExactCR);
         }

diff  --git a/llvm/unittests/IR/InstructionsTest.cpp b/llvm/unittests/IR/InstructionsTest.cpp
index 62b2ab2278b35..6324adfea4c4d 100644
--- a/llvm/unittests/IR/InstructionsTest.cpp
+++ b/llvm/unittests/IR/InstructionsTest.cpp
@@ -763,7 +763,7 @@ TEST(InstructionsTest, AlterCallBundles) {
   EXPECT_TRUE(Clone->hasFnAttr(Attribute::AttrKind::Cold));
   EXPECT_EQ(Call->getDebugLoc(), Clone->getDebugLoc());
   EXPECT_EQ(Clone->getNumOperandBundles(), 1U);
-  EXPECT_TRUE(Clone->getOperandBundle("after").hasValue());
+  EXPECT_TRUE(Clone->getOperandBundle("after"));
 }
 
 TEST(InstructionsTest, AlterInvokeBundles) {
@@ -795,7 +795,7 @@ TEST(InstructionsTest, AlterInvokeBundles) {
   EXPECT_TRUE(Clone->hasFnAttr(Attribute::AttrKind::Cold));
   EXPECT_EQ(Invoke->getDebugLoc(), Clone->getDebugLoc());
   EXPECT_EQ(Clone->getNumOperandBundles(), 1U);
-  EXPECT_TRUE(Clone->getOperandBundle("after").hasValue());
+  EXPECT_TRUE(Clone->getOperandBundle("after"));
 }
 
 TEST_F(ModuleWithFunctionTest, DropPoisonGeneratingFlags) {

diff  --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp
index 41ea3e9c2f5ca..0c73aaa69b31f 100644
--- a/llvm/unittests/IR/MetadataTest.cpp
+++ b/llvm/unittests/IR/MetadataTest.cpp
@@ -1664,7 +1664,7 @@ TEST_F(DIDerivedTypeTest, get) {
   EXPECT_EQ(2u, N->getSizeInBits());
   EXPECT_EQ(3u, N->getAlignInBits());
   EXPECT_EQ(4u, N->getOffsetInBits());
-  EXPECT_EQ(DWARFAddressSpace, N->getDWARFAddressSpace().getValue());
+  EXPECT_EQ(DWARFAddressSpace, *N->getDWARFAddressSpace());
   EXPECT_EQ(5u, N->getFlags());
   EXPECT_EQ(ExtraData, N->getExtraData());
   EXPECT_EQ(N, DIDerivedType::get(Context, dwarf::DW_TAG_pointer_type,
@@ -1728,7 +1728,7 @@ TEST_F(DIDerivedTypeTest, getWithLargeValues) {
   EXPECT_EQ(UINT64_MAX, N->getSizeInBits());
   EXPECT_EQ(UINT32_MAX - 1, N->getAlignInBits());
   EXPECT_EQ(UINT64_MAX - 2, N->getOffsetInBits());
-  EXPECT_EQ(UINT32_MAX - 3, N->getDWARFAddressSpace().getValue());
+  EXPECT_EQ(UINT32_MAX - 3, *N->getDWARFAddressSpace());
 }
 
 typedef MetadataTest DICompositeTypeTest;

diff  --git a/llvm/unittests/InterfaceStub/ELFYAMLTest.cpp b/llvm/unittests/InterfaceStub/ELFYAMLTest.cpp
index 3eb492618acfd..404dfd3e6b686 100644
--- a/llvm/unittests/InterfaceStub/ELFYAMLTest.cpp
+++ b/llvm/unittests/InterfaceStub/ELFYAMLTest.cpp
@@ -75,7 +75,7 @@ TEST(ElfYamlTextAPI, YAMLReadsTBESymbols) {
   ASSERT_THAT_ERROR(StubOrErr.takeError(), Succeeded());
   std::unique_ptr<IFSStub> Stub = std::move(StubOrErr.get());
   EXPECT_NE(Stub.get(), nullptr);
-  EXPECT_TRUE(Stub->SoName.hasValue());
+  EXPECT_TRUE(Stub->SoName);
   EXPECT_STREQ(Stub->SoName->c_str(), "test.so");
   EXPECT_EQ(Stub->Symbols.size(), 5u);
 
@@ -86,7 +86,7 @@ TEST(ElfYamlTextAPI, YAMLReadsTBESymbols) {
   EXPECT_EQ(SymBar.Type, IFSSymbolType::Object);
   EXPECT_FALSE(SymBar.Undefined);
   EXPECT_FALSE(SymBar.Weak);
-  EXPECT_FALSE(SymBar.Warning.hasValue());
+  EXPECT_FALSE(SymBar.Warning);
 
   IFSSymbol const &SymBaz = *Iterator++;
   EXPECT_STREQ(SymBaz.Name.c_str(), "baz");
@@ -119,7 +119,7 @@ TEST(ElfYamlTextAPI, YAMLReadsTBESymbols) {
   EXPECT_EQ(SymNot.Type, IFSSymbolType::Unknown);
   EXPECT_TRUE(SymNot.Undefined);
   EXPECT_TRUE(SymNot.Weak);
-  EXPECT_TRUE(SymNot.Warning.hasValue());
+  EXPECT_TRUE(SymNot.Warning);
   EXPECT_STREQ(SymNot.Warning->c_str(), "All fields populated!");
 }
 

diff  --git a/llvm/unittests/Object/XCOFFObjectFileTest.cpp b/llvm/unittests/Object/XCOFFObjectFileTest.cpp
index 0559a1ee3c575..41662be0b6dbb 100644
--- a/llvm/unittests/Object/XCOFFObjectFileTest.cpp
+++ b/llvm/unittests/Object/XCOFFObjectFileTest.cpp
@@ -116,7 +116,7 @@ TEST(XCOFFObjectFileTest, XCOFFTracebackTableAPIParmsType) {
   EXPECT_EQ(TT.getNumberOfFPParms(), 3);
 
   ASSERT_TRUE(TT.getParmsType());
-  EXPECT_EQ(TT.getParmsType().getValue(), "i, i, f, f, d");
+  EXPECT_EQ(*TT.getParmsType(), "i, i, f, f, d");
 
   V[8] = 0xAC;
   Size = sizeof(V);
@@ -124,7 +124,7 @@ TEST(XCOFFObjectFileTest, XCOFFTracebackTableAPIParmsType) {
   ASSERT_THAT_EXPECTED(TTOrErr1, Succeeded());
   XCOFFTracebackTable TT1 = *TTOrErr1;
   ASSERT_TRUE(TT1.getParmsType());
-  EXPECT_EQ(TT1.getParmsType().getValue(), "f, f, d, i, i");
+  EXPECT_EQ(*TT1.getParmsType(), "f, f, d, i, i");
 
   V[8] = 0xD4;
   Size = sizeof(V);
@@ -132,7 +132,7 @@ TEST(XCOFFObjectFileTest, XCOFFTracebackTableAPIParmsType) {
   ASSERT_THAT_EXPECTED(TTOrErr2, Succeeded());
   XCOFFTracebackTable TT2 = *TTOrErr2;
   ASSERT_TRUE(TT2.getParmsType());
-  EXPECT_EQ(TT2.getParmsType().getValue(), "d, i, f, f, i");
+  EXPECT_EQ(*TT2.getParmsType(), "d, i, f, f, i");
 
   V[6] = 0x01;
   Size = sizeof(V);
@@ -140,7 +140,7 @@ TEST(XCOFFObjectFileTest, XCOFFTracebackTableAPIParmsType) {
   ASSERT_THAT_EXPECTED(TTOrErr3, Succeeded());
   XCOFFTracebackTable TT3 = *TTOrErr3;
   ASSERT_TRUE(TT3.getParmsType());
-  EXPECT_EQ(TT3.getParmsType().getValue(), "d, i, f, f");
+  EXPECT_EQ(*TT3.getParmsType(), "d, i, f, f");
 
   V[6] = 0x04;
   V[7] = 0x1E;
@@ -153,7 +153,7 @@ TEST(XCOFFObjectFileTest, XCOFFTracebackTableAPIParmsType) {
   ASSERT_THAT_EXPECTED(TTOrErr4, Succeeded());
   XCOFFTracebackTable TT4 = *TTOrErr4;
   ASSERT_TRUE(TT4.getParmsType());
-  EXPECT_EQ(TT4.getParmsType().getValue(),
+  EXPECT_EQ(*TT4.getParmsType(),
             "f, f, d, i, i, f, f, f, f, f, f, f, f, f, f, f, f, ...");
 }
 
@@ -190,7 +190,7 @@ TEST(XCOFFObjectFileTest, XCOFFTracebackTableAPIAllocaRegister) {
   ASSERT_THAT_EXPECTED(TTOrErr, Succeeded());
   XCOFFTracebackTable TT = *TTOrErr;
   ASSERT_TRUE(TT.getAllocaRegister());
-  EXPECT_EQ(TT.getAllocaRegister().getValue(), 31u);
+  EXPECT_EQ(*TT.getAllocaRegister(), 31u);
 }
 
 TEST(XCOFFObjectFileTest, XCOFFTracebackTableAPIHasVectorInfo) {
@@ -222,8 +222,7 @@ TEST(XCOFFObjectFileTest, XCOFFTracebackTableAPIHasVectorInfo) {
   EXPECT_EQ(VecExt.getVectorParmsInfo(), "vf, vf");
 
   ASSERT_TRUE(TT.getExtensionTable());
-  EXPECT_EQ(TT.getExtensionTable().getValue(),
-            ExtendedTBTableFlag::TB_SSP_CANARY);
+  EXPECT_EQ(*TT.getExtensionTable(), ExtendedTBTableFlag::TB_SSP_CANARY);
 
   EXPECT_EQ(Size, 45u);
 }
@@ -256,8 +255,7 @@ TEST(XCOFFObjectFileTest, XCOFFTracebackTableAPIHasVectorInfo1) {
   EXPECT_EQ(VecExt.getVectorParmsInfo(), "vi, vs, vc");
 
   ASSERT_TRUE(TT.getExtensionTable());
-  EXPECT_EQ(TT.getExtensionTable().getValue(),
-            ExtendedTBTableFlag::TB_SSP_CANARY);
+  EXPECT_EQ(*TT.getExtensionTable(), ExtendedTBTableFlag::TB_SSP_CANARY);
 
   EXPECT_EQ(Size, 44u);
 }

diff  --git a/llvm/unittests/Support/ARMAttributeParser.cpp b/llvm/unittests/Support/ARMAttributeParser.cpp
index bd02f1b1f78fa..7293c5649558a 100644
--- a/llvm/unittests/Support/ARMAttributeParser.cpp
+++ b/llvm/unittests/Support/ARMAttributeParser.cpp
@@ -38,7 +38,7 @@ bool testBuildAttr(unsigned Tag, unsigned Value,
   cantFail(Parser.parse(Bytes, support::little));
 
   Optional<unsigned> Attr = Parser.getAttributeValue(ExpectedTag);
-  return Attr.hasValue() && Attr.getValue() == ExpectedValue;
+  return Attr && *Attr == ExpectedValue;
 }
 
 void testParseError(ArrayRef<uint8_t> bytes, const char *msg) {

diff  --git a/llvm/unittests/Support/AlignmentTest.cpp b/llvm/unittests/Support/AlignmentTest.cpp
index cb89776c0b7ae..fa9199706b412 100644
--- a/llvm/unittests/Support/AlignmentTest.cpp
+++ b/llvm/unittests/Support/AlignmentTest.cpp
@@ -52,9 +52,7 @@ std::vector<uint64_t> getValidAlignments() {
 
 TEST(AlignmentTest, AlignDefaultCTor) { EXPECT_EQ(Align().value(), 1ULL); }
 
-TEST(AlignmentTest, MaybeAlignDefaultCTor) {
-  EXPECT_FALSE(MaybeAlign().hasValue());
-}
+TEST(AlignmentTest, MaybeAlignDefaultCTor) { EXPECT_FALSE(MaybeAlign()); }
 
 TEST(AlignmentTest, ValidCTors) {
   for (uint64_t Value : getValidAlignments()) {
@@ -134,7 +132,7 @@ TEST(AlignmentTest, Encode_Decode) {
   for (uint64_t Value : getValidAlignments()) {
     {
       Align Actual(Value);
-      Align Expected = decodeMaybeAlign(encode(Actual)).getValue();
+      Align Expected = *decodeMaybeAlign(encode(Actual));
       EXPECT_EQ(Expected, Actual);
     }
     {
@@ -251,7 +249,7 @@ std::vector<uint64_t> getValidAlignmentsForDeathTest() {
 std::vector<uint64_t> getNonPowerOfTwo() { return {3, 10, 15}; }
 
 TEST(AlignmentDeathTest, CantConvertUnsetMaybe) {
-  EXPECT_DEATH((MaybeAlign(0).getValue()), ".*");
+  EXPECT_DEATH((*MaybeAlign(0)), ".*");
 }
 
 TEST(AlignmentDeathTest, InvalidCTors) {

diff  --git a/llvm/unittests/Support/CSKYAttributeParserTest.cpp b/llvm/unittests/Support/CSKYAttributeParserTest.cpp
index db64ef72d1a99..e857237a68a5c 100644
--- a/llvm/unittests/Support/CSKYAttributeParserTest.cpp
+++ b/llvm/unittests/Support/CSKYAttributeParserTest.cpp
@@ -84,7 +84,7 @@ static bool testAttributeInt(unsigned Tag, unsigned Value, unsigned ExpectedTag,
   cantFail(Parser.parse(Bytes, support::little));
 
   Optional<unsigned> Attr = Parser.getAttributeValue(ExpectedTag);
-  return Attr.hasValue() && Attr.getValue() == ExpectedValue;
+  return Attr && *Attr == ExpectedValue;
 }
 
 static bool testAttributeString(unsigned Tag, const char *Value,
@@ -101,7 +101,7 @@ static bool testAttributeString(unsigned Tag, const char *Value,
   cantFail(Parser.parse(Bytes, support::little));
 
   Optional<StringRef> Attr = Parser.getAttributeString(ExpectedTag);
-  return Attr.hasValue() && Attr.getValue() == ExpectedValue;
+  return Attr && *Attr == ExpectedValue;
 }
 
 static void testParseError(unsigned Tag, unsigned Value, const char *msg) {

diff  --git a/llvm/unittests/Support/Casting.cpp b/llvm/unittests/Support/Casting.cpp
index 93a5e67db0f42..311fefd728785 100644
--- a/llvm/unittests/Support/Casting.cpp
+++ b/llvm/unittests/Support/Casting.cpp
@@ -236,7 +236,7 @@ TEST(CastingTest, dyn_cast_or_null) {
 TEST(CastingTest, dyn_cast_value_types) {
   T1 t1;
   Optional<T2> t2 = dyn_cast<T2>(t1);
-  EXPECT_TRUE(t2.hasValue());
+  EXPECT_TRUE(t2);
 
   T2 *t2ptr = dyn_cast<T2>(&t1);
   EXPECT_TRUE(t2ptr != nullptr);

diff  --git a/llvm/unittests/Support/RISCVAttributeParserTest.cpp b/llvm/unittests/Support/RISCVAttributeParserTest.cpp
index 02ffb366a8396..a3aa88a91b2fd 100644
--- a/llvm/unittests/Support/RISCVAttributeParserTest.cpp
+++ b/llvm/unittests/Support/RISCVAttributeParserTest.cpp
@@ -45,7 +45,7 @@ static bool testAttribute(unsigned Tag, unsigned Value, unsigned ExpectedTag,
   cantFail(Parser.parse(Bytes, support::little));
 
   Optional<unsigned> Attr = Parser.getAttributeValue(ExpectedTag);
-  return Attr.hasValue() && Attr.getValue() == ExpectedValue;
+  return Attr && *Attr == ExpectedValue;
 }
 
 static bool testTagString(unsigned Tag, const char *name) {


        


More information about the llvm-commits mailing list