[llvm] 41ae78e - Use has_value instead of hasValue (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 19 20:15:56 PDT 2022


Author: Kazu Hirata
Date: 2022-07-19T20:15:44-07:00
New Revision: 41ae78ea3a931018cf2be58fb9eaa98bfeaf2db6

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

LOG: Use has_value instead of hasValue (NFC)

Added: 
    

Modified: 
    clang/lib/Basic/Sarif.cpp
    clang/unittests/Basic/SarifTest.cpp
    llvm/lib/CodeGen/ExpandVectorPredication.cpp
    llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
    llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
    llvm/lib/Target/AMDGPU/SIISelLowering.cpp
    llvm/lib/Transforms/IPO/Attributor.cpp
    llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Basic/Sarif.cpp b/clang/lib/Basic/Sarif.cpp
index 668e60d47eecd..ed43c7eab0566 100644
--- a/clang/lib/Basic/Sarif.cpp
+++ b/clang/lib/Basic/Sarif.cpp
@@ -270,18 +270,18 @@ void SarifDocumentWriter::endRun() {
   for (const auto &Pair : CurrentArtifacts) {
     const SarifArtifact &A = Pair.getValue();
     json::Object Loc{{"uri", A.Location.URI}};
-    if (A.Location.Index.hasValue()) {
+    if (A.Location.Index.has_value()) {
       Loc["index"] = static_cast<int64_t>(A.Location.Index.getValue());
     }
     json::Object Artifact;
     Artifact["location"] = std::move(Loc);
-    if (A.Length.hasValue())
+    if (A.Length.has_value())
       Artifact["length"] = static_cast<int64_t>(A.Length.getValue());
     if (!A.Roles.empty())
       Artifact["roles"] = json::Array(A.Roles);
     if (!A.MimeType.empty())
       Artifact["mimeType"] = A.MimeType;
-    if (A.Offset.hasValue())
+    if (A.Offset.has_value())
       Artifact["offset"] = A.Offset;
     Artifacts->push_back(json::Value(std::move(Artifact)));
   }

diff  --git a/clang/unittests/Basic/SarifTest.cpp b/clang/unittests/Basic/SarifTest.cpp
index 05221c828afe6..328496ab137d3 100644
--- a/clang/unittests/Basic/SarifTest.cpp
+++ b/clang/unittests/Basic/SarifTest.cpp
@@ -117,9 +117,9 @@ TEST_F(SarifDocumentWriterTest, canCreateDocumentWithOneRun) {
       Runs->begin()->getAsObject()->getObject("tool")->getObject("driver");
   ASSERT_THAT(driver, testing::NotNull());
 
-  ASSERT_TRUE(driver->getString("name").hasValue());
-  ASSERT_TRUE(driver->getString("fullName").hasValue());
-  ASSERT_TRUE(driver->getString("language").hasValue());
+  ASSERT_TRUE(driver->getString("name").has_value());
+  ASSERT_TRUE(driver->getString("fullName").has_value());
+  ASSERT_TRUE(driver->getString("language").has_value());
 
   EXPECT_EQ(driver->getString("name").getValue(), ShortName);
   EXPECT_EQ(driver->getString("fullName").getValue(), LongName);
@@ -186,8 +186,8 @@ TEST_F(SarifDocumentWriterTest, addingResultWithValidRuleAndRunIsOk) {
   const llvm::json::Array *Artifacts = TheRun->getArray("artifacts");
 
   // The tool is as expected
-  ASSERT_TRUE(Driver->getString("name").hasValue());
-  ASSERT_TRUE(Driver->getString("fullName").hasValue());
+  ASSERT_TRUE(Driver->getString("name").has_value());
+  ASSERT_TRUE(Driver->getString("fullName").has_value());
 
   EXPECT_EQ(Driver->getString("name").getValue(), "sarif test");
   EXPECT_EQ(Driver->getString("fullName").getValue(), "sarif test runner");

diff  --git a/llvm/lib/CodeGen/ExpandVectorPredication.cpp b/llvm/lib/CodeGen/ExpandVectorPredication.cpp
index ed95437f39bf9..8840ddde36921 100644
--- a/llvm/lib/CodeGen/ExpandVectorPredication.cpp
+++ b/llvm/lib/CodeGen/ExpandVectorPredication.cpp
@@ -419,7 +419,7 @@ CachingVPExpander::expandPredicationInMemoryIntrinsic(IRBuilder<> &Builder,
     if (IsUnmasked) {
       StoreInst *NewStore =
           Builder.CreateStore(DataParam, PtrParam, /*IsVolatile*/ false);
-      if (AlignOpt.hasValue())
+      if (AlignOpt.has_value())
         NewStore->setAlignment(AlignOpt.getValue());
       NewMemoryInst = NewStore;
     } else
@@ -431,7 +431,7 @@ CachingVPExpander::expandPredicationInMemoryIntrinsic(IRBuilder<> &Builder,
     if (IsUnmasked) {
       LoadInst *NewLoad =
           Builder.CreateLoad(VPI.getType(), PtrParam, /*IsVolatile*/ false);
-      if (AlignOpt.hasValue())
+      if (AlignOpt.has_value())
         NewLoad->setAlignment(AlignOpt.getValue());
       NewMemoryInst = NewLoad;
     } else

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp b/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
index 484e195c055b3..aa4e0116e404c 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
@@ -815,7 +815,7 @@ bool AMDGPUCallLowering::passSpecialInputs(MachineIRBuilder &MIRBuilder,
     } else if (InputID == AMDGPUFunctionArgInfo::LDS_KERNEL_ID) {
       Optional<uint32_t> Id =
           AMDGPUMachineFunction::getLDSKernelIdMetadata(MF.getFunction());
-      if (Id.hasValue()) {
+      if (Id.has_value()) {
         MIRBuilder.buildConstant(InputReg, Id.getValue());
       } else {
         MIRBuilder.buildUndef(InputReg);

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
index 7262b78e426cb..f1f8f28c41bda 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
@@ -4203,7 +4203,7 @@ bool AMDGPULegalizerInfo::getLDSKernelId(Register DstReg,
   Function &F = B.getMF().getFunction();
   Optional<uint32_t> KnownSize =
       AMDGPUMachineFunction::getLDSKernelIdMetadata(F);
-  if (KnownSize.hasValue())
+  if (KnownSize.has_value())
     B.buildConstant(DstReg, KnownSize.getValue());
   return false;
 }

diff  --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index 35129a5338ba8..cca4345c2a162 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -1670,7 +1670,7 @@ SDValue SITargetLowering::getLDSKernelId(SelectionDAG &DAG,
   Function &F = DAG.getMachineFunction().getFunction();
   Optional<uint32_t> KnownSize =
       AMDGPUMachineFunction::getLDSKernelIdMetadata(F);
-  if (KnownSize.hasValue())
+  if (KnownSize.has_value())
     return DAG.getConstant(KnownSize.getValue(), SL, MVT::i32);
   return SDValue();
 }
@@ -2821,7 +2821,7 @@ void SITargetLowering::passSpecialInputs(
       InputReg = getImplicitArgPtr(DAG, DL);
     } else if (InputID == AMDGPUFunctionArgInfo::LDS_KERNEL_ID) {
       Optional<uint32_t> Id = AMDGPUMachineFunction::getLDSKernelIdMetadata(F);
-      if (Id.hasValue()) {
+      if (Id.has_value()) {
         InputReg = DAG.getConstant(Id.getValue(), DL, ArgVT);
       } else {
         InputReg = DAG.getUNDEF(ArgVT);

diff  --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 99606ba528241..8ac591dd36cd8 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -1109,7 +1109,7 @@ bool Attributor::getAssumedSimplifiedValues(
   const auto &SimplificationCBs = SimplificationCallbacks.lookup(IRP);
   for (auto &CB : SimplificationCBs) {
     Optional<Value *> CBResult = CB(IRP, AA, UsedAssumedInformation);
-    if (!CBResult.hasValue())
+    if (!CBResult.has_value())
       continue;
     Value *V = CBResult.getValue();
     if (!V)

diff  --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 41a4fa184a2c8..ee0de04d22c54 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -5393,7 +5393,7 @@ struct AAValueSimplifyImpl : AAValueSimplify {
     bool UsedAssumedInformation = false;
     Optional<Value *> SimpleV = A.getAssumedSimplified(
         V, QueryingAA, UsedAssumedInformation, AA::Interprocedural);
-    if (!SimpleV.hasValue())
+    if (!SimpleV.has_value())
       return PoisonValue::get(&Ty);
     Value *EffectiveV = &V;
     if (SimpleV.value())
@@ -8340,7 +8340,7 @@ struct AAValueConstantRangeFloating : AAValueConstantRangeImpl {
     const auto &SimplifiedLHS = A.getAssumedSimplified(
         IRPosition::value(*LHS, getCallBaseContext()), *this,
         UsedAssumedInformation, AA::Interprocedural);
-    if (!SimplifiedLHS.hasValue())
+    if (!SimplifiedLHS.has_value())
       return true;
     if (!SimplifiedLHS.value())
       return false;
@@ -8349,7 +8349,7 @@ struct AAValueConstantRangeFloating : AAValueConstantRangeImpl {
     const auto &SimplifiedRHS = A.getAssumedSimplified(
         IRPosition::value(*RHS, getCallBaseContext()), *this,
         UsedAssumedInformation, AA::Interprocedural);
-    if (!SimplifiedRHS.hasValue())
+    if (!SimplifiedRHS.has_value())
       return true;
     if (!SimplifiedRHS.value())
       return false;
@@ -8393,7 +8393,7 @@ struct AAValueConstantRangeFloating : AAValueConstantRangeImpl {
     const auto &SimplifiedOpV = A.getAssumedSimplified(
         IRPosition::value(*OpV, getCallBaseContext()), *this,
         UsedAssumedInformation, AA::Interprocedural);
-    if (!SimplifiedOpV.hasValue())
+    if (!SimplifiedOpV.has_value())
       return true;
     if (!SimplifiedOpV.value())
       return false;
@@ -8423,7 +8423,7 @@ struct AAValueConstantRangeFloating : AAValueConstantRangeImpl {
     const auto &SimplifiedLHS = A.getAssumedSimplified(
         IRPosition::value(*LHS, getCallBaseContext()), *this,
         UsedAssumedInformation, AA::Interprocedural);
-    if (!SimplifiedLHS.hasValue())
+    if (!SimplifiedLHS.has_value())
       return true;
     if (!SimplifiedLHS.value())
       return false;
@@ -8432,7 +8432,7 @@ struct AAValueConstantRangeFloating : AAValueConstantRangeImpl {
     const auto &SimplifiedRHS = A.getAssumedSimplified(
         IRPosition::value(*RHS, getCallBaseContext()), *this,
         UsedAssumedInformation, AA::Interprocedural);
-    if (!SimplifiedRHS.hasValue())
+    if (!SimplifiedRHS.has_value())
       return true;
     if (!SimplifiedRHS.value())
       return false;
@@ -8498,7 +8498,7 @@ struct AAValueConstantRangeFloating : AAValueConstantRangeImpl {
         const auto &SimplifiedOpV = A.getAssumedSimplified(
             IRPosition::value(V, getCallBaseContext()), *this,
             UsedAssumedInformation, AA::Interprocedural);
-        if (!SimplifiedOpV.hasValue())
+        if (!SimplifiedOpV.has_value())
           return true;
         if (!SimplifiedOpV.value())
           return false;
@@ -9218,7 +9218,7 @@ struct AANoUndefImpl : AANoUndef {
     // the same reason above.
     if (!A.getAssumedSimplified(getIRPosition(), *this, UsedAssumedInformation,
                                 AA::Interprocedural)
-             .hasValue())
+             .has_value())
       return ChangeStatus::UNCHANGED;
     return AANoUndef::manifest(A);
   }
@@ -9759,7 +9759,7 @@ askForAssumedConstant(Attributor &A, const AbstractAttribute &QueryingAA,
 
   Optional<Constant *> COpt = AA.getAssumedConstant(A);
 
-  if (!COpt.hasValue()) {
+  if (!COpt.has_value()) {
     A.recordDependence(AA, QueryingAA, DepClassTy::OPTIONAL);
     return llvm::None;
   }
@@ -9777,10 +9777,10 @@ Value *AAPotentialValues::getSingleValue(
   Optional<Value *> V;
   for (auto &It : Values) {
     V = AA::combineOptionalValuesInAAValueLatice(V, It.getValue(), &Ty);
-    if (V.hasValue() && !V.getValue())
+    if (V.has_value() && !V.getValue())
       break;
   }
-  if (!V.hasValue())
+  if (!V.has_value())
     return UndefValue::get(&Ty);
   return V.getValue();
 }
@@ -9850,7 +9850,7 @@ struct AAPotentialValuesImpl : AAPotentialValues {
       Type &Ty = *getAssociatedType();
       Optional<Value *> SimpleV =
           askOtherAA<AAValueConstantRange>(A, *this, ValIRP, Ty);
-      if (SimpleV.hasValue() && !SimpleV.getValue()) {
+      if (SimpleV.has_value() && !SimpleV.getValue()) {
         auto &PotentialConstantsAA = A.getAAFor<AAPotentialConstantValues>(
             *this, ValIRP, DepClassTy::OPTIONAL);
         if (PotentialConstantsAA.isValidState()) {
@@ -9862,7 +9862,7 @@ struct AAPotentialValuesImpl : AAPotentialValues {
           return;
         }
       }
-      if (!SimpleV.hasValue())
+      if (!SimpleV.has_value())
         return;
 
       if (SimpleV.getValue())
@@ -10003,7 +10003,7 @@ struct AAPotentialValuesFloating : AAPotentialValuesImpl {
     const auto &SimplifiedLHS = A.getAssumedSimplified(
         IRPosition::value(*LHS, getCallBaseContext()), *this,
         UsedAssumedInformation, AA::Intraprocedural);
-    if (!SimplifiedLHS.hasValue())
+    if (!SimplifiedLHS.has_value())
       return true;
     if (!SimplifiedLHS.getValue())
       return false;
@@ -10012,7 +10012,7 @@ struct AAPotentialValuesFloating : AAPotentialValuesImpl {
     const auto &SimplifiedRHS = A.getAssumedSimplified(
         IRPosition::value(*RHS, getCallBaseContext()), *this,
         UsedAssumedInformation, AA::Intraprocedural);
-    if (!SimplifiedRHS.hasValue())
+    if (!SimplifiedRHS.has_value())
       return true;
     if (!SimplifiedRHS.getValue())
       return false;
@@ -10067,7 +10067,7 @@ struct AAPotentialValuesFloating : AAPotentialValuesImpl {
 
     Optional<Constant *> C =
         A.getAssumedConstant(*SI.getCondition(), *this, UsedAssumedInformation);
-    bool NoValueYet = !C.hasValue();
+    bool NoValueYet = !C.has_value();
     if (NoValueYet || isa_and_nonnull<UndefValue>(*C))
       return true;
     if (auto *CI = dyn_cast_or_null<ConstantInt>(*C)) {
@@ -10192,7 +10192,7 @@ struct AAPotentialValuesFloating : AAPotentialValuesImpl {
           UsedAssumedInformation, AA::Intraprocedural);
       // If we are not sure about any operand we are not sure about the entire
       // instruction, we'll wait.
-      if (!SimplifiedOp.hasValue())
+      if (!SimplifiedOp.has_value())
         return true;
 
       if (SimplifiedOp.getValue())
@@ -10493,7 +10493,7 @@ struct AAPotentialValuesCallSiteReturned : AAPotentialValuesImpl {
       Value *V = It.getValue();
       Optional<Value *> CallerV = A.translateArgumentToCallSiteContent(
           V, *CB, *this, UsedAssumedInformation);
-      if (!CallerV.hasValue()) {
+      if (!CallerV.has_value()) {
         // Nothing to do as long as no value was determined.
         continue;
       }


        


More information about the llvm-commits mailing list