Don't use Optional::hasValue (NFC)

This commit is contained in:
Kazu Hirata 2022-06-20 11:33:56 -07:00
parent 037f09959a
commit 5413bf1bac
72 changed files with 99 additions and 99 deletions

View File

@ -53,7 +53,7 @@ void ClangTidyProfiling::printAsJSON(llvm::raw_ostream &OS) {
}
void ClangTidyProfiling::storeProfileData() {
assert(Storage.hasValue() && "We should have a filename.");
assert(Storage && "We should have a filename.");
llvm::SmallString<256> OutputDirectory(Storage->StoreFilename);
llvm::sys::path::remove_filename(OutputDirectory);
@ -80,7 +80,7 @@ ClangTidyProfiling::ClangTidyProfiling(llvm::Optional<StorageParams> Storage)
ClangTidyProfiling::~ClangTidyProfiling() {
TG.emplace("clang-tidy", "clang-tidy checks profiling", Records);
if (!Storage.hasValue())
if (!Storage)
printUserFriendlyTable(llvm::errs());
else
storeProfileData();

View File

@ -1683,7 +1683,7 @@ public:
if (CalledFn->getParamDecl(Idx) == PassedToParam)
TargetIdx.emplace(Idx);
assert(TargetIdx.hasValue() && "Matched, but didn't find index?");
assert(TargetIdx && "Matched, but didn't find index?");
TargetParams[PassedParamOfThisFn].insert(
{CalledFn->getCanonicalDecl(), *TargetIdx});
}

View File

@ -67,7 +67,7 @@ void SuspiciousMemoryComparisonCheck::check(
if (!PointeeType->isIncompleteType()) {
uint64_t PointeeSize = Ctx.getTypeSize(PointeeType);
if (ComparedBits.hasValue() && *ComparedBits >= PointeeSize &&
if (ComparedBits && *ComparedBits >= PointeeSize &&
!Ctx.hasUniqueObjectRepresentations(PointeeQualifiedType)) {
diag(CE->getBeginLoc(),
"comparing object representation of type %0 which does not have a "

View File

@ -65,7 +65,7 @@ analyzeFunction(const FunctionDecl &FuncDecl, ASTContext &ASTCtx) {
// `runDataflowAnalysis` doesn't guarantee that the exit block is visited;
// for example, when it is unreachable.
// FIXME: Diagnose violations even when the exit block is unreachable.
if (!ExitBlockState.hasValue())
if (!ExitBlockState)
return llvm::None;
return std::move(ExitBlockState->Lattice);

View File

@ -258,7 +258,7 @@ IdentifierNamingCheck::FileStyle IdentifierNamingCheck::getFileStyleFromOptions(
auto HPTOpt =
Options.get<IdentifierNamingCheck::HungarianPrefixType>(StyleString);
if (HPTOpt.hasValue() && !HungarianNotation.checkOptionValid(I))
if (HPTOpt && !HungarianNotation.checkOptionValid(I))
configurationDiag("invalid identifier naming option '%0'") << StyleString;
memcpy(&StyleString[StyleSize], "IgnoredRegexp", 13);

View File

@ -493,7 +493,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
Opts.CodeComplete.EnableSnippets = Params.capabilities.CompletionSnippets;
Opts.CodeComplete.IncludeFixIts = Params.capabilities.CompletionFixes;
if (!Opts.CodeComplete.BundleOverloads.hasValue())
if (!Opts.CodeComplete.BundleOverloads)
Opts.CodeComplete.BundleOverloads = Params.capabilities.HasSignatureHelp;
Opts.CodeComplete.DocumentationFormat =
Params.capabilities.CompletionDocumentationFormat;

View File

@ -97,7 +97,7 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
if (FIndex)
FIndex->updateMain(Path, AST);
assert(AST.getDiagnostics().hasValue() &&
assert(AST.getDiagnostics() &&
"We issue callback only with fresh preambles");
std::vector<Diag> Diagnostics = *AST.getDiagnostics();
if (ServerCallbacks)
@ -672,7 +672,7 @@ void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID,
}
Effect = T.takeError();
}
assert(Effect.hasValue() && "Expected at least one selection");
assert(Effect && "Expected at least one selection");
if (*Effect && (*Effect)->FormatEdits) {
// Format tweaks that require it centrally here.
for (auto &It : (*Effect)->ApplyEdits) {

View File

@ -835,7 +835,7 @@ struct CompletionRecorder : public CodeCompleteConsumer {
continue;
// Skip injected class name when no class scope is not explicitly set.
// E.g. show injected A::A in `using A::A^` but not in "A^".
if (Result.Declaration && !Context.getCXXScopeSpecifier().hasValue() &&
if (Result.Declaration && !Context.getCXXScopeSpecifier() &&
isInjectedClass(*Result.Declaration))
continue;
// We choose to never append '::' to completion results in clangd.
@ -1439,7 +1439,7 @@ public:
HeuristicPrefix = guessCompletionPrefix(SemaCCInput.ParseInput.Contents,
SemaCCInput.Offset);
populateContextWords(SemaCCInput.ParseInput.Contents);
if (Opts.Index && SpecFuzzyFind && SpecFuzzyFind->CachedReq.hasValue()) {
if (Opts.Index && SpecFuzzyFind && SpecFuzzyFind->CachedReq) {
assert(!SpecFuzzyFind->Result.valid());
SpecReq = speculativeFuzzyFindRequestForCompletion(
*SpecFuzzyFind->CachedReq, HeuristicPrefix);

View File

@ -544,7 +544,7 @@ IncludeFixer::unresolvedNameRecorder() {
}
std::vector<Fix> IncludeFixer::fixUnresolvedName() const {
assert(LastUnresolvedName.hasValue());
assert(LastUnresolvedName);
auto &Unresolved = *LastUnresolvedName;
vlog("Trying to fix unresolved name \"{0}\" in scopes: [{1}]",
Unresolved.Name, llvm::join(Unresolved.Scopes, ", "));

View File

@ -34,7 +34,7 @@ bool mapOptOrNull(const llvm::json::Value &Params, llvm::StringLiteral Prop,
assert(O);
auto *V = O->get(Prop);
// Field is missing or null.
if (!V || V->getAsNull().hasValue())
if (!V || V->getAsNull())
return true;
return fromJSON(*V, Out, P.field(Prop));
}
@ -608,7 +608,7 @@ llvm::json::Value toJSON(const Diagnostic &D) {
Diag["codeActions"] = D.codeActions;
if (!D.code.empty())
Diag["code"] = D.code;
if (D.codeDescription.hasValue())
if (D.codeDescription)
Diag["codeDescription"] = *D.codeDescription;
if (!D.source.empty())
Diag["source"] = D.source;
@ -926,7 +926,7 @@ llvm::json::Value toJSON(const MarkupContent &MC) {
llvm::json::Value toJSON(const Hover &H) {
llvm::json::Object Result{{"contents", toJSON(H.contents)}};
if (H.range.hasValue())
if (H.range)
Result["range"] = toJSON(*H.range);
return std::move(Result);
@ -1024,7 +1024,7 @@ llvm::json::Value toJSON(const CompletionList &L) {
}
llvm::json::Value toJSON(const ParameterInformation &PI) {
assert((PI.labelOffsets.hasValue() || !PI.labelString.empty()) &&
assert((PI.labelOffsets || !PI.labelString.empty()) &&
"parameter information label is required");
llvm::json::Object Result;
if (PI.labelOffsets)

View File

@ -121,7 +121,7 @@ llvm::Expected<SelectionRange> getSemanticRanges(ParsedAST &AST, Position Pos) {
}
auto SR = toHalfOpenFileRange(SM, LangOpts, Node->ASTNode.getSourceRange());
if (!SR.hasValue() || SM.getFileID(SR->getBegin()) != SM.getMainFileID()) {
if (!SR || SM.getFileID(SR->getBegin()) != SM.getMainFileID()) {
continue;
}
Range R;

View File

@ -820,7 +820,7 @@ tooling::Replacement replaceWithFuncCall(const NewFunction &ExtractedFunc,
tooling::Replacement createFunctionDefinition(const NewFunction &ExtractedFunc,
const SourceManager &SM) {
FunctionDeclKind DeclKind = InlineDefinition;
if (ExtractedFunc.ForwardDeclarationPoint.hasValue())
if (ExtractedFunc.ForwardDeclarationPoint)
DeclKind = OutOfLineDefinition;
std::string FunctionDef = ExtractedFunc.renderDeclaration(
DeclKind, *ExtractedFunc.SemanticDC, *ExtractedFunc.SyntacticDC, SM);

View File

@ -130,7 +130,7 @@ public:
Inputs.ClangTidyProvider = Opts.ClangTidyProvider;
Inputs.Opts.PreambleParseForwardingFunctions =
Opts.PreambleParseForwardingFunctions;
if (Contents.hasValue()) {
if (Contents) {
Inputs.Contents = *Contents;
log("Imaginary source file contents:\n{0}", Inputs.Contents);
} else {

View File

@ -304,7 +304,7 @@ private:
MayTakeTrivial = false;
}
// Is this the best branch so far? (Including if it's #if 1).
if (TookTrivial || !C.Taken.hasValue() || BranchScore > Best) {
if (TookTrivial || !C.Taken || BranchScore > Best) {
Best = BranchScore;
C.Taken = I;
}

View File

@ -90,7 +90,7 @@ std::string ForestNode::dumpRecursive(const Grammar &G,
Result += llvm::formatv("[{0,3}, {1,3}) ", P->startTokenIndex(), End);
Result += LineDec.Prefix;
Result += LineDec.First;
if (ElidedParent.hasValue()) {
if (ElidedParent) {
Result += G.symbolName(*ElidedParent);
Result += "~";
}

View File

@ -216,7 +216,7 @@ public:
}
bool isForeign() const {
assert(Foreign.hasValue() && "Foreign must be set before querying");
assert(Foreign && "Foreign must be set before querying");
return *Foreign;
}
void setForeign(bool B) const { Foreign = B; }

View File

@ -2073,7 +2073,7 @@ Optional<FileEntryRef> Preprocessor::LookupHeaderIncludeOrImport(
}
// If the file is still not found, just go with the vanilla diagnostic
assert(!File.hasValue() && "expected missing file");
assert(!File && "expected missing file");
Diag(FilenameTok, diag::err_pp_file_not_found)
<< OriginalFilename << FilenameRange;
if (IsFrameworkFound) {

View File

@ -120,7 +120,7 @@ AnalyzerOptions::mayInlineCXXMemberFunction(
.Case("none", CIMK_None)
.Default(None);
assert(K.hasValue() && "Invalid c++ member function inlining mode.");
assert(K && "Invalid c++ member function inlining mode.");
return *K >= Param;
}

View File

@ -1037,7 +1037,7 @@ bool ExprEngine::shouldInlineCall(const CallEvent &Call, const Decl *D,
CallInlinePolicy CIP = mayInlineCallKind(Call, Pred, Opts, CallOpts);
if (CIP != CIP_Allowed) {
if (CIP == CIP_DisallowedAlways) {
assert(!MayInline.hasValue() || MayInline.getValue());
assert(!MayInline || *MayInline);
Engine.FunctionSummaries->markShouldNotInline(D);
}
return false;

View File

@ -500,7 +500,7 @@ public:
}
void attachLoopCleanup(std::function<void(fir::FirOpBuilder &builder)> fn) {
if (!loopCleanup.hasValue()) {
if (!loopCleanup) {
loopCleanup = fn;
return;
}

View File

@ -2064,7 +2064,7 @@ private:
return;
}
if (lbounds.hasValue()) {
if (lbounds) {
// Array of POINTER entities, with elemental assignment.
if (!Fortran::lower::isWholePointer(assign.lhs))
fir::emitFatalError(toLocation(), "pointer assignment to non-pointer");

View File

@ -2590,7 +2590,7 @@ public:
return *allocatedResult;
}
if (!resultType.hasValue())
if (!resultType)
return mlir::Value{}; // subroutine call
// For now, Fortran return values are implemented with a single MLIR
// function return value.
@ -6410,7 +6410,7 @@ private:
mem = copyNeeded ? copyNextArrayCtorSection(exv, buffPos, buffSize, mem,
eleSz, eleTy, eleRefTy, resTy)
: fir::getBase(exv);
if (fir::isa_char(seqTy.getEleTy()) && !charLen.hasValue()) {
if (fir::isa_char(seqTy.getEleTy()) && !charLen) {
charLen = builder.createTemporary(loc, builder.getI64Type());
mlir::Value castLen =
builder.createConvert(loc, builder.getI64Type(), fir::getLen(exv));
@ -6492,7 +6492,7 @@ private:
mem = copyNeeded ? copyNextArrayCtorSection(exv, buffPos, buffSize, mem,
eleSz, eleTy, eleRefTy, resTy)
: fir::getBase(exv);
if (fir::isa_char(seqTy.getEleTy()) && !charLen.hasValue()) {
if (fir::isa_char(seqTy.getEleTy()) && !charLen) {
charLen = builder.createTemporary(loc, builder.getI64Type());
mlir::Value castLen =
builder.createConvert(loc, builder.getI64Type(), fir::getLen(exv));

View File

@ -1852,7 +1852,7 @@ void genBeginDataTransferCallArgs(
if constexpr (hasIOCtrl) { // READ or WRITE
if (isInternal) {
// descriptor or scalar variable; maybe explicit format; scratch area
if (descRef.hasValue()) {
if (descRef) {
mlir::Value desc = builder.createBox(loc, *descRef);
ioArgs.push_back(
builder.createConvert(loc, ioFuncTy.getInput(ioArgs.size()), desc));

View File

@ -2493,7 +2493,7 @@ private:
return mlir::emitError(loc, "invalid coordinate/check failed");
// check if the i-th coordinate relates to an array
if (dims.hasValue()) {
if (dims) {
arrIdx.push_back(nxtOpnd);
int dimsLeft = *dims;
if (dimsLeft > 1) {
@ -2529,7 +2529,7 @@ private:
offs.push_back(nxtOpnd);
}
if (dims.hasValue())
if (dims)
offs.append(arrIdx.rbegin(), arrIdx.rend());
mlir::Value base = operands[0];
mlir::Value retval = genGEP(loc, ty, rewriter, base, offs);

View File

@ -199,7 +199,7 @@ public:
// to call.
int dropFront = 0;
if constexpr (std::is_same_v<std::decay_t<A>, fir::CallOp>) {
if (!callOp.getCallee().hasValue()) {
if (!callOp.getCallee()) {
newInTys.push_back(fnTy.getInput(0));
newOpers.push_back(callOp.getOperand(0));
dropFront = 1;
@ -327,7 +327,7 @@ public:
newCall = rewriter->create<A>(loc, newResTys, newOpers);
}
LLVM_DEBUG(llvm::dbgs() << "replacing call with " << newCall << '\n');
if (wrap.hasValue())
if (wrap)
replaceOp(callOp, (*wrap)(newCall.getOperation()));
else
replaceOp(callOp, newCall.getResults());

View File

@ -38,7 +38,7 @@ static std::string doModules(llvm::ArrayRef<llvm::StringRef> mods) {
static std::string doModulesHost(llvm::ArrayRef<llvm::StringRef> mods,
llvm::Optional<llvm::StringRef> host) {
std::string result = doModules(mods);
if (host.hasValue())
if (host)
result.append("F").append(host->lower());
return result;
}

View File

@ -620,7 +620,7 @@ void LinkerDriver::addWinSysRootLibSearchPaths() {
// Parses LIB environment which contains a list of search paths.
void LinkerDriver::addLibSearchPaths() {
Optional<std::string> envOpt = Process::GetEnv("LIB");
if (!envOpt.hasValue())
if (!envOpt)
return;
StringRef env = saver().save(*envOpt);
while (!env.empty()) {

View File

@ -208,7 +208,7 @@ void LinkerDriver::addFile(StringRef path, bool withLOption) {
using namespace sys::fs;
Optional<MemoryBufferRef> buffer = readFile(path);
if (!buffer.hasValue())
if (!buffer)
return;
MemoryBufferRef mbref = *buffer;

View File

@ -697,7 +697,7 @@ static void updateARMVFPArgs(const ARMAttributeParser &attributes,
const InputFile *f) {
Optional<unsigned> attr =
attributes.getAttributeValue(ARMBuildAttrs::ABI_VFP_args);
if (!attr.hasValue())
if (!attr)
// If an ABI tag isn't present then it is implicitly given the value of 0
// which maps to ARMBuildAttrs::BaseAAPCS. However many assembler files,
// including some in glibc that don't use FP args (and should have value 3)

View File

@ -1350,7 +1350,7 @@ SmallVector<PhdrEntry *, 0> LinkerScript::createPhdrs() {
// Assign headers specified by linker script
for (size_t id : getPhdrIndices(sec)) {
ret[id]->add(sec);
if (!phdrsCommands[id].flags.hasValue())
if (!phdrsCommands[id].flags)
ret[id]->p_flags |= sec->getPhdrFlags();
}
}

View File

@ -234,7 +234,7 @@ std::vector<MemoryBufferRef> static getArchiveMembers(MemoryBufferRef mb) {
void LinkerDriver::addFile(StringRef path) {
Optional<MemoryBufferRef> buffer = readFile(path);
if (!buffer.hasValue())
if (!buffer)
return;
MemoryBufferRef mbref = *buffer;

View File

@ -44,7 +44,7 @@ namespace wasm {
void InputFile::checkArch(Triple::ArchType arch) const {
bool is64 = arch == Triple::wasm64;
if (is64 && !config->is64.hasValue()) {
if (is64 && !config->is64) {
fatal(toString(this) +
": must specify -mwasm64 to process wasm64 object files");
} else if (config->is64.value_or(false) != is64) {

View File

@ -754,7 +754,7 @@ void Writer::createCommandExportWrappers() {
const std::string &funcName = commandExportWrapperNames.back();
auto func = make<SyntheticFunction>(*f->getSignature(), funcName);
if (f->function->getExportName().hasValue())
if (f->function->getExportName())
func->setExportName(f->function->getExportName()->str());
else
func->setExportName(f->getName().str());

View File

@ -52,7 +52,7 @@ bool BreakpointIDList::AddBreakpointID(BreakpointID bp_id) {
bool BreakpointIDList::AddBreakpointID(const char *bp_id_str) {
auto bp_id = BreakpointID::ParseCanonicalReference(bp_id_str);
if (!bp_id.hasValue())
if (!bp_id)
return false;
m_breakpoint_ids.push_back(*bp_id);
@ -76,7 +76,7 @@ bool BreakpointIDList::FindBreakpointID(BreakpointID &bp_id,
bool BreakpointIDList::FindBreakpointID(const char *bp_id_str,
size_t *position) const {
auto bp_id = BreakpointID::ParseCanonicalReference(bp_id_str);
if (!bp_id.hasValue())
if (!bp_id)
return false;
return FindBreakpointID(*bp_id, position);
@ -89,7 +89,7 @@ void BreakpointIDList::InsertStringArray(
for (const char *str : string_array) {
auto bp_id = BreakpointID::ParseCanonicalReference(str);
if (bp_id.hasValue())
if (bp_id)
m_breakpoint_ids.push_back(*bp_id);
}
result.SetStatus(eReturnStatusSuccessFinishNoResult);
@ -163,7 +163,7 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target,
BreakpointSP breakpoint_sp;
auto bp_id = BreakpointID::ParseCanonicalReference(bp_id_str);
if (bp_id.hasValue())
if (bp_id)
breakpoint_sp = target->GetBreakpointByID(bp_id->GetBreakpointID());
if (!breakpoint_sp) {
new_args.Clear();

View File

@ -304,7 +304,7 @@ protected:
Thread *thread = m_exe_ctx.GetThreadPtr();
uint32_t frame_idx = UINT32_MAX;
if (m_options.relative_frame_offset.hasValue()) {
if (m_options.relative_frame_offset) {
// The one and only argument is a signed relative frame index
frame_idx = thread->GetSelectedFrameIndex();
if (frame_idx == UINT32_MAX)

View File

@ -1313,7 +1313,7 @@ void Debugger::ReportProgress(uint64_t progress_id, const std::string &message,
uint64_t completed, uint64_t total,
llvm::Optional<lldb::user_id_t> debugger_id) {
// Check if this progress is for a specific debugger.
if (debugger_id.hasValue()) {
if (debugger_id) {
// It is debugger specific, grab it and deliver the event if the debugger
// still exists.
DebuggerSP debugger_sp = FindDebuggerWithID(*debugger_id);

View File

@ -858,7 +858,7 @@ bool ClangUserExpression::Complete(ExecutionContext &exe_ctx,
// The line and column of the user expression inside the transformed source
// code.
unsigned user_expr_line, user_expr_column;
if (m_user_expression_start_pos.hasValue())
if (m_user_expression_start_pos)
AbsPosToLineColumnPos(*m_user_expression_start_pos, m_transformed_text,
user_expr_line, user_expr_column);
else

View File

@ -319,7 +319,7 @@ bool AppleObjCRuntime::AppleIsModuleObjCLibrary(const ModuleSP &module_sp) {
// we use the version of Foundation to make assumptions about the ObjC runtime
// on a target
uint32_t AppleObjCRuntime::GetFoundationVersion() {
if (!m_Foundation_major.hasValue()) {
if (!m_Foundation_major) {
const ModuleList &modules = m_process->GetTarget().GetImages();
for (uint32_t idx = 0; idx < modules.GetSize(); idx++) {
lldb::ModuleSP module_sp = modules.GetModuleAtIndex(idx);

View File

@ -6003,7 +6003,7 @@ llvm::VersionTuple ObjectFileMachO::GetMinimumOSVersion() {
}
llvm::VersionTuple ObjectFileMachO::GetSDKVersion() {
if (!m_sdk_versions.hasValue()) {
if (!m_sdk_versions) {
lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
for (uint32_t i = 0; i < m_header.ncmds; ++i) {
const lldb::offset_t load_cmd_offset = offset;
@ -6032,7 +6032,7 @@ llvm::VersionTuple ObjectFileMachO::GetSDKVersion() {
offset = load_cmd_offset + lc.cmdsize;
}
if (!m_sdk_versions.hasValue()) {
if (!m_sdk_versions) {
offset = MachHeaderSizeFromMagic(m_header.magic);
for (uint32_t i = 0; i < m_header.ncmds; ++i) {
const lldb::offset_t load_cmd_offset = offset;
@ -6069,7 +6069,7 @@ llvm::VersionTuple ObjectFileMachO::GetSDKVersion() {
}
}
if (!m_sdk_versions.hasValue())
if (!m_sdk_versions)
m_sdk_versions = llvm::VersionTuple();
}

View File

@ -28,7 +28,7 @@ NativeProcessELF::GetAuxValue(enum AuxVector::EntryType type) {
}
lldb::addr_t NativeProcessELF::GetSharedLibraryInfoAddress() {
if (!m_shared_library_info_addr.hasValue()) {
if (!m_shared_library_info_addr) {
if (GetAddressByteSize() == 8)
m_shared_library_info_addr =
GetELFImageInfoAddress<llvm::ELF::Elf64_Ehdr, llvm::ELF::Elf64_Phdr,

View File

@ -236,7 +236,7 @@ llvm::Optional<lldb::pid_t> MinidumpParser::GetPid() {
}
llvm::Optional<LinuxProcStatus> proc_status = GetLinuxProcStatus();
if (proc_status.hasValue()) {
if (proc_status) {
return proc_status->GetPid();
}

View File

@ -511,7 +511,7 @@ SymbolFileBreakpad::GetParameterStackSize(Symbol &symbol) {
symbol.GetAddress().GetFileAddress())) {
auto record = StackWinRecord::parse(
*LineIterator(*m_objfile_sp, Record::StackWin, entry->data));
assert(record.hasValue());
assert(record);
return record->ParameterSize;
}
return llvm::createStringError(llvm::inconvertibleErrorCode(),
@ -655,7 +655,7 @@ SymbolFileBreakpad::ParseCFIUnwindPlan(const Bookmark &bookmark,
LineIterator It(*m_objfile_sp, Record::StackCFI, bookmark),
End(*m_objfile_sp);
llvm::Optional<StackCFIRecord> init_record = StackCFIRecord::parse(*It);
assert(init_record.hasValue() && init_record->Size.hasValue() &&
assert(init_record && init_record->Size &&
"Record already parsed successfully in ParseUnwindData!");
auto plan_sp = std::make_shared<UnwindPlan>(lldb::eRegisterKindLLDB);

View File

@ -1453,7 +1453,7 @@ void PdbAstBuilder::ParseAllNamespacesPlusChildrenOf(
CVTagRecord tag = CVTagRecord::create(cvt);
if (!parent.hasValue()) {
if (!parent) {
clang::QualType qt = GetOrCreateType(tid);
CompleteType(qt);
continue;

View File

@ -1540,7 +1540,7 @@ static bool ClassTemplateAllowsToInstantiationArgs(
return false;
// Ensure that <typename...> != <typename>.
if (pack_parameter.hasValue() != instantiation_values.hasParameterPack())
if (pack_parameter.has_value() != instantiation_values.hasParameterPack())
return false;
// Compare the first pack parameter that was found with the first pack

View File

@ -84,7 +84,7 @@ bool SelectHelper::FDIsSetError(lldb::socket_t fd) const {
static void updateMaxFd(llvm::Optional<lldb::socket_t> &vold,
lldb::socket_t vnew) {
if (!vold.hasValue())
if (!vold)
vold = vnew;
else
vold = std::max(*vold, vnew);
@ -123,7 +123,7 @@ lldb_private::Status SelectHelper::Select() {
updateMaxFd(max_fd, fd);
}
if (!max_fd.hasValue()) {
if (!max_fd) {
error.SetErrorString("no valid file descriptors");
return error;
}

View File

@ -132,7 +132,7 @@ public:
uint32_t getRegister() const { return RegNum; }
int32_t getOffset() const { return Offset; }
uint32_t getAddressSpace() const {
assert(Kind == RegPlusOffset && AddrSpace.hasValue());
assert(Kind == RegPlusOffset && AddrSpace);
return *AddrSpace;
}
int32_t getConstant() const { return Offset; }

View File

@ -300,7 +300,7 @@ public:
void setDefaultConstrainedExcept(fp::ExceptionBehavior NewExcept) {
#ifndef NDEBUG
Optional<StringRef> ExceptStr = convertExceptionBehaviorToStr(NewExcept);
assert(ExceptStr.hasValue() && "Garbage strict exception behavior!");
assert(ExceptStr && "Garbage strict exception behavior!");
#endif
DefaultConstrainedExcept = NewExcept;
}
@ -309,7 +309,7 @@ public:
void setDefaultConstrainedRounding(RoundingMode NewRounding) {
#ifndef NDEBUG
Optional<StringRef> RoundingStr = convertRoundingModeToStr(NewRounding);
assert(RoundingStr.hasValue() && "Garbage strict rounding mode!");
assert(RoundingStr && "Garbage strict rounding mode!");
#endif
DefaultConstrainedRounding = NewRounding;
}

View File

@ -193,7 +193,7 @@ StringRef IRInstructionData::getCalleeName() const {
assert(isa<CallInst>(Inst) &&
"Can only get a name from a call instruction");
assert(CalleeName.hasValue() && "CalleeName has not been set");
assert(CalleeName && "CalleeName has not been set");
return *CalleeName;
}

View File

@ -7587,7 +7587,7 @@ LegalizerHelper::lowerMemcpyInline(MachineInstr &MI) {
// See if this is a constant length copy
auto LenVRegAndVal = getIConstantVRegValWithLookThrough(Len, MRI);
// FIXME: support dynamically sized G_MEMCPY_INLINE
assert(LenVRegAndVal.hasValue() &&
assert(LenVRegAndVal &&
"inline memcpy with dynamic size is not yet supported");
uint64_t KnownLen = LenVRegAndVal->Value.getZExtValue();
if (KnownLen == 0) {

View File

@ -468,7 +468,7 @@ unsigned DWARFLinker::shouldKeepSubprogramDIE(
if (!LowPc)
return Flags;
assert(LowPc.hasValue() && "low_pc attribute is not an address.");
assert(LowPc && "low_pc attribute is not an address.");
if (!RelocMgr.isLiveSubprogram(DIE, MyInfo))
return Flags;

View File

@ -49,7 +49,7 @@ ContinuationRecordBuilder::ContinuationRecordBuilder()
ContinuationRecordBuilder::~ContinuationRecordBuilder() = default;
void ContinuationRecordBuilder::begin(ContinuationRecordKind RecordKind) {
assert(!Kind.hasValue());
assert(!Kind);
Kind = RecordKind;
Buffer.clear();
SegmentWriter.setOffset(0);
@ -76,7 +76,7 @@ void ContinuationRecordBuilder::begin(ContinuationRecordKind RecordKind) {
template <typename RecordType>
void ContinuationRecordBuilder::writeMemberType(RecordType &Record) {
assert(Kind.hasValue());
assert(Kind);
uint32_t OriginalOffset = SegmentWriter.getOffset();
CVMemberRecord CVMR;

View File

@ -24,7 +24,7 @@ SymbolSerializer::SymbolSerializer(BumpPtrAllocator &Allocator,
Mapping(Writer, Container) {}
Error SymbolSerializer::visitSymbolBegin(CVSymbol &Record) {
assert(!CurrentSymbol.hasValue() && "Already in a symbol mapping!");
assert(!CurrentSymbol && "Already in a symbol mapping!");
Writer.setOffset(0);
@ -39,7 +39,7 @@ Error SymbolSerializer::visitSymbolBegin(CVSymbol &Record) {
}
Error SymbolSerializer::visitSymbolEnd(CVSymbol &Record) {
assert(CurrentSymbol.hasValue() && "Not in a symbol mapping!");
assert(CurrentSymbol && "Not in a symbol mapping!");
if (auto EC = Mapping.visitSymbolEnd(Record))
return EC;

View File

@ -525,7 +525,7 @@ SymbolGroupIterator &SymbolGroupIterator::operator++() {
}
void SymbolGroupIterator::scanToNextDebugS() {
assert(SectionIter.hasValue());
assert(SectionIter);
auto End = Value.File->obj().section_end();
auto &Iter = *SectionIter;
assert(!isEnd());
@ -551,7 +551,7 @@ bool SymbolGroupIterator::isEnd() const {
return Index == Count;
}
assert(SectionIter.hasValue());
assert(SectionIter);
return *SectionIter == Value.File->obj().section_end();
}

View File

@ -1971,7 +1971,7 @@ void Function::setEntryCount(ProfileCount Count,
const DenseSet<GlobalValue::GUID> *S) {
#if !defined(NDEBUG)
auto PrevCount = getEntryCount();
assert(!PrevCount.hasValue() || PrevCount->getType() == Count.getType());
assert(!PrevCount || PrevCount->getType() == Count.getType());
#endif
auto ImportGUIDs = getImportGUIDs();

View File

@ -617,7 +617,7 @@ CmpInst::Predicate VPCmpIntrinsic::getPredicate() const {
#define END_REGISTER_VP_INTRINSIC(VPID) break;
#include "llvm/IR/VPIntrinsics.def"
}
assert(CCArgIdx.hasValue() && "Unexpected vector-predicated comparison");
assert(CCArgIdx && "Unexpected vector-predicated comparison");
return IsFP ? getFPPredicateFromMD(getArgOperand(*CCArgIdx))
: getIntPredicateFromMD(getArgOperand(*CCArgIdx));
}

View File

@ -1335,7 +1335,7 @@ static void sectionMapping(IO &IO, ELFYAML::RawContentSection &Section) {
// We also support reading a content as array of bytes using the ContentArray
// key. obj2yaml never prints this field.
assert(!IO.outputting() || !Section.ContentBuf.hasValue());
assert(!IO.outputting() || !Section.ContentBuf);
IO.mapOptional("ContentArray", Section.ContentBuf);
if (Section.ContentBuf) {
if (Section.Content)

View File

@ -178,7 +178,7 @@ public:
MipsABIFlagsSection &getABIFlagsSection() { return ABIFlagsSection; }
const MipsABIInfo &getABI() const {
assert(ABI.hasValue() && "ABI hasn't been set!");
assert(ABI && "ABI hasn't been set!");
return *ABI;
}

View File

@ -182,7 +182,7 @@ static void getSortedConstantKeys(std::vector<Value *> &SortedKeys,
Value *OutlinableRegion::findCorrespondingValueIn(const OutlinableRegion &Other,
Value *V) {
Optional<unsigned> GVN = Candidate->getGVN(V);
assert(GVN.hasValue() && "No GVN for incoming value");
assert(GVN && "No GVN for incoming value");
Optional<unsigned> CanonNum = Candidate->getCanonicalNum(*GVN);
Optional<unsigned> FirstGVN = Other.Candidate->fromCanonicalNum(*CanonNum);
Optional<Value *> FoundValueOpt = Other.Candidate->fromGVN(*FirstGVN);
@ -1196,7 +1196,7 @@ static Optional<unsigned> getGVNForPHINode(OutlinableRegion &Region,
// Collect the canonical numbers of the values in the PHINode.
unsigned GVN = OGVN.getValue();
OGVN = Cand.getCanonicalNum(GVN);
assert(OGVN.hasValue() && "No GVN found for incoming value?");
assert(OGVN && "No GVN found for incoming value?");
PHIGVNs.push_back(*OGVN);
// Find the incoming block and use the canonical numbering as well to define
@ -1225,7 +1225,7 @@ static Optional<unsigned> getGVNForPHINode(OutlinableRegion &Region,
}
GVN = OGVN.getValue();
OGVN = Cand.getCanonicalNum(GVN);
assert(OGVN.hasValue() && "No GVN found for incoming block?");
assert(OGVN && "No GVN found for incoming block?");
PHIGVNs.push_back(*OGVN);
}

View File

@ -4582,7 +4582,7 @@ private:
// We have empty reaching kernels, therefore we cannot tell if the
// associated call site can be folded. At this moment, SimplifiedValue
// must be none.
assert(!SimplifiedValue.hasValue() && "SimplifiedValue should be none");
assert(!SimplifiedValue && "SimplifiedValue should be none");
}
return SimplifiedValue == SimplifiedValueBefore ? ChangeStatus::UNCHANGED
@ -4625,7 +4625,7 @@ private:
return indicatePessimisticFixpoint();
if (CallerKernelInfoAA.ReachingKernelEntries.empty()) {
assert(!SimplifiedValue.hasValue() &&
assert(!SimplifiedValue &&
"SimplifiedValue should keep none at this point");
return ChangeStatus::UNCHANGED;
}

View File

@ -1607,7 +1607,7 @@ static void fixFuncEntryCount(PGOUseFunc &Func, LoopInfo &LI,
BlockFrequencyInfo NBFI(F, NBPI, LI);
#ifndef NDEBUG
auto BFIEntryCount = F.getEntryCount();
assert(BFIEntryCount.hasValue() && (BFIEntryCount->getCount() > 0) &&
assert(BFIEntryCount && (BFIEntryCount->getCount() > 0) &&
"Invalid BFI Entrycount");
#endif
auto SumCount = APFloat::getZero(APFloat::IEEEdouble());

View File

@ -468,7 +468,7 @@ public:
int64_t RawValue = std::numeric_limits<int64_t>::min())
: LabelID(LabelID_.value_or(~0u)), EmitStr(EmitStr),
NumElements(NumElements), Flags(Flags), RawValue(RawValue) {
assert((!LabelID_.hasValue() || LabelID != ~0u) &&
assert((!LabelID_ || LabelID != ~0u) &&
"This value is reserved for non-labels");
}
MatchTableRecord(const MatchTableRecord &Other) = default;

View File

@ -1162,7 +1162,7 @@ void Simplex::undoLastConstraint() {
pivot(*maybeRow, column);
} else {
Optional<unsigned> row = findAnyPivotRow(column);
assert(row.hasValue() && "Pivot should always exist for a constraint!");
assert(row && "Pivot should always exist for a constraint!");
pivot(*row, column);
}
}
@ -1181,7 +1181,7 @@ void LexSimplexBase::undoLastConstraint() {
// long as we get the unknown to row orientation and remove it.
unsigned column = con.back().pos;
Optional<unsigned> row = findAnyPivotRow(column);
assert(row.hasValue() && "Pivot should always exist for a constraint!");
assert(row && "Pivot should always exist for a constraint!");
pivot(*row, column);
}
removeLastConstraintRowOrientation();

View File

@ -1272,7 +1272,7 @@ static bool isFusionProfitable(Operation *srcOpInst, Operation *srcStoreOpInst,
auto srcMemSizeVal = srcMemSize.getValue();
auto dstMemSizeVal = dstMemSize.getValue();
assert(sliceMemEstimate.hasValue() && "expected value");
assert(sliceMemEstimate && "expected value");
auto fusedMem = dstMemSizeVal + sliceMemEstimate.getValue();
LLVM_DEBUG(llvm::dbgs() << " src mem: " << srcMemSizeVal << "\n"

View File

@ -1440,7 +1440,7 @@ static bool checkLoopInterchangeDependences(
// This iterates through loops in the desired order.
for (unsigned j = 0; j < maxLoopDepth; ++j) {
unsigned permIndex = loopPermMapInv[j];
assert(depComps[permIndex].lb.hasValue());
assert(depComps[permIndex].lb);
int64_t depCompLb = depComps[permIndex].lb.getValue();
if (depCompLb > 0)
break;

View File

@ -1791,7 +1791,7 @@ MemRefType mlir::normalizeMemRefType(MemRefType memrefType, OpBuilder b,
auto ubConst = fac.getConstantBound(IntegerPolyhedron::UB, d);
// For a static memref and an affine map with no symbols, this is
// always bounded.
assert(ubConst.hasValue() && "should always have an upper bound");
assert(ubConst && "should always have an upper bound");
if (ubConst.getValue() < 0)
// This is due to an invalid map that maps to a negative space.
return memrefType;

View File

@ -104,7 +104,7 @@ getFuncAnalysisState(const AnalysisState &state) {
Optional<const FuncAnalysisState *> maybeState =
state.getDialectState<FuncAnalysisState>(
func::FuncDialect::getDialectNamespace());
assert(maybeState.hasValue() && "FuncAnalysisState does not exist");
assert(maybeState && "FuncAnalysisState does not exist");
return **maybeState;
}

View File

@ -82,7 +82,7 @@ getFuncAnalysisState(const AnalysisState &state) {
Optional<const FuncAnalysisState *> maybeState =
state.getDialectState<FuncAnalysisState>(
func::FuncDialect::getDialectNamespace());
assert(maybeState.hasValue() && "FuncAnalysisState does not exist");
assert(maybeState && "FuncAnalysisState does not exist");
return **maybeState;
}

View File

@ -306,7 +306,7 @@ bool matcher::operatesOnSuperVectorsOf(Operation &op,
auto ratio = shapeRatio(superVectorType, subVectorType);
// Sanity check.
assert((ratio.hasValue() || !mustDivide) &&
assert((ratio || !mustDivide) &&
"vector.transfer operation in which super-vector size is not an"
" integer multiple of sub-vector size");

View File

@ -781,7 +781,7 @@ bool mlir::lsp::fromJSON(const llvm::json::Value &value,
//===----------------------------------------------------------------------===//
llvm::json::Value mlir::lsp::toJSON(const ParameterInformation &value) {
assert((value.labelOffsets.hasValue() || !value.labelString.empty()) &&
assert((value.labelOffsets || !value.labelString.empty()) &&
"parameter information label is required");
llvm::json::Object result;
if (value.labelOffsets)

View File

@ -52,7 +52,7 @@ struct SymbolUsesPass
// Test the functionality of getSymbolUses.
symbolUses = SymbolTable::getSymbolUses(symbol, &module.getBodyRegion());
assert(symbolUses.hasValue() && "expected no unknown operations");
assert(symbolUses && "expected no unknown operations");
for (SymbolTable::SymbolUse symbolUse : *symbolUses) {
// Check that we can resolve back to our symbol.
if (SymbolTable::lookupNearestSymbolFrom(

View File

@ -718,7 +718,7 @@ static LogicalResult generateNamedGenericOpOds(LinalgOpConfig &opConfig,
static const char stmtFmt[] = "$_state.addAttribute(\"{0}\", {0});";
// Add the type conversion attributes to the op definition and builders.
if (isFunctionAttribute(arg.kind)) {
assert(arg.defaultFn.hasValue());
assert(arg.defaultFn);
std::string enumName = convertOperandKindToEnumName(arg.kind);
static const char typeFmt[] = "{0}::{1}";
static const char defFmt[] = "DefaultValuedAttr<{0}, \"{1}\">:${2}";
@ -861,7 +861,7 @@ exprs.push_back(getAffineConstantExpr(cst{1}, context));
for (LinalgOperandDef &arg : opConfig.structuredOp->args) {
if (arg.kind != LinalgOperandDefKind::IndexAttr)
continue;
assert(arg.indexAttrMap.hasValue());
assert(arg.indexAttrMap);
for (auto &en :
llvm::enumerate(arg.indexAttrMap->affineMap().getResults())) {
if (auto symbol = en.value().dyn_cast<AffineSymbolExpr>()) {
@ -958,7 +958,7 @@ std::string {0}::getLibraryCallName() {{
for (LinalgOperandDef &arg : opConfig.structuredOp->args) {
if (arg.kind != LinalgOperandDefKind::IndexAttr)
continue;
assert(arg.indexAttrMap.hasValue());
assert(arg.indexAttrMap);
// Verify index attribute. Paramters:
// {0}: Attribute name
// {1}: Attribute size

View File

@ -1745,7 +1745,7 @@ StringRef StaticMatcherHelper::getVerifierName(DagLeaf leaf) {
if (leaf.isAttrMatcher()) {
Optional<StringRef> constraint =
staticVerifierEmitter.getAttrConstraintFn(leaf.getAsConstraint());
assert(constraint.hasValue() && "attribute constraint was not uniqued");
assert(constraint && "attribute constraint was not uniqued");
return *constraint;
}
assert(leaf.isOperandMatcher());