Don't use Optional::hasValue (NFC)

This commit is contained in:
Kazu Hirata 2022-06-20 20:17:57 -07:00
parent 064a08cd95
commit 0916d96d12
55 changed files with 82 additions and 82 deletions

View File

@ -799,7 +799,7 @@ void NotNullTerminatedResultCheck::check(
Optional<bool> AreSafeFunctionsWanted;
Preprocessor::macro_iterator It = PP->macro_begin();
while (It != PP->macro_end() && !AreSafeFunctionsWanted.hasValue()) {
while (It != PP->macro_end() && !AreSafeFunctionsWanted) {
if (It->first->getName() == "__STDC_WANT_LIB_EXT1__") {
const auto *MI = PP->getMacroInfo(It->first);
// PP->getMacroInfo() returns nullptr if macro has no definition.

View File

@ -375,7 +375,7 @@ struct CodeCompletionBuilder {
std::move(*Spelled),
Includes.shouldInsertInclude(*ResolvedDeclaring, *ResolvedInserted));
};
bool ShouldInsert = C.headerToInsertIfAllowed(Opts).hasValue();
bool ShouldInsert = C.headerToInsertIfAllowed(Opts).has_value();
// Calculate include paths and edits for all possible headers.
for (const auto &Inc : C.RankedIncludeHeaders) {
if (auto ToInclude = Inserted(Inc)) {

View File

@ -378,7 +378,7 @@ wordMatching(llvm::StringRef Name, const llvm::StringSet<> *ContextWords) {
SymbolRelevanceSignals::DerivedSignals
SymbolRelevanceSignals::calculateDerivedSignals() const {
DerivedSignals Derived;
Derived.NameMatchesContext = wordMatching(Name, ContextWords).hasValue();
Derived.NameMatchesContext = wordMatching(Name, ContextWords).has_value();
Derived.FileProximityDistance = !FileProximityMatch || SymbolURI.empty()
? FileDistance::Unreachable
: FileProximityMatch->distance(SymbolURI);

View File

@ -452,7 +452,7 @@ public:
{
std::lock_guard<std::mutex> Lock(Mutex);
CurrentReq.reset();
IsEmpty = !NextReq.hasValue();
IsEmpty = !NextReq;
}
if (IsEmpty) {
// We don't perform this above, before waiting for a request to make
@ -1146,7 +1146,7 @@ void ASTWorker::generateDiagnostics(
}
Status.update([&](TUStatus &Status) {
Status.Details.ReuseAST = false;
Status.Details.BuildFailed = !NewAST.hasValue();
Status.Details.BuildFailed = !NewAST;
});
AST = NewAST ? std::make_unique<ParsedAST>(std::move(*NewAST)) : nullptr;
} else {

View File

@ -253,7 +253,7 @@ public:
vlog(" definition: {0}", Definitions);
auto Hover = getHover(*AST, Pos, Style, &Index);
vlog(" hover: {0}", Hover.hasValue());
vlog(" hover: {0}", Hover.has_value());
unsigned DocHighlights = findDocumentHighlights(*AST, Pos).size();
vlog(" documentHighlight: {0}", DocHighlights);

View File

@ -238,7 +238,7 @@ public:
: llvm::None;
}
void setSwiftImportAsNonGeneric(llvm::Optional<bool> Value) {
SwiftImportAsNonGenericSpecified = Value.hasValue();
SwiftImportAsNonGenericSpecified = Value.has_value();
SwiftImportAsNonGeneric = Value.value_or(false);
}
@ -247,7 +247,7 @@ public:
: llvm::None;
}
void setSwiftObjCMembers(llvm::Optional<bool> Value) {
SwiftObjCMembersSpecified = Value.hasValue();
SwiftObjCMembersSpecified = Value.has_value();
SwiftObjCMembers = Value.value_or(false);
}
@ -365,7 +365,7 @@ public:
: llvm::None;
}
void setSwiftImportAsAccessors(llvm::Optional<bool> Value) {
SwiftImportAsAccessorsSpecified = Value.hasValue();
SwiftImportAsAccessorsSpecified = Value.has_value();
SwiftImportAsAccessors = Value.value_or(false);
}
@ -429,7 +429,7 @@ public:
return NoEscape;
}
void setNoEscape(llvm::Optional<bool> Value) {
NoEscapeSpecified = Value.hasValue();
NoEscapeSpecified = Value.has_value();
NoEscape = Value.value_or(false);
}
@ -666,7 +666,7 @@ public:
return llvm::None;
}
void setFlagEnum(llvm::Optional<bool> Value) {
HasFlagEnum = Value.hasValue();
HasFlagEnum = Value.has_value();
IsFlagEnum = Value.value_or(false);
}

View File

@ -5805,7 +5805,7 @@ public:
static void Profile(llvm::FoldingSetNodeID &ID, QualType Pattern,
Optional<unsigned> NumExpansions) {
ID.AddPointer(Pattern.getAsOpaquePtr());
ID.AddBoolean(NumExpansions.hasValue());
ID.AddBoolean(NumExpansions.has_value());
if (NumExpansions)
ID.AddInteger(*NumExpansions);
}

View File

@ -196,7 +196,7 @@ CXXNewExpr::CXXNewExpr(bool IsGlobalNew, FunctionDecl *OperatorNew,
"Only NoInit can have no initializer!");
CXXNewExprBits.IsGlobalNew = IsGlobalNew;
CXXNewExprBits.IsArray = ArraySize.hasValue();
CXXNewExprBits.IsArray = ArraySize.has_value();
CXXNewExprBits.ShouldPassAlignment = ShouldPassAlignment;
CXXNewExprBits.UsualArrayDeleteWantsSize = UsualArrayDeleteWantsSize;
CXXNewExprBits.StoredInitializationStyle =
@ -248,7 +248,7 @@ CXXNewExpr::Create(const ASTContext &Ctx, bool IsGlobalNew,
InitializationStyle InitializationStyle, Expr *Initializer,
QualType Ty, TypeSourceInfo *AllocatedTypeInfo,
SourceRange Range, SourceRange DirectInitRange) {
bool IsArray = ArraySize.hasValue();
bool IsArray = ArraySize.has_value();
bool HasInit = Initializer != nullptr;
unsigned NumPlacementArgs = PlacementArgs.size();
bool IsParenTypeId = TypeIdParens.isValid();

View File

@ -429,7 +429,7 @@ public:
}
void onStartOfTranslationUnit() {
const bool EnableCheckProfiling = Options.CheckProfiling.hasValue();
const bool EnableCheckProfiling = Options.CheckProfiling.has_value();
TimeBucketRegion Timer;
for (MatchCallback *MC : Matchers->AllCallbacks) {
if (EnableCheckProfiling)
@ -439,7 +439,7 @@ public:
}
void onEndOfTranslationUnit() {
const bool EnableCheckProfiling = Options.CheckProfiling.hasValue();
const bool EnableCheckProfiling = Options.CheckProfiling.has_value();
TimeBucketRegion Timer;
for (MatchCallback *MC : Matchers->AllCallbacks) {
if (EnableCheckProfiling)
@ -1010,7 +1010,7 @@ private:
/// Used by \c matchDispatch() below.
template <typename T, typename MC>
void matchWithoutFilter(const T &Node, const MC &Matchers) {
const bool EnableCheckProfiling = Options.CheckProfiling.hasValue();
const bool EnableCheckProfiling = Options.CheckProfiling.has_value();
TimeBucketRegion Timer;
for (const auto &MP : Matchers) {
if (EnableCheckProfiling)
@ -1033,7 +1033,7 @@ private:
if (Filter.empty())
return;
const bool EnableCheckProfiling = Options.CheckProfiling.hasValue();
const bool EnableCheckProfiling = Options.CheckProfiling.has_value();
TimeBucketRegion Timer;
auto &Matchers = this->Matchers->DeclOrStmt;
for (unsigned short I : Filter) {

View File

@ -626,7 +626,7 @@ Optional<FileEntryRef> DirectoryLookup::DoFrameworkLookup(
// Set out flags.
InUserSpecifiedSystemFramework = CacheEntry.IsUserSpecifiedSystemFramework;
IsFrameworkFound = CacheEntry.Directory.hasValue();
IsFrameworkFound = CacheEntry.Directory.has_value();
if (RelativePath) {
RelativePath->clear();

View File

@ -1926,7 +1926,7 @@ Sema::isUnavailableAlignedAllocationFunction(const FunctionDecl &FD) const {
return false;
Optional<unsigned> AlignmentParam;
if (FD.isReplaceableGlobalAllocationFunction(&AlignmentParam) &&
AlignmentParam.hasValue())
AlignmentParam)
return true;
return false;
}
@ -2231,7 +2231,7 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
!Expr::hasAnyTypeDependentArguments(PlacementArgs) &&
FindAllocationFunctions(
StartLoc, SourceRange(PlacementLParen, PlacementRParen), Scope, Scope,
AllocType, ArraySize.hasValue(), PassAlignment, PlacementArgs,
AllocType, ArraySize.has_value(), PassAlignment, PlacementArgs,
OperatorNew, OperatorDelete))
return ExprError();
@ -2314,7 +2314,7 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
// Adjust placement args by prepending conjured size and alignment exprs.
llvm::SmallVector<Expr *, 8> CallArgs;
CallArgs.reserve(NumImplicitArgs + PlacementArgs.size());
CallArgs.emplace_back(AllocationSize.hasValue()
CallArgs.emplace_back(AllocationSize
? static_cast<Expr *>(&AllocationSizeLiteral)
: &OpaqueAllocationSize);
if (PassAlignment)

View File

@ -1406,7 +1406,7 @@ CallEventManager::getCaller(const StackFrameContext *CalleeCtx,
Trigger = Dtor->getBody();
return getCXXDestructorCall(Dtor, Trigger, ThisVal.getAsRegion(),
E.getAs<CFGBaseDtor>().hasValue(), State,
E.getAs<CFGBaseDtor>().has_value(), State,
CallerCtx);
}

View File

@ -2481,7 +2481,7 @@ RegionStoreManager::bindArray(RegionBindingsConstRef B,
RegionBindingsRef NewB(B);
for (; Size.hasValue() ? i < Size.getValue() : true ; ++i, ++VI) {
for (; Size ? i < *Size : true; ++i, ++VI) {
// The init list might be shorter than the array length.
if (VI == VE)
break;

View File

@ -572,7 +572,7 @@ private:
for (const auto &T : A.getTokenBuffer().expandedTokens().drop_back()) {
auto *L = new (A.getAllocator()) syntax::Leaf(&T);
L->Original = true;
L->CanModify = A.getTokenBuffer().spelledForExpanded(T).hasValue();
L->CanModify = A.getTokenBuffer().spelledForExpanded(T).has_value();
Trees.insert(Trees.end(), {&T, L});
}
}
@ -646,7 +646,7 @@ private:
// Mark that this node came from the AST and is backed by the source code.
Node->Original = true;
Node->CanModify =
A.getTokenBuffer().spelledForExpanded(Tokens).hasValue();
A.getTokenBuffer().spelledForExpanded(Tokens).has_value();
Trees.erase(BeginChildren, EndChildren);
Trees.insert({FirstToken, Node});

View File

@ -1318,7 +1318,7 @@ static Error UnbundleArchive() {
if (!NextTripleOrErr)
return NextTripleOrErr.takeError();
CodeObject = ((*NextTripleOrErr).hasValue()) ? **NextTripleOrErr : "";
CodeObject = NextTripleOrErr->value_or("");
} // End of processing of all bundle entries of this child of input archive.
} // End of while over children of input archive.

View File

@ -1229,7 +1229,7 @@ genConditionHandlerCall(Fortran::lower::AbstractConverter &converter,
boolValue(csi.hasErr),
boolValue(csi.hasEnd),
boolValue(csi.hasEor),
boolValue(csi.ioMsg.hasValue())};
boolValue(csi.ioMsg.has_value())};
builder.create<fir::CallOp>(loc, enableHandlers, ioArgs);
}
@ -1902,7 +1902,7 @@ genDataTransferStmt(Fortran::lower::AbstractConverter &converter,
llvm::Optional<fir::ExtendedValue> descRef =
isInternal ? maybeGetInternalIODescriptor(converter, stmt, stmtCtx)
: llvm::None;
const bool isInternalWithDesc = descRef.hasValue();
const bool isInternalWithDesc = descRef.has_value();
const bool isAsync = isDataTransferAsynchronous(loc, stmt);
const bool isNml = isDataTransferNamelist(stmt);

View File

@ -3079,7 +3079,7 @@ void fir::StringLitOp::build(mlir::OpBuilder &builder,
fir::CharacterType inType, llvm::StringRef val,
llvm::Optional<int64_t> len) {
auto valAttr = builder.getNamedAttr(value(), builder.getStringAttr(val));
int64_t length = len.hasValue() ? len.getValue() : inType.getLen();
int64_t length = len ? *len : inType.getLen();
auto lenAttr = mkNamedIntegerAttr(builder, size(), length);
result.addAttributes({valAttr, lenAttr});
result.addTypes(inType);
@ -3102,7 +3102,7 @@ void fir::StringLitOp::build(mlir::OpBuilder &builder,
llvm::Optional<std::int64_t> len) {
auto valAttr =
builder.getNamedAttr(xlist(), convertToArrayAttr(builder, vlist));
std::int64_t length = len.hasValue() ? len.getValue() : inType.getLen();
std::int64_t length = len ? *len : inType.getLen();
auto lenAttr = mkNamedIntegerAttr(builder, size(), length);
result.addAttributes({valAttr, lenAttr});
result.addTypes(inType);
@ -3115,7 +3115,7 @@ void fir::StringLitOp::build(mlir::OpBuilder &builder,
llvm::Optional<std::int64_t> len) {
auto valAttr =
builder.getNamedAttr(xlist(), convertToArrayAttr(builder, vlist));
std::int64_t length = len.hasValue() ? len.getValue() : inType.getLen();
std::int64_t length = len ? *len : inType.getLen();
auto lenAttr = mkNamedIntegerAttr(builder, size(), length);
result.addAttributes({valAttr, lenAttr});
result.addTypes(inType);
@ -3128,7 +3128,7 @@ void fir::StringLitOp::build(mlir::OpBuilder &builder,
llvm::Optional<std::int64_t> len) {
auto valAttr =
builder.getNamedAttr(xlist(), convertToArrayAttr(builder, vlist));
std::int64_t length = len.hasValue() ? len.getValue() : inType.getLen();
std::int64_t length = len ? *len : inType.getLen();
auto lenAttr = mkNamedIntegerAttr(builder, size(), length);
result.addAttributes({valAttr, lenAttr});
result.addTypes(inType);

View File

@ -212,7 +212,7 @@ bool CommandInterpreter::SetQuitExitCode(int exit_code) {
}
int CommandInterpreter::GetQuitExitCode(bool &exited) const {
exited = m_quit_exit_code.hasValue();
exited = m_quit_exit_code.has_value();
if (exited)
return *m_quit_exit_code;
return 0;

View File

@ -489,7 +489,7 @@ void SymbolFileBreakpad::AddSymbols(Symtab &symtab) {
/*is_trampoline*/ false, /*is_artificial*/ false,
AddressRange(section_sp, address - section_sp->GetFileAddress(),
size.value_or(0)),
size.hasValue(), /*contains_linker_annotations*/ false, /*flags*/ 0);
size.has_value(), /*contains_linker_annotations*/ false, /*flags*/ 0);
};
for (llvm::StringRef line : lines(Record::Public)) {

View File

@ -1373,7 +1373,7 @@ user_id_t SymbolFileDWARF::GetUID(DIERef ref) {
lldbassert(GetDwoNum().value_or(0) <= 0x3fffffff);
return user_id_t(GetDwoNum().value_or(0)) << 32 | ref.die_offset() |
lldb::user_id_t(GetDwoNum().hasValue()) << 62 |
lldb::user_id_t(GetDwoNum().has_value()) << 62 |
lldb::user_id_t(ref.section() == DIERef::Section::DebugTypes) << 63;
}

View File

@ -66,7 +66,7 @@ clang::QualType UdtRecordCompleter::AddBaseClassForTypeIndex(
std::unique_ptr<clang::CXXBaseSpecifier> base_spec =
m_ast_builder.clang().CreateBaseClassSpecifier(
qt.getAsOpaquePtr(), TranslateMemberAccess(access),
vtable_idx.hasValue(), udt_cvt.kind() == LF_CLASS);
vtable_idx.has_value(), udt_cvt.kind() == LF_CLASS);
if (!base_spec)
return {};

View File

@ -323,7 +323,7 @@ void CompileUnit::ResolveSymbolContext(
const bool inlines = false;
const bool exact = true;
const llvm::Optional<uint16_t> column =
src_location_spec.GetColumn().hasValue()
src_location_spec.GetColumn()
? llvm::Optional<uint16_t>(line_entry.column)
: llvm::None;

View File

@ -145,7 +145,7 @@ public:
DefaultInlineAdvice(InlineAdvisor *Advisor, CallBase &CB,
Optional<InlineCost> OIC, OptimizationRemarkEmitter &ORE,
bool EmitRemarks = true)
: InlineAdvice(Advisor, CB, ORE, OIC.hasValue()), OriginalCB(&CB),
: InlineAdvice(Advisor, CB, ORE, OIC.has_value()), OriginalCB(&CB),
OIC(OIC), EmitRemarks(EmitRemarks) {}
private:

View File

@ -35,7 +35,7 @@ inline bool hasAttachedCallOpBundle(const CallBase *CB) {
// functions.
return !CB->getFunctionType()->getReturnType()->isVoidTy() &&
CB->getOperandBundle(LLVMContext::OB_clang_arc_attachedcall)
.hasValue();
.has_value();
}
/// This function returns operand bundle clang_arc_attachedcall's argument,

View File

@ -34,7 +34,7 @@ public:
template <typename TFunc> void ForEachRecord(TFunc Func) {
Optional<TypeIndex> Next = getFirst();
while (Next.hasValue()) {
while (Next) {
TypeIndex N = *Next;
Func(N, getType(N));
Next = getNext(N);

View File

@ -34,7 +34,7 @@ public:
AttributeSpec(dwarf::Attribute A, dwarf::Form F, Optional<uint8_t> ByteSize)
: Attr(A), Form(F) {
assert(!isImplicitConst());
this->ByteSize.HasByteSize = ByteSize.hasValue();
this->ByteSize.HasByteSize = ByteSize.has_value();
if (this->ByteSize.HasByteSize)
this->ByteSize.ByteSize = *ByteSize;
}

View File

@ -8858,7 +8858,7 @@ ScalarEvolution::ExitLimit ScalarEvolution::computeShiftCompareExitLimit(
// and the kind of shift should be match the kind of shift we peeled
// off, if any.
(!PostShiftOpCode.hasValue() || *PostShiftOpCode == OpCodeOut);
(!PostShiftOpCode || *PostShiftOpCode == OpCodeOut);
};
PHINode *PN;

View File

@ -736,7 +736,7 @@ Error BitcodeAnalyzer::parseBlock(unsigned BlockID, unsigned IndentLevel,
BlockStats.NumInstances++;
// BLOCKINFO is a special part of the stream.
bool DumpRecords = O.hasValue();
bool DumpRecords = O.has_value();
if (BlockID == bitc::BLOCKINFO_BLOCK_ID) {
if (O && !O->DumpBlockinfo)
O->OS << Indent << "<BLOCKINFO_BLOCK/>\n";
@ -898,7 +898,7 @@ Error BitcodeAnalyzer::parseBlock(unsigned BlockID, unsigned IndentLevel,
// If we found a module hash, let's verify that it matches!
if (BlockID == bitc::MODULE_BLOCK_ID && Code == bitc::MODULE_CODE_HASH &&
CheckHash.hasValue()) {
CheckHash) {
if (Record.size() != 5)
O->OS << " (invalid)";
else {

View File

@ -885,7 +885,7 @@ ExpandMemCmpPass::runImpl(Function &F, const TargetLibraryInfo *TLI,
bool MadeChanges = false;
for (auto BBIt = F.begin(); BBIt != F.end();) {
if (runOnBlock(*BBIt, TLI, TTI, TL, DL, PSI, BFI,
DTU.hasValue() ? DTU.getPointer() : nullptr)) {
DTU ? DTU.getPointer() : nullptr)) {
MadeChanges = true;
// If changes were made, restart the function from the beginning, since
// the structure of the function was changed.

View File

@ -323,7 +323,7 @@ static SDValue getCopyFromPartsVector(SelectionDAG &DAG, const SDLoc &DL,
Optional<CallingConv::ID> CallConv) {
assert(ValueVT.isVector() && "Not a vector value");
assert(NumParts > 0 && "No parts to assemble!");
const bool IsABIRegCopy = CallConv.hasValue();
const bool IsABIRegCopy = CallConv.has_value();
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
SDValue Val = Parts[0];
@ -647,7 +647,7 @@ static void getCopyToPartsVector(SelectionDAG &DAG, const SDLoc &DL,
EVT ValueVT = Val.getValueType();
assert(ValueVT.isVector() && "Not a vector");
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
const bool IsABIRegCopy = CallConv.hasValue();
const bool IsABIRegCopy = CallConv.has_value();
if (NumParts == 1) {
EVT PartEVT = PartVT;

View File

@ -361,7 +361,7 @@ bool ShadowStackGCLowering::runOnFunction(Function &F) {
// For each instruction that escapes...
EscapeEnumerator EE(F, "gc_cleanup", /*HandleExceptions=*/true,
DTU.hasValue() ? DTU.getPointer() : nullptr);
DTU ? DTU.getPointer() : nullptr);
while (IRBuilder<> *AtExit = EE.Next()) {
// Pop the entry from the shadow stack. Don't reuse CurrentHead from
// AtEntry, since that would make the value live for the entire function.

View File

@ -355,7 +355,7 @@ Error PDBFileBuilder::commit(StringRef Filename, codeview::GUID *Guid) {
H->Age = Info->getAge();
H->Guid = Info->getGuid();
Optional<uint32_t> Sig = Info->getSignature();
H->Signature = Sig.hasValue() ? *Sig : time(nullptr);
H->Signature = Sig ? *Sig : time(nullptr);
}
return Buffer.commit();

View File

@ -379,7 +379,7 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V,
opc != Instruction::AddrSpaceCast &&
// Do not fold bitcast (gep) with inrange index, as this loses
// information.
!cast<GEPOperator>(CE)->getInRangeIndex().hasValue() &&
!cast<GEPOperator>(CE)->getInRangeIndex() &&
// Do not fold if the gep type is a vector, as bitcasting
// operand 0 of a vector gep will result in a bitcast between
// different sizes.

View File

@ -1582,7 +1582,7 @@ DIExpression *DIExpression::appendToStack(const DIExpression *Expr,
//
// Match .* DW_OP_stack_value (DW_OP_LLVM_fragment A B)?.
Optional<FragmentInfo> FI = Expr->getFragmentInfo();
unsigned DropUntilStackValue = FI.hasValue() ? 3 : 0;
unsigned DropUntilStackValue = FI ? 3 : 0;
ArrayRef<uint64_t> ExprOpsBeforeFragment =
Expr->getElements().drop_back(DropUntilStackValue);
bool NeedsDeref = (Expr->getNumElements() > DropUntilStackValue) &&

View File

@ -64,7 +64,7 @@ Value *VectorBuilder::createVectorInstruction(unsigned Opcode, Type *ReturnTy,
auto VLenPosOpt = VPIntrinsic::getVectorLengthParamPos(VPID);
size_t NumInstParams = InstOpArray.size();
size_t NumVPParams =
NumInstParams + MaskPosOpt.hasValue() + VLenPosOpt.hasValue();
NumInstParams + MaskPosOpt.has_value() + VLenPosOpt.has_value();
SmallVector<Value *, 6> IntrinParams;

View File

@ -4887,7 +4887,7 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
Optional<RoundingMode> RoundMode =
convertStrToRoundingMode(cast<MDString>(MD)->getString());
Check(RoundMode.hasValue() && RoundMode.getValue() != RoundingMode::Dynamic,
Check(RoundMode && *RoundMode != RoundingMode::Dynamic,
"unsupported rounding mode argument", Call);
break;
}
@ -6067,7 +6067,7 @@ void Verifier::verifyAttachedCallBundle(const CallBase &Call,
}
void Verifier::verifySourceDebugInfo(const DICompileUnit &U, const DIFile &F) {
bool HasSource = F.getSource().hasValue();
bool HasSource = F.getSource().has_value();
if (!HasSourceDebugInfo.count(&U))
HasSourceDebugInfo[&U] = HasSource;
CheckDI(HasSource == HasSourceDebugInfo[&U],

View File

@ -587,7 +587,7 @@ MCDwarfLineTableHeader::tryGetFile(StringRef &Directory,
// Keep track of whether any or all files have an MD5 checksum.
// If any files have embedded source, they all must.
if (MCDwarfFiles.empty()) {
trackMD5Usage(Checksum.hasValue());
trackMD5Usage(Checksum.has_value());
HasSource = (Source != None);
}
if (DwarfVersion >= 5 && isRootFile(RootFile, Directory, FileName, Checksum))
@ -650,7 +650,7 @@ MCDwarfLineTableHeader::tryGetFile(StringRef &Directory,
File.Name = std::string(FileName);
File.DirIndex = DirIndex;
File.Checksum = Checksum;
trackMD5Usage(Checksum.hasValue());
trackMD5Usage(Checksum.has_value());
File.Source = Source;
if (Source)
HasSource = true;

View File

@ -5831,7 +5831,7 @@ bool AArch64InstructionSelector::selectIntrinsic(MachineInstr &I,
uint64_t Key = I.getOperand(3).getImm();
Register DiscReg = I.getOperand(4).getReg();
auto DiscVal = getIConstantVRegVal(DiscReg, MRI);
bool IsDiscZero = DiscVal.hasValue() && DiscVal->isNullValue();
bool IsDiscZero = DiscVal && DiscVal->isNullValue();
if (Key > 3)
return false;

View File

@ -4386,7 +4386,7 @@ void ARMTargetLowering::VarArgStyleRegisters(CCState &CCInfo, SelectionDAG &DAG,
bool ARMTargetLowering::splitValueIntoRegisterParts(
SelectionDAG &DAG, const SDLoc &DL, SDValue Val, SDValue *Parts,
unsigned NumParts, MVT PartVT, Optional<CallingConv::ID> CC) const {
bool IsABIRegCopy = CC.hasValue();
bool IsABIRegCopy = CC.has_value();
EVT ValueVT = Val.getValueType();
if (IsABIRegCopy && (ValueVT == MVT::f16 || ValueVT == MVT::bf16) &&
PartVT == MVT::f32) {
@ -4404,7 +4404,7 @@ bool ARMTargetLowering::splitValueIntoRegisterParts(
SDValue ARMTargetLowering::joinRegisterPartsIntoValue(
SelectionDAG &DAG, const SDLoc &DL, const SDValue *Parts, unsigned NumParts,
MVT PartVT, EVT ValueVT, Optional<CallingConv::ID> CC) const {
bool IsABIRegCopy = CC.hasValue();
bool IsABIRegCopy = CC.has_value();
if (IsABIRegCopy && (ValueVT == MVT::f16 || ValueVT == MVT::bf16) &&
PartVT == MVT::f32) {
unsigned ValueBits = ValueVT.getSizeInBits();

View File

@ -295,7 +295,7 @@ void HexagonShuffler::restrictBranchOrder(HexagonPacketSummary const &Summary) {
Summary.branchInsts[0]->Core.setUnits(jumpSlot.first);
Summary.branchInsts[1]->Core.setUnits(jumpSlot.second);
const bool HasShuffledPacket = tryAuction(Summary).hasValue();
const bool HasShuffledPacket = tryAuction(Summary).has_value();
if (HasShuffledPacket)
return;
@ -599,7 +599,7 @@ void HexagonShuffler::restrictPreferSlot3(HexagonPacketSummary const &Summary,
// and then pin it to slot #3
const unsigned saveUnits = PrefSlot3Inst->Core.getUnits();
PrefSlot3Inst->Core.setUnits(saveUnits & Slot3Mask);
const bool HasShuffledPacket = tryAuction(Summary).hasValue();
const bool HasShuffledPacket = tryAuction(Summary).has_value();
if (HasShuffledPacket)
return;

View File

@ -11941,7 +11941,7 @@ bool RISCVTargetLowering::allowsMisalignedMemoryAccesses(
bool RISCVTargetLowering::splitValueIntoRegisterParts(
SelectionDAG &DAG, const SDLoc &DL, SDValue Val, SDValue *Parts,
unsigned NumParts, MVT PartVT, Optional<CallingConv::ID> CC) const {
bool IsABIRegCopy = CC.hasValue();
bool IsABIRegCopy = CC.has_value();
EVT ValueVT = Val.getValueType();
if (IsABIRegCopy && ValueVT == MVT::f16 && PartVT == MVT::f32) {
// Cast the f16 to i16, extend to i32, pad with ones to make a float nan,
@ -11995,7 +11995,7 @@ bool RISCVTargetLowering::splitValueIntoRegisterParts(
SDValue RISCVTargetLowering::joinRegisterPartsIntoValue(
SelectionDAG &DAG, const SDLoc &DL, const SDValue *Parts, unsigned NumParts,
MVT PartVT, EVT ValueVT, Optional<CallingConv::ID> CC) const {
bool IsABIRegCopy = CC.hasValue();
bool IsABIRegCopy = CC.has_value();
if (IsABIRegCopy && ValueVT == MVT::f16 && PartVT == MVT::f32) {
SDValue Val = Parts[0];

View File

@ -339,7 +339,7 @@ static bool genericValueTraversal(
if (auto *SI = dyn_cast<SelectInst>(V)) {
Optional<Constant *> C = A.getAssumedConstant(
*SI->getCondition(), QueryingAA, UsedAssumedInformation);
bool NoValueYet = !C.hasValue();
bool NoValueYet = !C;
if (NoValueYet || isa_and_nonnull<UndefValue>(*C))
continue;
if (auto *CI = dyn_cast_or_null<ConstantInt>(*C)) {
@ -9576,7 +9576,7 @@ struct AANoUndefImpl : AANoUndef {
// considered to be dead. We don't manifest noundef in such positions for
// the same reason above.
if (!A.getAssumedSimplified(getIRPosition(), *this, UsedAssumedInformation)
.hasValue())
.has_value())
return ChangeStatus::UNCHANGED;
return AANoUndef::manifest(A);
}

View File

@ -964,7 +964,7 @@ findExtractedInputToOverallInputMapping(OutlinableRegion &Region,
// argument in the overall function.
if (Input->isSwiftError()) {
assert(
!Group.SwiftErrorArgument.hasValue() &&
!Group.SwiftErrorArgument &&
"Argument already marked with swifterr for this OutlinableGroup!");
Group.SwiftErrorArgument = TypeIndex;
}
@ -1871,7 +1871,7 @@ replaceArgumentUses(OutlinableRegion &Region,
// If this is storing a PHINode, we must make sure it is included in the
// overall function.
if (!isa<PHINode>(ValueOperand) ||
Region.Candidate->getGVN(ValueOperand).hasValue()) {
Region.Candidate->getGVN(ValueOperand).has_value()) {
if (FirstFunction)
continue;
Value *CorrVal =

View File

@ -923,7 +923,7 @@ PreservedAnalyses LoopFlattenPass::run(LoopNest &LN, LoopAnalysisManager &LAM,
// this pass will simplify all loops that contain inner loops,
// regardless of whether anything ends up being flattened.
Changed |= Flatten(LN, &AR.DT, &AR.LI, &AR.SE, &AR.AC, &AR.TTI, &U,
MSSAU.hasValue() ? MSSAU.getPointer() : nullptr);
MSSAU ? MSSAU.getPointer() : nullptr);
if (!Changed)
return PreservedAnalyses::all();
@ -989,7 +989,7 @@ bool LoopFlattenLegacyPass::runOnFunction(Function &F) {
for (Loop *L : *LI) {
auto LN = LoopNest::getLoopNest(*L, *SE);
Changed |= Flatten(*LN, DT, LI, SE, AC, TTI, nullptr,
MSSAU.hasValue() ? MSSAU.getPointer() : nullptr);
MSSAU ? MSSAU.getPointer() : nullptr);
}
return Changed;
}

View File

@ -221,7 +221,7 @@ PreservedAnalyses LoopInstSimplifyPass::run(Loop &L, LoopAnalysisManager &AM,
AR.MSSA->verifyMemorySSA();
}
if (!simplifyLoopInst(L, AR.DT, AR.LI, AR.AC, AR.TLI,
MSSAU.hasValue() ? MSSAU.getPointer() : nullptr))
MSSAU ? MSSAU.getPointer() : nullptr))
return PreservedAnalyses::all();
auto PA = getLoopPassPreservedAnalyses();

View File

@ -140,7 +140,7 @@ static bool runPartiallyInlineLibCalls(Function &F, TargetLibraryInfo *TLI,
case LibFunc_sqrt:
if (TTI->haveFastSqrt(Call->getType()) &&
optimizeSQRT(Call, CalledFunc, *CurrBB, BB, TTI,
DTU.hasValue() ? DTU.getPointer() : nullptr))
DTU ? DTU.getPointer() : nullptr))
break;
continue;
default:

View File

@ -873,7 +873,7 @@ static bool runImpl(Function &F, const TargetTransformInfo &TTI,
for (BasicBlock &BB : llvm::make_early_inc_range(F)) {
bool ModifiedDTOnIteration = false;
MadeChange |= optimizeBlock(BB, ModifiedDTOnIteration, TTI, DL,
DTU.hasValue() ? DTU.getPointer() : nullptr);
DTU ? DTU.getPointer() : nullptr);
// Restart BB iteration if the dominator tree of the Function was changed
if (ModifiedDTOnIteration)

View File

@ -86,7 +86,7 @@ def SPIRV_Dialect : Dialect {
// enum class with `name`.
class SPV_IsKnownEnumCaseFor<string name> :
CPred<"::mlir::spirv::symbolize" # name # "("
"$_self.cast<IntegerAttr>().getValue().getZExtValue()).hasValue()">;
"$_self.cast<IntegerAttr>().getValue().getZExtValue()).has_value()">;
// Wrapper over base BitEnumAttr to set common fields.
class SPV_BitEnumAttr<string name, string description,

View File

@ -163,7 +163,7 @@ static Value generateInBoundsCheck(
Value cond; // Condition to be built...
// Condition check 1: Access in-bounds?
bool isBroadcast = !dim.hasValue(); // No in-bounds check for broadcasts.
bool isBroadcast = !dim; // No in-bounds check for broadcasts.
Location loc = xferOp.getLoc();
ImplicitLocOpBuilder lb(xferOp.getLoc(), b);
if (!xferOp.isDimInBounds(0) && !isBroadcast) {

View File

@ -151,7 +151,7 @@ LinalgTilingOptions &mlir::linalg::LinalgTilingOptions::scalarizeDynamicDims() {
// If the shape size is dynamic, tile by 1. Otherwise, do not tile (tile
// size 0).
for (Value shapeSize : shapeSizes)
tileSizes.push_back(getConstantIntValue(shapeSize).hasValue()
tileSizes.push_back(getConstantIntValue(shapeSize)
? b.create<arith::ConstantIndexOp>(loc, 0)
: b.create<arith::ConstantIndexOp>(loc, 1));
return tileSizes;

View File

@ -657,7 +657,7 @@ public:
Value zero = constantIndex(rewriter, loc, 0);
Value one = constantIndex(rewriter, loc, 1);
auto indicesValues = genSplitSparseConstant(rewriter, loc, src);
bool isCOOConstant = indicesValues.hasValue();
bool isCOOConstant = indicesValues.has_value();
Value indices;
Value values;
if (isCOOConstant) {

View File

@ -65,7 +65,7 @@ AttrOrTypeDef::AttrOrTypeDef(const llvm::Record *def) : def(def) {
// Verify the use of the mnemonic field.
bool hasCppFormat = hasCustomAssemblyFormat();
bool hasDeclarativeFormat = getAssemblyFormat().hasValue();
bool hasDeclarativeFormat = getAssemblyFormat().has_value();
if (getMnemonic()) {
if (hasCppFormat && hasDeclarativeFormat) {
PrintFatalError(getLoc(), "cannot specify both 'assemblyFormat' "
@ -269,7 +269,7 @@ StringRef AttrOrTypeParameter::getSyntax() const {
bool AttrOrTypeParameter::isOptional() const {
// Parameters with default values are automatically optional.
return getDefValue<llvm::BitInit>("isOptional").value_or(false) ||
getDefaultValue().hasValue();
getDefaultValue();
}
Optional<StringRef> AttrOrTypeParameter::getDefaultValue() const {

View File

@ -315,7 +315,7 @@ convertOperationImpl(Operation &opInst, llvm::IRBuilderBase &builder,
}
auto ft = LLVM::LLVMFunctionType::get(resultType, operandTypes);
llvm::InlineAsm *inlineAsmInst =
inlineAsmOp.getAsmDialect().hasValue()
inlineAsmOp.getAsmDialect()
? llvm::InlineAsm::get(
static_cast<llvm::FunctionType *>(
moduleTranslation.convertType(ft)),

View File

@ -816,7 +816,7 @@ convertOmpWsLoop(Operation &opInst, llvm::IRBuilderBase &builder,
allocaIP = findAllocaInsertPoint(builder, moduleTranslation);
// TODO: Handle doacross loops when the ordered clause has a parameter.
bool isOrdered = loop.ordered_val().hasValue();
bool isOrdered = loop.ordered_val().has_value();
Optional<omp::ScheduleModifier> scheduleModifier = loop.schedule_modifier();
bool isSimd = loop.simd_modifier();

View File

@ -251,7 +251,7 @@ void DefGen::emitParserPrinter() {
mnemonic->body().indent() << strfmt("return {\"{0}\"};", *def.getMnemonic());
// Declare the parser and printer, if needed.
bool hasAssemblyFormat = def.getAssemblyFormat().hasValue();
bool hasAssemblyFormat = def.getAssemblyFormat().has_value();
if (!def.hasCustomAssemblyFormat() && !hasAssemblyFormat)
return;