[clang] Don't use Optional::hasValue (NFC)
This patch replaces Optional::hasValue with the implicit cast to bool in conditionals only.
This commit is contained in:
parent
0a0effdd5b
commit
97afce08cb
@ -544,8 +544,8 @@ public:
|
||||
/// flag may have been previously set, at which point it will not
|
||||
/// be reset unless one specifies to do so.
|
||||
void setPrunable(bool isPrunable, bool override = false) {
|
||||
if (IsPrunable.hasValue() && !override)
|
||||
return;
|
||||
if (IsPrunable && !override)
|
||||
return;
|
||||
IsPrunable = isPrunable;
|
||||
}
|
||||
|
||||
|
||||
@ -1766,9 +1766,9 @@ public:
|
||||
template <typename T>
|
||||
friend const SemaDiagnosticBuilder &
|
||||
operator<<(const SemaDiagnosticBuilder &Diag, const T &Value) {
|
||||
if (Diag.ImmediateDiag.hasValue())
|
||||
if (Diag.ImmediateDiag)
|
||||
*Diag.ImmediateDiag << Value;
|
||||
else if (Diag.PartialDiagId.hasValue())
|
||||
else if (Diag.PartialDiagId)
|
||||
Diag.S.DeviceDeferredDiags[Diag.Fn][*Diag.PartialDiagId].second
|
||||
<< Value;
|
||||
return Diag;
|
||||
@ -1780,26 +1780,26 @@ public:
|
||||
template <typename T, typename = typename std::enable_if<
|
||||
!std::is_lvalue_reference<T>::value>::type>
|
||||
const SemaDiagnosticBuilder &operator<<(T &&V) const {
|
||||
if (ImmediateDiag.hasValue())
|
||||
if (ImmediateDiag)
|
||||
*ImmediateDiag << std::move(V);
|
||||
else if (PartialDiagId.hasValue())
|
||||
else if (PartialDiagId)
|
||||
S.DeviceDeferredDiags[Fn][*PartialDiagId].second << std::move(V);
|
||||
return *this;
|
||||
}
|
||||
|
||||
friend const SemaDiagnosticBuilder &
|
||||
operator<<(const SemaDiagnosticBuilder &Diag, const PartialDiagnostic &PD) {
|
||||
if (Diag.ImmediateDiag.hasValue())
|
||||
if (Diag.ImmediateDiag)
|
||||
PD.Emit(*Diag.ImmediateDiag);
|
||||
else if (Diag.PartialDiagId.hasValue())
|
||||
else if (Diag.PartialDiagId)
|
||||
Diag.S.DeviceDeferredDiags[Diag.Fn][*Diag.PartialDiagId].second = PD;
|
||||
return Diag;
|
||||
}
|
||||
|
||||
void AddFixItHint(const FixItHint &Hint) const {
|
||||
if (ImmediateDiag.hasValue())
|
||||
if (ImmediateDiag)
|
||||
ImmediateDiag->AddFixItHint(Hint);
|
||||
else if (PartialDiagId.hasValue())
|
||||
else if (PartialDiagId)
|
||||
S.DeviceDeferredDiags[Fn][*PartialDiagId].second.AddFixItHint(Hint);
|
||||
}
|
||||
|
||||
|
||||
@ -341,7 +341,7 @@ protected:
|
||||
addStateConstraints(NewState);
|
||||
|
||||
Optional<bool> res = Solver->check();
|
||||
if (!res.hasValue())
|
||||
if (!res)
|
||||
Cached[hash] = ConditionTruthVal();
|
||||
else
|
||||
Cached[hash] = ConditionTruthVal(res.getValue());
|
||||
|
||||
@ -168,7 +168,7 @@ OMPDeclareTargetDeclAttr::getActiveAttr(const ValueDecl *VD) {
|
||||
llvm::Optional<OMPDeclareTargetDeclAttr::MapTypeTy>
|
||||
OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(const ValueDecl *VD) {
|
||||
llvm::Optional<OMPDeclareTargetDeclAttr *> ActiveAttr = getActiveAttr(VD);
|
||||
if (ActiveAttr.hasValue())
|
||||
if (ActiveAttr)
|
||||
return ActiveAttr.getValue()->getMapType();
|
||||
return llvm::None;
|
||||
}
|
||||
@ -176,7 +176,7 @@ OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(const ValueDecl *VD) {
|
||||
llvm::Optional<OMPDeclareTargetDeclAttr::DevTypeTy>
|
||||
OMPDeclareTargetDeclAttr::getDeviceType(const ValueDecl *VD) {
|
||||
llvm::Optional<OMPDeclareTargetDeclAttr *> ActiveAttr = getActiveAttr(VD);
|
||||
if (ActiveAttr.hasValue())
|
||||
if (ActiveAttr)
|
||||
return ActiveAttr.getValue()->getDevType();
|
||||
return llvm::None;
|
||||
}
|
||||
@ -184,7 +184,7 @@ OMPDeclareTargetDeclAttr::getDeviceType(const ValueDecl *VD) {
|
||||
llvm::Optional<SourceLocation>
|
||||
OMPDeclareTargetDeclAttr::getLocation(const ValueDecl *VD) {
|
||||
llvm::Optional<OMPDeclareTargetDeclAttr *> ActiveAttr = getActiveAttr(VD);
|
||||
if (ActiveAttr.hasValue())
|
||||
if (ActiveAttr)
|
||||
return ActiveAttr.getValue()->getRange().getBegin();
|
||||
return llvm::None;
|
||||
}
|
||||
|
||||
@ -397,9 +397,9 @@ bool Parser::parseIdentifierPrefixImpl(VariantValue *Value) {
|
||||
assert(NamedValue.isMatcher());
|
||||
llvm::Optional<DynTypedMatcher> Result =
|
||||
NamedValue.getMatcher().getSingleMatcher();
|
||||
if (Result.hasValue()) {
|
||||
if (Result) {
|
||||
llvm::Optional<DynTypedMatcher> Bound = Result->tryBind(BindID);
|
||||
if (Bound.hasValue()) {
|
||||
if (Bound) {
|
||||
*Value = VariantMatcher::SingleMatcher(*Bound);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -797,9 +797,9 @@ VariantMatcher Registry::constructBoundMatcher(MatcherCtor Ctor,
|
||||
if (Out.isNull()) return Out;
|
||||
|
||||
llvm::Optional<DynTypedMatcher> Result = Out.getSingleMatcher();
|
||||
if (Result.hasValue()) {
|
||||
if (Result) {
|
||||
llvm::Optional<DynTypedMatcher> Bound = Result->tryBind(BindID);
|
||||
if (Bound.hasValue()) {
|
||||
if (Bound) {
|
||||
return VariantMatcher::SingleMatcher(*Bound);
|
||||
}
|
||||
}
|
||||
|
||||
@ -697,7 +697,7 @@ static Stmt *create_OSAtomicCompareAndSwap(ASTContext &C, const FunctionDecl *D)
|
||||
|
||||
Stmt *BodyFarm::getBody(const FunctionDecl *D) {
|
||||
Optional<Stmt *> &Val = Bodies[D];
|
||||
if (Val.hasValue())
|
||||
if (Val)
|
||||
return Val.getValue();
|
||||
|
||||
Val = nullptr;
|
||||
@ -872,7 +872,7 @@ Stmt *BodyFarm::getBody(const ObjCMethodDecl *D) {
|
||||
return nullptr;
|
||||
|
||||
Optional<Stmt *> &Val = Bodies[D];
|
||||
if (Val.hasValue())
|
||||
if (Val)
|
||||
return Val.getValue();
|
||||
Val = nullptr;
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ buildStmtToBasicBlockMap(const CFG &Cfg) {
|
||||
|
||||
for (const CFGElement &Element : *Block) {
|
||||
auto Stmt = Element.getAs<CFGStmt>();
|
||||
if (!Stmt.hasValue())
|
||||
if (!Stmt)
|
||||
continue;
|
||||
|
||||
StmtToBlock[Stmt.getValue().getStmt()] = Block;
|
||||
|
||||
@ -50,7 +50,7 @@ public:
|
||||
auto BlockIT = CFCtx.getStmtToBlock().find(&ignoreCFGOmittedNodes(S));
|
||||
assert(BlockIT != CFCtx.getStmtToBlock().end());
|
||||
const auto &State = BlockToState[BlockIT->getSecond()->getBlockID()];
|
||||
assert(State.hasValue());
|
||||
assert(State);
|
||||
return &State.getValue().Env;
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ static TypeErasedDataflowAnalysisState computeBlockInputState(
|
||||
// loop back edge to `Block`.
|
||||
const llvm::Optional<TypeErasedDataflowAnalysisState> &MaybePredState =
|
||||
BlockStates[Pred->getBlockID()];
|
||||
if (!MaybePredState.hasValue())
|
||||
if (!MaybePredState)
|
||||
continue;
|
||||
|
||||
TypeErasedDataflowAnalysisState PredState = MaybePredState.getValue();
|
||||
@ -222,14 +222,14 @@ static TypeErasedDataflowAnalysisState computeBlockInputState(
|
||||
}
|
||||
}
|
||||
|
||||
if (MaybeState.hasValue()) {
|
||||
if (MaybeState) {
|
||||
Analysis.joinTypeErased(MaybeState->Lattice, PredState.Lattice);
|
||||
MaybeState->Env.join(PredState.Env, Analysis);
|
||||
} else {
|
||||
MaybeState = std::move(PredState);
|
||||
}
|
||||
}
|
||||
if (!MaybeState.hasValue()) {
|
||||
if (!MaybeState) {
|
||||
// FIXME: Consider passing `Block` to `Analysis.typeErasedInitialElement()`
|
||||
// to enable building analyses like computation of dominators that
|
||||
// initialize the state of each basic block differently.
|
||||
@ -367,7 +367,7 @@ runTypeErasedDataflowAnalysis(const ControlFlowContext &CFCtx,
|
||||
TypeErasedDataflowAnalysisState NewBlockState =
|
||||
transferBlock(CFCtx, BlockStates, *Block, InitEnv, Analysis);
|
||||
|
||||
if (OldBlockState.hasValue() &&
|
||||
if (OldBlockState &&
|
||||
Analysis.isEqualTypeErased(OldBlockState.getValue().Lattice,
|
||||
NewBlockState.Lattice) &&
|
||||
OldBlockState->Env.equivalentTo(NewBlockState.Env, Analysis)) {
|
||||
|
||||
@ -319,7 +319,7 @@ static Optional<bool> comparePath(const PathPieces &X, const PathPieces &Y) {
|
||||
|
||||
for ( ; X_I != X_end && Y_I != Y_end; ++X_I, ++Y_I) {
|
||||
Optional<bool> b = comparePiece(**X_I, **Y_I);
|
||||
if (b.hasValue())
|
||||
if (b)
|
||||
return b.getValue();
|
||||
}
|
||||
|
||||
@ -396,7 +396,7 @@ static bool compare(const PathDiagnostic &X, const PathDiagnostic &Y) {
|
||||
return (*XI) < (*YI);
|
||||
}
|
||||
Optional<bool> b = comparePath(X.path, Y.path);
|
||||
assert(b.hasValue());
|
||||
assert(b);
|
||||
return b.getValue();
|
||||
}
|
||||
|
||||
|
||||
@ -148,7 +148,7 @@ public:
|
||||
Value getValue(const CFGBlock *block, const CFGBlock *dstBlock,
|
||||
const VarDecl *vd) {
|
||||
const Optional<unsigned> &idx = declToIndex.getValueIndex(vd);
|
||||
assert(idx.hasValue());
|
||||
assert(idx);
|
||||
return getValueVector(block)[idx.getValue()];
|
||||
}
|
||||
};
|
||||
@ -209,7 +209,7 @@ void CFGBlockValues::resetScratch() {
|
||||
|
||||
ValueVector::reference CFGBlockValues::operator[](const VarDecl *vd) {
|
||||
const Optional<unsigned> &idx = declToIndex.getValueIndex(vd);
|
||||
assert(idx.hasValue());
|
||||
assert(idx);
|
||||
return scratch[idx.getValue()];
|
||||
}
|
||||
|
||||
|
||||
@ -251,7 +251,7 @@ bool RISCVTargetInfo::hasFeature(StringRef Feature) const {
|
||||
.Case("riscv64", Is64Bit)
|
||||
.Case("64bit", Is64Bit)
|
||||
.Default(None);
|
||||
if (Result.hasValue())
|
||||
if (Result)
|
||||
return Result.getValue();
|
||||
|
||||
if (ISAInfo->isSupportedExtensionFeature(Feature))
|
||||
|
||||
@ -2826,12 +2826,12 @@ bool CodeGenModule::isProfileInstrExcluded(llvm::Function *Fn,
|
||||
CodeGenOptions::ProfileInstrKind Kind = getCodeGenOpts().getProfileInstr();
|
||||
// First, check the function name.
|
||||
Optional<bool> V = ProfileList.isFunctionExcluded(Fn->getName(), Kind);
|
||||
if (V.hasValue())
|
||||
if (V)
|
||||
return *V;
|
||||
// Next, check the source location.
|
||||
if (Loc.isValid()) {
|
||||
Optional<bool> V = ProfileList.isLocationExcluded(Loc, Kind);
|
||||
if (V.hasValue())
|
||||
if (V)
|
||||
return *V;
|
||||
}
|
||||
// If location is unknown, this may be a compiler-generated function. Assume
|
||||
|
||||
@ -475,7 +475,7 @@ void AVR::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
D.Diag(diag::warn_drv_avr_stdlib_not_linked);
|
||||
}
|
||||
|
||||
if (SectionAddressData.hasValue()) {
|
||||
if (SectionAddressData) {
|
||||
std::string DataSectionArg = std::string("-Tdata=0x") +
|
||||
llvm::utohexstr(SectionAddressData.getValue());
|
||||
CmdArgs.push_back(Args.MakeArgString(DataSectionArg));
|
||||
|
||||
@ -2086,7 +2086,7 @@ void Generic_GCC::GCCInstallationDetector::print(raw_ostream &OS) const {
|
||||
}
|
||||
|
||||
bool Generic_GCC::GCCInstallationDetector::getBiarchSibling(Multilib &M) const {
|
||||
if (BiarchSibling.hasValue()) {
|
||||
if (BiarchSibling) {
|
||||
M = BiarchSibling.getValue();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -725,11 +725,11 @@ static bool getLiteralInfo(SourceRange literalRange,
|
||||
break;
|
||||
}
|
||||
|
||||
if (!UpperU.hasValue() && !UpperL.hasValue())
|
||||
if (!UpperU && !UpperL)
|
||||
UpperU = UpperL = true;
|
||||
else if (UpperU.hasValue() && !UpperL.hasValue())
|
||||
else if (UpperU && !UpperL)
|
||||
UpperL = UpperU;
|
||||
else if (UpperL.hasValue() && !UpperU.hasValue())
|
||||
else if (UpperL && !UpperU)
|
||||
UpperU = UpperL;
|
||||
|
||||
Info.U = *UpperU ? "U" : "u";
|
||||
|
||||
@ -1951,7 +1951,7 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
|
||||
<< "-fdiagnostics-hotness-threshold=";
|
||||
} else {
|
||||
Opts.DiagnosticsHotnessThreshold = *ResultOrErr;
|
||||
if ((!Opts.DiagnosticsHotnessThreshold.hasValue() ||
|
||||
if ((!Opts.DiagnosticsHotnessThreshold ||
|
||||
Opts.DiagnosticsHotnessThreshold.getValue() > 0) &&
|
||||
!UsingProfile)
|
||||
Diags.Report(diag::warn_drv_diagnostics_hotness_requires_pgo)
|
||||
@ -1968,7 +1968,7 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
|
||||
<< "-fdiagnostics-misexpect-tolerance=";
|
||||
} else {
|
||||
Opts.DiagnosticsMisExpectTolerance = *ResultOrErr;
|
||||
if ((!Opts.DiagnosticsMisExpectTolerance.hasValue() ||
|
||||
if ((!Opts.DiagnosticsMisExpectTolerance ||
|
||||
Opts.DiagnosticsMisExpectTolerance.getValue() > 0) &&
|
||||
!UsingProfile)
|
||||
Diags.Report(diag::warn_drv_diagnostics_misexpect_requires_pgo)
|
||||
@ -2578,10 +2578,10 @@ static void GenerateFrontendArgs(const FrontendOptions &Opts,
|
||||
for (const auto &ModuleFile : Opts.ModuleFiles)
|
||||
GenerateArg(Args, OPT_fmodule_file, ModuleFile, SA);
|
||||
|
||||
if (Opts.AuxTargetCPU.hasValue())
|
||||
if (Opts.AuxTargetCPU)
|
||||
GenerateArg(Args, OPT_aux_target_cpu, *Opts.AuxTargetCPU, SA);
|
||||
|
||||
if (Opts.AuxTargetFeatures.hasValue())
|
||||
if (Opts.AuxTargetFeatures)
|
||||
for (const auto &Feature : *Opts.AuxTargetFeatures)
|
||||
GenerateArg(Args, OPT_aux_target_feature, Feature, SA);
|
||||
|
||||
|
||||
@ -831,11 +831,11 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
|
||||
VersionTuple tuple = LangOpts.ObjCRuntime.getVersion();
|
||||
|
||||
unsigned minor = 0;
|
||||
if (tuple.getMinor().hasValue())
|
||||
if (tuple.getMinor())
|
||||
minor = tuple.getMinor().getValue();
|
||||
|
||||
unsigned subminor = 0;
|
||||
if (tuple.getSubminor().hasValue())
|
||||
if (tuple.getSubminor())
|
||||
subminor = tuple.getSubminor().getValue();
|
||||
|
||||
Builder.defineMacro("__OBJFW_RUNTIME_ABI__",
|
||||
|
||||
@ -549,7 +549,7 @@ Scanner::tryLexIdentifierOrSkipLine(const char *&First, const char *const End) {
|
||||
|
||||
StringRef Scanner::lexIdentifier(const char *&First, const char *const End) {
|
||||
Optional<StringRef> Id = tryLexIdentifierOrSkipLine(First, End);
|
||||
assert(Id.hasValue() && "expected identifier token");
|
||||
assert(Id && "expected identifier token");
|
||||
return Id.getValue();
|
||||
}
|
||||
|
||||
|
||||
@ -209,7 +209,7 @@ MacroDirective::DefInfo MacroDirective::getDefinition() {
|
||||
}
|
||||
|
||||
VisibilityMacroDirective *VisMD = cast<VisibilityMacroDirective>(MD);
|
||||
if (!isPublic.hasValue())
|
||||
if (!isPublic)
|
||||
isPublic = VisMD->isPublic();
|
||||
}
|
||||
|
||||
|
||||
@ -1325,7 +1325,7 @@ already_lexed:
|
||||
|
||||
// The last ')' has been reached; return the value if one found or
|
||||
// a diagnostic and a dummy value.
|
||||
if (Result.hasValue()) {
|
||||
if (Result) {
|
||||
OS << Result.getValue();
|
||||
// For strict conformance to __has_cpp_attribute rules, use 'L'
|
||||
// suffix for dated literals.
|
||||
|
||||
@ -114,7 +114,7 @@ bool PreprocessingRecord::isEntityInFileID(iterator PPEI, FileID FID) {
|
||||
// deserializing it.
|
||||
Optional<bool> IsInFile =
|
||||
ExternalSource->isPreprocessedEntityInFileID(LoadedIndex, FID);
|
||||
if (IsInFile.hasValue())
|
||||
if (IsInFile)
|
||||
return IsInFile.getValue();
|
||||
|
||||
// The external source did not provide a definite answer, go and deserialize
|
||||
|
||||
@ -1873,7 +1873,7 @@ void Parser::ParseOMPDeclareTargetClauses(
|
||||
if (IsDeviceTypeClause) {
|
||||
Optional<SimpleClauseData> DevTypeData =
|
||||
parseOpenMPSimpleClause(*this, OMPC_device_type);
|
||||
if (DevTypeData.hasValue()) {
|
||||
if (DevTypeData) {
|
||||
if (DeviceTypeLoc.isValid()) {
|
||||
// We already saw another device_type clause, diagnose it.
|
||||
Diag(DevTypeData.getValue().Loc,
|
||||
|
||||
@ -444,7 +444,7 @@ bool Sema::inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl,
|
||||
// If no target was inferred, mark this member as __host__ __device__;
|
||||
// it's the least restrictive option that can be invoked from any target.
|
||||
bool NeedsH = true, NeedsD = true;
|
||||
if (InferredTarget.hasValue()) {
|
||||
if (InferredTarget) {
|
||||
if (InferredTarget.getValue() == CFT_Device)
|
||||
NeedsH = false;
|
||||
else if (InferredTarget.getValue() == CFT_Host)
|
||||
|
||||
@ -1873,7 +1873,7 @@ static ExprResult SemaBuiltinLaunder(Sema &S, CallExpr *TheCall) {
|
||||
return 2;
|
||||
return llvm::Optional<unsigned>{};
|
||||
}();
|
||||
if (DiagSelect.hasValue()) {
|
||||
if (DiagSelect) {
|
||||
S.Diag(TheCall->getBeginLoc(), diag::err_builtin_launder_invalid_arg)
|
||||
<< DiagSelect.getValue() << TheCall->getSourceRange();
|
||||
return ExprError();
|
||||
|
||||
@ -15444,7 +15444,7 @@ void Sema::AddKnownFunctionAttributesForReplaceableGlobalAllocationFunction(
|
||||
// (3.1) If the allocation function takes an argument of type
|
||||
// std::align_val_t, the storage will have the alignment
|
||||
// specified by the value of this argument.
|
||||
if (AlignmentParam.hasValue() && !FD->hasAttr<AllocAlignAttr>()) {
|
||||
if (AlignmentParam && !FD->hasAttr<AllocAlignAttr>()) {
|
||||
FD->addAttr(AllocAlignAttr::CreateImplicit(
|
||||
Context, ParamIdx(AlignmentParam.getValue(), FD), FD->getLocation()));
|
||||
}
|
||||
@ -19102,12 +19102,12 @@ Sema::FunctionEmissionStatus Sema::getEmissionStatus(FunctionDecl *FD,
|
||||
// #pragma omp declare target to(*) device_type(*).
|
||||
// Therefore DevTy having no value does not imply host. The emission status
|
||||
// will be checked again at the end of compilation unit with Final = true.
|
||||
if (DevTy.hasValue())
|
||||
if (DevTy)
|
||||
if (*DevTy == OMPDeclareTargetDeclAttr::DT_Host)
|
||||
return FunctionEmissionStatus::OMPDiscarded;
|
||||
// If we have an explicit value for the device type, or we are in a target
|
||||
// declare context, we need to emit all extern and used symbols.
|
||||
if (isInOpenMPDeclareTargetContext() || DevTy.hasValue())
|
||||
if (isInOpenMPDeclareTargetContext() || DevTy)
|
||||
if (IsEmittedForExternalSymbol())
|
||||
return FunctionEmissionStatus::Emitted;
|
||||
// Device mode only emits what it must, if it wasn't tagged yet and needed,
|
||||
|
||||
@ -2680,8 +2680,8 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
|
||||
auto Major = Version.getMajor();
|
||||
auto NewMajor = Major >= 9 ? Major - 7 : 0;
|
||||
if (NewMajor >= 2) {
|
||||
if (Version.getMinor().hasValue()) {
|
||||
if (Version.getSubminor().hasValue())
|
||||
if (Version.getMinor()) {
|
||||
if (Version.getSubminor())
|
||||
return VersionTuple(NewMajor, Version.getMinor().getValue(),
|
||||
Version.getSubminor().getValue());
|
||||
else
|
||||
|
||||
@ -2274,10 +2274,10 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
|
||||
|
||||
// How many bytes do we want to allocate here?
|
||||
llvm::Optional<llvm::APInt> AllocationSize;
|
||||
if (!ArraySize.hasValue() && !AllocType->isDependentType()) {
|
||||
if (!ArraySize && !AllocType->isDependentType()) {
|
||||
// For non-array operator new, we only want to allocate one element.
|
||||
AllocationSize = SingleEltSize;
|
||||
} else if (KnownArraySize.hasValue() && !AllocType->isDependentType()) {
|
||||
} else if (KnownArraySize && !AllocType->isDependentType()) {
|
||||
// For array operator new, only deal with static array size case.
|
||||
bool Overflow;
|
||||
AllocationSize = llvm::APInt(SizeTyWidth, *KnownArraySize)
|
||||
|
||||
@ -828,7 +828,7 @@ public:
|
||||
/// Returns optional parameter for the ordered region.
|
||||
std::pair<const Expr *, OMPOrderedClause *> getOrderedRegionParam() const {
|
||||
if (const SharingMapTy *Top = getTopOfStackOrNull())
|
||||
if (Top->OrderedRegion.hasValue())
|
||||
if (Top->OrderedRegion)
|
||||
return Top->OrderedRegion.getValue();
|
||||
return std::make_pair(nullptr, nullptr);
|
||||
}
|
||||
@ -843,7 +843,7 @@ public:
|
||||
std::pair<const Expr *, OMPOrderedClause *>
|
||||
getParentOrderedRegionParam() const {
|
||||
if (const SharingMapTy *Parent = getSecondOnStackOrNull())
|
||||
if (Parent->OrderedRegion.hasValue())
|
||||
if (Parent->OrderedRegion)
|
||||
return Parent->OrderedRegion.getValue();
|
||||
return std::make_pair(nullptr, nullptr);
|
||||
}
|
||||
@ -7761,7 +7761,7 @@ bool OpenMPIterationSpaceChecker::setStep(Expr *NewStep, bool Subtract) {
|
||||
bool IsConstZero = Result && !Result->getBoolValue();
|
||||
|
||||
// != with increment is treated as <; != with decrement is treated as >
|
||||
if (!TestIsLessOp.hasValue())
|
||||
if (!TestIsLessOp)
|
||||
TestIsLessOp = IsConstPos || (IsUnsigned && !Subtract);
|
||||
if (UB &&
|
||||
(IsConstZero || (TestIsLessOp.getValue()
|
||||
@ -22180,7 +22180,7 @@ void Sema::ActOnOpenMPDeclareTargetName(NamedDecl *ND, SourceLocation Loc,
|
||||
auto *VD = cast<ValueDecl>(ND);
|
||||
llvm::Optional<OMPDeclareTargetDeclAttr *> ActiveAttr =
|
||||
OMPDeclareTargetDeclAttr::getActiveAttr(VD);
|
||||
if (ActiveAttr.hasValue() && ActiveAttr.getValue()->getDevType() != DTCI.DT &&
|
||||
if (ActiveAttr && ActiveAttr.getValue()->getDevType() != DTCI.DT &&
|
||||
ActiveAttr.getValue()->getLevel() == Level) {
|
||||
Diag(Loc, diag::err_omp_device_type_mismatch)
|
||||
<< OMPDeclareTargetDeclAttr::ConvertDevTypeTyToStr(DTCI.DT)
|
||||
@ -22188,18 +22188,18 @@ void Sema::ActOnOpenMPDeclareTargetName(NamedDecl *ND, SourceLocation Loc,
|
||||
ActiveAttr.getValue()->getDevType());
|
||||
return;
|
||||
}
|
||||
if (ActiveAttr.hasValue() && ActiveAttr.getValue()->getMapType() != MT &&
|
||||
if (ActiveAttr && ActiveAttr.getValue()->getMapType() != MT &&
|
||||
ActiveAttr.getValue()->getLevel() == Level) {
|
||||
Diag(Loc, diag::err_omp_declare_target_to_and_link) << ND;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ActiveAttr.hasValue() && ActiveAttr.getValue()->getLevel() == Level)
|
||||
if (ActiveAttr && ActiveAttr.getValue()->getLevel() == Level)
|
||||
return;
|
||||
|
||||
Expr *IndirectE = nullptr;
|
||||
bool IsIndirect = false;
|
||||
if (DTCI.Indirect.hasValue()) {
|
||||
if (DTCI.Indirect) {
|
||||
IndirectE = DTCI.Indirect.getValue();
|
||||
if (!IndirectE)
|
||||
IsIndirect = true;
|
||||
@ -22294,12 +22294,12 @@ void Sema::checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D,
|
||||
llvm::Optional<OMPDeclareTargetDeclAttr *> ActiveAttr =
|
||||
OMPDeclareTargetDeclAttr::getActiveAttr(VD);
|
||||
unsigned Level = DeclareTargetNesting.size();
|
||||
if (ActiveAttr.hasValue() && ActiveAttr.getValue()->getLevel() >= Level)
|
||||
if (ActiveAttr && ActiveAttr.getValue()->getLevel() >= Level)
|
||||
return;
|
||||
DeclareTargetContextInfo &DTCI = DeclareTargetNesting.back();
|
||||
Expr *IndirectE = nullptr;
|
||||
bool IsIndirect = false;
|
||||
if (DTCI.Indirect.hasValue()) {
|
||||
if (DTCI.Indirect) {
|
||||
IndirectE = DTCI.Indirect.getValue();
|
||||
if (!IndirectE)
|
||||
IsIndirect = true;
|
||||
|
||||
@ -766,7 +766,7 @@ void VariadicMethodTypeChecker::checkPreObjCMessage(const ObjCMethodCall &msg,
|
||||
continue;
|
||||
|
||||
// Generate only one error node to use for all bug reports.
|
||||
if (!errorNode.hasValue())
|
||||
if (!errorNode)
|
||||
errorNode = C.generateNonFatalErrorNode();
|
||||
|
||||
if (!errorNode.getValue())
|
||||
|
||||
@ -272,12 +272,12 @@ ProgramStateRef GTestChecker::assumeValuesEqual(SVal Val1, SVal Val2,
|
||||
CheckerContext &C) {
|
||||
auto DVal1 = Val1.getAs<DefinedOrUnknownSVal>();
|
||||
auto DVal2 = Val2.getAs<DefinedOrUnknownSVal>();
|
||||
if (!DVal1.hasValue() || !DVal2.hasValue())
|
||||
if (!DVal1 || !DVal2)
|
||||
return State;
|
||||
|
||||
auto ValuesEqual =
|
||||
C.getSValBuilder().evalEQ(State, *DVal1, *DVal2).getAs<DefinedSVal>();
|
||||
if (!ValuesEqual.hasValue())
|
||||
if (!ValuesEqual)
|
||||
return State;
|
||||
|
||||
State = C.getConstraintManager().assume(State, *ValuesEqual, true);
|
||||
|
||||
@ -1238,7 +1238,7 @@ void MallocChecker::checkKernelMalloc(const CallEvent &Call,
|
||||
ProgramStateRef State = C.getState();
|
||||
llvm::Optional<ProgramStateRef> MaybeState =
|
||||
performKernelMalloc(Call, C, State);
|
||||
if (MaybeState.hasValue())
|
||||
if (MaybeState)
|
||||
State = MaybeState.getValue();
|
||||
else
|
||||
State = MallocMemAux(C, Call, Call.getArgExpr(0), UndefinedVal(), State,
|
||||
@ -3571,13 +3571,13 @@ void MallocChecker::printState(raw_ostream &Out, ProgramStateRef State,
|
||||
const RefState *RefS = State->get<RegionState>(I.getKey());
|
||||
AllocationFamily Family = RefS->getAllocationFamily();
|
||||
Optional<MallocChecker::CheckKind> CheckKind = getCheckIfTracked(Family);
|
||||
if (!CheckKind.hasValue())
|
||||
CheckKind = getCheckIfTracked(Family, true);
|
||||
if (!CheckKind)
|
||||
CheckKind = getCheckIfTracked(Family, true);
|
||||
|
||||
I.getKey()->dumpToStream(Out);
|
||||
Out << " : ";
|
||||
I.getData().dump(Out);
|
||||
if (CheckKind.hasValue())
|
||||
if (CheckKind)
|
||||
Out << " (" << CheckNames[*CheckKind].getName() << ")";
|
||||
Out << NL;
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ AnalyzerOptions::getExplorationStrategy() const {
|
||||
.Case("bfs_block_dfs_contents",
|
||||
ExplorationStrategyKind::BFSBlockDFSContents)
|
||||
.Default(None);
|
||||
assert(K.hasValue() && "User mode is invalid.");
|
||||
assert(K && "User mode is invalid.");
|
||||
return K.getValue();
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ CTUPhase1InliningKind AnalyzerOptions::getCTUPhase1Inlining() const {
|
||||
.Case("small", CTUPhase1InliningKind::Small)
|
||||
.Case("all", CTUPhase1InliningKind::All)
|
||||
.Default(None);
|
||||
assert(K.hasValue() && "CTU inlining mode is invalid.");
|
||||
assert(K && "CTU inlining mode is invalid.");
|
||||
return K.getValue();
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ IPAKind AnalyzerOptions::getIPAMode() const {
|
||||
.Case("dynamic", IPAK_DynamicDispatch)
|
||||
.Case("dynamic-bifurcate", IPAK_DynamicDispatchBifurcate)
|
||||
.Default(None);
|
||||
assert(K.hasValue() && "IPA Mode is invalid.");
|
||||
assert(K && "IPA Mode is invalid.");
|
||||
|
||||
return K.getValue();
|
||||
}
|
||||
|
||||
@ -2949,7 +2949,7 @@ PathDiagnosticPieceRef ConditionBRVisitor::VisitTrueTest(
|
||||
|
||||
PathDiagnosticLocation Loc(Cond, SM, LCtx);
|
||||
auto event = std::make_shared<PathDiagnosticEventPiece>(Loc, Message);
|
||||
if (shouldPrune.hasValue())
|
||||
if (shouldPrune)
|
||||
event->setPrunable(shouldPrune.getValue());
|
||||
return event;
|
||||
}
|
||||
@ -3279,7 +3279,7 @@ void FalsePositiveRefutationBRVisitor::finalizeVisitor(
|
||||
|
||||
// And check for satisfiability
|
||||
Optional<bool> IsSAT = RefutationSolver->check();
|
||||
if (!IsSAT.hasValue())
|
||||
if (!IsSAT)
|
||||
return;
|
||||
|
||||
if (!IsSAT.getValue())
|
||||
|
||||
@ -1015,7 +1015,7 @@ bool ExprEngine::shouldInlineCall(const CallEvent &Call, const Decl *D,
|
||||
|
||||
// Check if this function has been marked as non-inlinable.
|
||||
Optional<bool> MayInline = Engine.FunctionSummaries->mayInline(D);
|
||||
if (MayInline.hasValue()) {
|
||||
if (MayInline) {
|
||||
if (!MayInline.getValue())
|
||||
return false;
|
||||
|
||||
|
||||
@ -114,7 +114,7 @@ bool RVVType::verifyType() const {
|
||||
return false;
|
||||
if (isScalar())
|
||||
return true;
|
||||
if (!Scale.hasValue())
|
||||
if (!Scale)
|
||||
return false;
|
||||
if (isFloat() && ElementBitwidth == 8)
|
||||
return false;
|
||||
@ -799,7 +799,7 @@ RVVType::computeTypes(BasicType BT, int Log2LMUL, unsigned NF,
|
||||
RVVTypes Types;
|
||||
for (const PrototypeDescriptor &Proto : Prototype) {
|
||||
auto T = computeType(BT, Log2LMUL, Proto);
|
||||
if (!T.hasValue())
|
||||
if (!T)
|
||||
return llvm::None;
|
||||
// Record legal type index
|
||||
Types.push_back(T.getValue());
|
||||
|
||||
@ -179,9 +179,9 @@ static std::string getReplacementErrString(replacement_error Err) {
|
||||
|
||||
std::string ReplacementError::message() const {
|
||||
std::string Message = getReplacementErrString(Err);
|
||||
if (NewReplacement.hasValue())
|
||||
if (NewReplacement)
|
||||
Message += "\nNew replacement: " + NewReplacement->toString();
|
||||
if (ExistingReplacement.hasValue())
|
||||
if (ExistingReplacement)
|
||||
Message += "\nExisting replacement: " + ExistingReplacement->toString();
|
||||
return Message;
|
||||
}
|
||||
|
||||
@ -406,7 +406,7 @@ int clang_main(int Argc, char **Argv) {
|
||||
if (ClangCLMode) {
|
||||
// Arguments in "CL" are prepended.
|
||||
llvm::Optional<std::string> OptCL = llvm::sys::Process::GetEnv("CL");
|
||||
if (OptCL.hasValue()) {
|
||||
if (OptCL) {
|
||||
SmallVector<const char *, 8> PrependedOpts;
|
||||
getCLEnvVarOptions(OptCL.getValue(), Saver, PrependedOpts);
|
||||
|
||||
@ -415,7 +415,7 @@ int clang_main(int Argc, char **Argv) {
|
||||
}
|
||||
// Arguments in "_CL_" are appended.
|
||||
llvm::Optional<std::string> Opt_CL_ = llvm::sys::Process::GetEnv("_CL_");
|
||||
if (Opt_CL_.hasValue()) {
|
||||
if (Opt_CL_) {
|
||||
SmallVector<const char *, 8> AppendedOpts;
|
||||
getCLEnvVarOptions(Opt_CL_.getValue(), Saver, AppendedOpts);
|
||||
|
||||
|
||||
@ -536,7 +536,7 @@ bool CursorVisitor::VisitChildren(CXCursor Cursor) {
|
||||
TLEnd = CXXUnit->top_level_end();
|
||||
TL != TLEnd; ++TL) {
|
||||
const Optional<bool> V = handleDeclForVisitation(*TL);
|
||||
if (!V.hasValue())
|
||||
if (!V)
|
||||
continue;
|
||||
return V.getValue();
|
||||
}
|
||||
@ -641,7 +641,7 @@ bool CursorVisitor::VisitDeclContext(DeclContext *DC) {
|
||||
if (OMD->isSynthesizedAccessorStub())
|
||||
continue;
|
||||
const Optional<bool> V = handleDeclForVisitation(D);
|
||||
if (!V.hasValue())
|
||||
if (!V)
|
||||
continue;
|
||||
return V.getValue();
|
||||
}
|
||||
@ -675,7 +675,7 @@ Optional<bool> CursorVisitor::handleDeclForVisitation(const Decl *D) {
|
||||
}
|
||||
|
||||
const Optional<bool> V = shouldVisitCursor(Cursor);
|
||||
if (!V.hasValue())
|
||||
if (!V)
|
||||
return None;
|
||||
if (!V.getValue())
|
||||
return false;
|
||||
@ -1074,7 +1074,7 @@ bool CursorVisitor::VisitObjCContainerDecl(ObjCContainerDecl *D) {
|
||||
I != E; ++I) {
|
||||
CXCursor Cursor = MakeCXCursor(*I, TU, RegionOfInterest);
|
||||
const Optional<bool> &V = shouldVisitCursor(Cursor);
|
||||
if (!V.hasValue())
|
||||
if (!V)
|
||||
continue;
|
||||
if (!V.getValue())
|
||||
return false;
|
||||
@ -8178,13 +8178,13 @@ static CXVersion convertVersion(VersionTuple In) {
|
||||
Out.Major = In.getMajor();
|
||||
|
||||
Optional<unsigned> Minor = In.getMinor();
|
||||
if (Minor.hasValue())
|
||||
if (Minor)
|
||||
Out.Minor = *Minor;
|
||||
else
|
||||
return Out;
|
||||
|
||||
Optional<unsigned> Subminor = In.getSubminor();
|
||||
if (Subminor.hasValue())
|
||||
if (Subminor)
|
||||
Out.Subminor = *Subminor;
|
||||
|
||||
return Out;
|
||||
|
||||
@ -259,11 +259,11 @@ void checkEventualResultWithTimeout(VerifyingConsumer &TestConsumer) {
|
||||
<< "The expected result state wasn't reached before the time-out.";
|
||||
std::unique_lock<std::mutex> L(TestConsumer.Mtx);
|
||||
EXPECT_TRUE(TestConsumer.result().hasValue());
|
||||
if (TestConsumer.result().hasValue()) {
|
||||
if (TestConsumer.result()) {
|
||||
EXPECT_TRUE(*TestConsumer.result());
|
||||
}
|
||||
if ((TestConsumer.result().hasValue() && !TestConsumer.result().getValue()) ||
|
||||
!TestConsumer.result().hasValue())
|
||||
if ((TestConsumer.result() && !TestConsumer.result().getValue()) ||
|
||||
!TestConsumer.result())
|
||||
TestConsumer.printUnmetExpectations(llvm::outs());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@ -118,18 +118,18 @@ static bool checkReplacementError(llvm::Error &&Error,
|
||||
OS << "Unexpected error code: " << int(RE.get()) << "\n";
|
||||
if (ExpectedExisting != RE.getExistingReplacement()) {
|
||||
OS << "Expected Existing != Actual Existing.\n";
|
||||
if (ExpectedExisting.hasValue())
|
||||
if (ExpectedExisting)
|
||||
OS << "Expected existing replacement: " << ExpectedExisting->toString()
|
||||
<< "\n";
|
||||
if (RE.getExistingReplacement().hasValue())
|
||||
if (RE.getExistingReplacement())
|
||||
OS << "Actual existing replacement: "
|
||||
<< RE.getExistingReplacement()->toString() << "\n";
|
||||
}
|
||||
if (ExpectedNew != RE.getNewReplacement()) {
|
||||
OS << "Expected New != Actual New.\n";
|
||||
if (ExpectedNew.hasValue())
|
||||
if (ExpectedNew)
|
||||
OS << "Expected new replacement: " << ExpectedNew->toString() << "\n";
|
||||
if (RE.getNewReplacement().hasValue())
|
||||
if (RE.getNewReplacement())
|
||||
OS << "Actual new replacement: " << RE.getNewReplacement()->toString()
|
||||
<< "\n";
|
||||
}
|
||||
|
||||
@ -217,7 +217,7 @@ void RVVEmitter::createHeader(raw_ostream &OS) {
|
||||
for (int Log2LMUL : Log2LMULs) {
|
||||
auto T = RVVType::computeType(BasicType::Int8, Log2LMUL,
|
||||
PrototypeDescriptor::Mask);
|
||||
if (T.hasValue())
|
||||
if (T)
|
||||
printType(T.getValue());
|
||||
}
|
||||
// Print RVV int/float types.
|
||||
@ -225,7 +225,7 @@ void RVVEmitter::createHeader(raw_ostream &OS) {
|
||||
BasicType BT = ParseBasicType(I);
|
||||
for (int Log2LMUL : Log2LMULs) {
|
||||
auto T = RVVType::computeType(BT, Log2LMUL, PrototypeDescriptor::Vector);
|
||||
if (T.hasValue()) {
|
||||
if (T) {
|
||||
printType(T.getValue());
|
||||
auto UT = RVVType::computeType(
|
||||
BT, Log2LMUL,
|
||||
@ -240,7 +240,7 @@ void RVVEmitter::createHeader(raw_ostream &OS) {
|
||||
for (int Log2LMUL : Log2LMULs) {
|
||||
auto T = RVVType::computeType(BasicType::Float16, Log2LMUL,
|
||||
PrototypeDescriptor::Vector);
|
||||
if (T.hasValue())
|
||||
if (T)
|
||||
printType(T.getValue());
|
||||
}
|
||||
OS << "#endif\n";
|
||||
@ -249,7 +249,7 @@ void RVVEmitter::createHeader(raw_ostream &OS) {
|
||||
for (int Log2LMUL : Log2LMULs) {
|
||||
auto T = RVVType::computeType(BasicType::Float32, Log2LMUL,
|
||||
PrototypeDescriptor::Vector);
|
||||
if (T.hasValue())
|
||||
if (T)
|
||||
printType(T.getValue());
|
||||
}
|
||||
OS << "#endif\n";
|
||||
@ -258,7 +258,7 @@ void RVVEmitter::createHeader(raw_ostream &OS) {
|
||||
for (int Log2LMUL : Log2LMULs) {
|
||||
auto T = RVVType::computeType(BasicType::Float64, Log2LMUL,
|
||||
PrototypeDescriptor::Vector);
|
||||
if (T.hasValue())
|
||||
if (T)
|
||||
printType(T.getValue());
|
||||
}
|
||||
OS << "#endif\n\n";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user