forked from OSchip/llvm-project
Use has_value instead of hasValue (NFC)
This commit is contained in:
parent
5dd19ada57
commit
41ae78ea3a
|
@ -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)));
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue