[clang] Use value_or instead of getValueOr (NFC)

This commit is contained in:
Kazu Hirata 2022-06-18 23:21:34 -07:00
parent 57e43ebc42
commit 06decd0b41
30 changed files with 84 additions and 89 deletions

View File

@ -239,7 +239,7 @@ public:
}
void setSwiftImportAsNonGeneric(llvm::Optional<bool> Value) {
SwiftImportAsNonGenericSpecified = Value.hasValue();
SwiftImportAsNonGeneric = Value.getValueOr(false);
SwiftImportAsNonGeneric = Value.value_or(false);
}
llvm::Optional<bool> getSwiftObjCMembers() const {
@ -248,7 +248,7 @@ public:
}
void setSwiftObjCMembers(llvm::Optional<bool> Value) {
SwiftObjCMembersSpecified = Value.hasValue();
SwiftObjCMembers = Value.getValueOr(false);
SwiftObjCMembers = Value.value_or(false);
}
/// Strip off any information within the class information structure that is
@ -366,7 +366,7 @@ public:
}
void setSwiftImportAsAccessors(llvm::Optional<bool> Value) {
SwiftImportAsAccessorsSpecified = Value.hasValue();
SwiftImportAsAccessors = Value.getValueOr(false);
SwiftImportAsAccessors = Value.value_or(false);
}
friend bool operator==(const ObjCPropertyInfo &, const ObjCPropertyInfo &);
@ -430,7 +430,7 @@ public:
}
void setNoEscape(llvm::Optional<bool> Value) {
NoEscapeSpecified = Value.hasValue();
NoEscape = Value.getValueOr(false);
NoEscape = Value.value_or(false);
}
llvm::Optional<RetainCountConventionKind> getRetainCountConvention() const {
@ -667,7 +667,7 @@ public:
}
void setFlagEnum(llvm::Optional<bool> Value) {
HasFlagEnum = Value.hasValue();
IsFlagEnum = Value.getValueOr(false);
IsFlagEnum = Value.value_or(false);
}
TagInfo &operator|=(const TagInfo &RHS) {

View File

@ -21,7 +21,7 @@ inline T makeNullableFromOptional(const Optional<T> &value) {
template <class T>
inline T *makePointerFromOptional(Optional<T *> value) {
return value.getValueOr(nullptr);
return value.value_or(nullptr);
}
// PropertyReader is a class concept that requires the following method:

View File

@ -1233,7 +1233,7 @@ class TemplateTypeParmDecl final : public TypeDecl,
: TypeDecl(TemplateTypeParm, DC, IdLoc, Id, KeyLoc), Typename(Typename),
HasTypeConstraint(HasTypeConstraint), TypeConstraintInitialized(false),
ExpandedParameterPack(NumExpanded),
NumExpanded(NumExpanded.getValueOr(0)) {}
NumExpanded(NumExpanded.value_or(0)) {}
public:
static TemplateTypeParmDecl *Create(const ASTContext &C, DeclContext *DC,

View File

@ -550,9 +550,7 @@ public:
}
/// Return true if the diagnostic piece is prunable.
bool isPrunable() const {
return IsPrunable.getValueOr(false);
}
bool isPrunable() const { return IsPrunable.value_or(false); }
void dump() const override;

View File

@ -7655,7 +7655,7 @@ public:
RequiredTemplateKind(TemplateNameIsRequiredTag) {}
SourceLocation getTemplateKeywordLoc() const {
return TemplateKW.getValueOr(SourceLocation());
return TemplateKW.value_or(SourceLocation());
}
bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); }
bool isRequired() const { return TemplateKW != SourceLocation(); }

View File

@ -761,7 +761,7 @@ void APValue::printPretty(raw_ostream &Out, const PrintingPolicy &Policy,
if (!hasLValuePath()) {
// No lvalue path: just print the offset.
CharUnits O = getLValueOffset();
CharUnits S = Ctx ? Ctx->getTypeSizeInCharsIfKnown(InnerTy).getValueOr(
CharUnits S = Ctx ? Ctx->getTypeSizeInCharsIfKnown(InnerTy).value_or(
CharUnits::Zero())
: CharUnits::Zero();
if (!O.isZero()) {

View File

@ -887,7 +887,7 @@ ASTContext::getCanonicalTemplateTemplateParmDecl(
TargetCXXABI::Kind ASTContext::getCXXABIKind() const {
auto Kind = getTargetInfo().getCXXABI().getKind();
return getLangOpts().CXXABI.getValueOr(Kind);
return getLangOpts().CXXABI.value_or(Kind);
}
CXXABI *ASTContext::createCXXABI(const TargetInfo &T) {

View File

@ -148,7 +148,7 @@ clang::ast_matchers::dynamic::internal::ArgTypeTraits<
for (StringRef OrFlag : Split) {
if (llvm::Optional<llvm::Regex::RegexFlags> NextFlag =
getRegexFlag(OrFlag.trim()))
Flag = Flag.getValueOr(llvm::Regex::NoFlags) | *NextFlag;
Flag = Flag.value_or(llvm::Regex::NoFlags) | *NextFlag;
else
return None;
}

View File

@ -645,7 +645,7 @@ bool Parser::parseMatcherExpressionImpl(const TokenInfo &NameToken,
Tokenizer->SkipNewlines();
{
ScopedContextEntry SCE(this, Ctor.getValueOr(nullptr));
ScopedContextEntry SCE(this, Ctor.value_or(nullptr));
while (Tokenizer->nextTokenKind() != TokenInfo::TK_Eof) {
if (Tokenizer->nextTokenKind() == TokenInfo::TK_CloseParen) {

View File

@ -431,10 +431,9 @@ void assignOptionalValue(const Expr &E, LatticeTransferState &State,
/// Returns a symbolic value for the "has_value" property of an `optional<T>`
/// value that is constructed/assigned from a value of type `U` or `optional<U>`
/// where `T` is constructible from `U`.
BoolValue &
getValueOrConversionHasValue(const FunctionDecl &F, const Expr &E,
const MatchFinder::MatchResult &MatchRes,
LatticeTransferState &State) {
BoolValue &value_orConversionHasValue(const FunctionDecl &F, const Expr &E,
const MatchFinder::MatchResult &MatchRes,
LatticeTransferState &State) {
assert(F.getTemplateSpecializationArgs()->size() > 0);
const int TemplateParamOptionalWrappersCount = countOptionalWrappers(
@ -462,9 +461,9 @@ void transferValueOrConversionConstructor(
assert(E->getNumArgs() > 0);
assignOptionalValue(*E, State,
getValueOrConversionHasValue(*E->getConstructor(),
*E->getArg(0), MatchRes,
State));
value_orConversionHasValue(*E->getConstructor(),
*E->getArg(0), MatchRes,
State));
}
void transferAssignment(const CXXOperatorCallExpr *E, BoolValue &HasValueVal,
@ -487,8 +486,8 @@ void transferValueOrConversionAssignment(
LatticeTransferState &State) {
assert(E->getNumArgs() > 1);
transferAssignment(E,
getValueOrConversionHasValue(
*E->getDirectCallee(), *E->getArg(1), MatchRes, State),
value_orConversionHasValue(*E->getDirectCallee(),
*E->getArg(1), MatchRes, State),
State);
}

View File

@ -220,8 +220,7 @@ CudaVersion MaxVersionForCudaArch(CudaArch A) {
}
CudaVersion ToCudaVersion(llvm::VersionTuple Version) {
int IVer =
Version.getMajor() * 10 + Version.getMinor().getValueOr(0);
int IVer = Version.getMajor() * 10 + Version.getMinor().value_or(0);
switch(IVer) {
case 70:
return CudaVersion::CUDA_70;

View File

@ -73,19 +73,19 @@ void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
char Str[7];
if (OsVersion.getMajor() < 10) {
Str[0] = '0' + OsVersion.getMajor();
Str[1] = '0' + (OsVersion.getMinor().getValueOr(0) / 10);
Str[2] = '0' + (OsVersion.getMinor().getValueOr(0) % 10);
Str[3] = '0' + (OsVersion.getSubminor().getValueOr(0) / 10);
Str[4] = '0' + (OsVersion.getSubminor().getValueOr(0) % 10);
Str[1] = '0' + (OsVersion.getMinor().value_or(0) / 10);
Str[2] = '0' + (OsVersion.getMinor().value_or(0) % 10);
Str[3] = '0' + (OsVersion.getSubminor().value_or(0) / 10);
Str[4] = '0' + (OsVersion.getSubminor().value_or(0) % 10);
Str[5] = '\0';
} else {
// Handle versions >= 10.
Str[0] = '0' + (OsVersion.getMajor() / 10);
Str[1] = '0' + (OsVersion.getMajor() % 10);
Str[2] = '0' + (OsVersion.getMinor().getValueOr(0) / 10);
Str[3] = '0' + (OsVersion.getMinor().getValueOr(0) % 10);
Str[4] = '0' + (OsVersion.getSubminor().getValueOr(0) / 10);
Str[5] = '0' + (OsVersion.getSubminor().getValueOr(0) % 10);
Str[2] = '0' + (OsVersion.getMinor().value_or(0) / 10);
Str[3] = '0' + (OsVersion.getMinor().value_or(0) % 10);
Str[4] = '0' + (OsVersion.getSubminor().value_or(0) / 10);
Str[5] = '0' + (OsVersion.getSubminor().value_or(0) % 10);
Str[6] = '\0';
}
if (Triple.isTvOS())
@ -98,23 +98,23 @@ void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
assert(OsVersion < VersionTuple(10) && "Invalid version!");
char Str[6];
Str[0] = '0' + OsVersion.getMajor();
Str[1] = '0' + (OsVersion.getMinor().getValueOr(0) / 10);
Str[2] = '0' + (OsVersion.getMinor().getValueOr(0) % 10);
Str[3] = '0' + (OsVersion.getSubminor().getValueOr(0) / 10);
Str[4] = '0' + (OsVersion.getSubminor().getValueOr(0) % 10);
Str[1] = '0' + (OsVersion.getMinor().value_or(0) / 10);
Str[2] = '0' + (OsVersion.getMinor().value_or(0) % 10);
Str[3] = '0' + (OsVersion.getSubminor().value_or(0) / 10);
Str[4] = '0' + (OsVersion.getSubminor().value_or(0) % 10);
Str[5] = '\0';
Builder.defineMacro("__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__", Str);
} else if (Triple.isDriverKit()) {
assert(OsVersion.getMajor() < 100 &&
OsVersion.getMinor().getValueOr(0) < 100 &&
OsVersion.getSubminor().getValueOr(0) < 100 && "Invalid version!");
OsVersion.getMinor().value_or(0) < 100 &&
OsVersion.getSubminor().value_or(0) < 100 && "Invalid version!");
char Str[7];
Str[0] = '0' + (OsVersion.getMajor() / 10);
Str[1] = '0' + (OsVersion.getMajor() % 10);
Str[2] = '0' + (OsVersion.getMinor().getValueOr(0) / 10);
Str[3] = '0' + (OsVersion.getMinor().getValueOr(0) % 10);
Str[4] = '0' + (OsVersion.getSubminor().getValueOr(0) / 10);
Str[5] = '0' + (OsVersion.getSubminor().getValueOr(0) % 10);
Str[2] = '0' + (OsVersion.getMinor().value_or(0) / 10);
Str[3] = '0' + (OsVersion.getMinor().value_or(0) % 10);
Str[4] = '0' + (OsVersion.getSubminor().value_or(0) / 10);
Str[5] = '0' + (OsVersion.getSubminor().value_or(0) % 10);
Str[6] = '\0';
Builder.defineMacro("__ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__", Str);
} else if (Triple.isMacOSX()) {
@ -127,17 +127,17 @@ void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
if (OsVersion < VersionTuple(10, 10)) {
Str[0] = '0' + (OsVersion.getMajor() / 10);
Str[1] = '0' + (OsVersion.getMajor() % 10);
Str[2] = '0' + std::min(OsVersion.getMinor().getValueOr(0), 9U);
Str[3] = '0' + std::min(OsVersion.getSubminor().getValueOr(0), 9U);
Str[2] = '0' + std::min(OsVersion.getMinor().value_or(0), 9U);
Str[3] = '0' + std::min(OsVersion.getSubminor().value_or(0), 9U);
Str[4] = '\0';
} else {
// Handle versions > 10.9.
Str[0] = '0' + (OsVersion.getMajor() / 10);
Str[1] = '0' + (OsVersion.getMajor() % 10);
Str[2] = '0' + (OsVersion.getMinor().getValueOr(0) / 10);
Str[3] = '0' + (OsVersion.getMinor().getValueOr(0) % 10);
Str[4] = '0' + (OsVersion.getSubminor().getValueOr(0) / 10);
Str[5] = '0' + (OsVersion.getSubminor().getValueOr(0) % 10);
Str[2] = '0' + (OsVersion.getMinor().value_or(0) / 10);
Str[3] = '0' + (OsVersion.getMinor().value_or(0) % 10);
Str[4] = '0' + (OsVersion.getSubminor().value_or(0) / 10);
Str[5] = '0' + (OsVersion.getSubminor().value_or(0) % 10);
Str[6] = '\0';
}
Builder.defineMacro("__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__", Str);

View File

@ -1603,7 +1603,7 @@ ScalarExprEmitter::VisitSYCLUniqueStableNameExpr(SYCLUniqueStableNameExpr *E) {
Context.getTargetInfo().getConstantAddressSpace();
llvm::Constant *GlobalConstStr = Builder.CreateGlobalStringPtr(
E->ComputeName(Context), "__usn_str",
static_cast<unsigned>(GlobalAS.getValueOr(LangAS::Default)));
static_cast<unsigned>(GlobalAS.value_or(LangAS::Default)));
unsigned ExprAS = Context.getTargetAddressSpace(E->getType());

View File

@ -3915,8 +3915,8 @@ static llvm::Value *emitIsPlatformVersionAtLeast(CodeGenFunction &CGF,
Args.push_back(
llvm::ConstantInt::get(CGM.Int32Ty, getBaseMachOPlatformID(TT)));
Args.push_back(llvm::ConstantInt::get(CGM.Int32Ty, Version.getMajor()));
Args.push_back(llvm::ConstantInt::get(CGM.Int32Ty, Min.getValueOr(0)));
Args.push_back(llvm::ConstantInt::get(CGM.Int32Ty, SMin.getValueOr(0)));
Args.push_back(llvm::ConstantInt::get(CGM.Int32Ty, Min.value_or(0)));
Args.push_back(llvm::ConstantInt::get(CGM.Int32Ty, SMin.value_or(0)));
};
assert(!Version.empty() && "unexpected empty version");
@ -3952,9 +3952,8 @@ CodeGenFunction::EmitBuiltinAvailable(const VersionTuple &Version) {
Optional<unsigned> Min = Version.getMinor(), SMin = Version.getSubminor();
llvm::Value *Args[] = {
llvm::ConstantInt::get(CGM.Int32Ty, Version.getMajor()),
llvm::ConstantInt::get(CGM.Int32Ty, Min.getValueOr(0)),
llvm::ConstantInt::get(CGM.Int32Ty, SMin.getValueOr(0))
};
llvm::ConstantInt::get(CGM.Int32Ty, Min.value_or(0)),
llvm::ConstantInt::get(CGM.Int32Ty, SMin.value_or(0))};
llvm::Value *CallRes =
EmitNounwindRuntimeCall(CGM.IsOSVersionAtLeastFn, Args);

View File

@ -6435,8 +6435,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
StringRef Val = A->getValue();
Val = Val.empty() ? "0" : Val; // Treat "" as 0 or disable.
bool Invalid = GNUCVer.tryParse(Val);
unsigned Minor = GNUCVer.getMinor().getValueOr(0);
unsigned Patch = GNUCVer.getSubminor().getValueOr(0);
unsigned Minor = GNUCVer.getMinor().value_or(0);
unsigned Patch = GNUCVer.getSubminor().value_or(0);
if (Invalid || GNUCVer.getBuild() || Minor >= 100 || Patch >= 100) {
D.Diag(diag::err_drv_invalid_value)
<< A->getAsString(Args) << A->getValue();

View File

@ -730,7 +730,7 @@ void darwin::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (const Arg *Root = Args.getLastArg(options::OPT_isysroot)) {
// ld64 fixed the implicit -F and -L paths in ld64-605.1+.
if (Version.getMajor() < 605 ||
(Version.getMajor() == 605 && Version.getMinor().getValueOr(0) < 1)) {
(Version.getMajor() == 605 && Version.getMinor().value_or(0) < 1)) {
SmallString<128> L(Root->getValue());
llvm::sys::path::append(L, "System", "DriverKit", "usr", "lib");
@ -1927,8 +1927,8 @@ std::string getOSVersion(llvm::Triple::OSType OS, const llvm::Triple &Triple,
std::string OSVersion;
llvm::raw_string_ostream(OSVersion)
<< OsVersion.getMajor() << '.' << OsVersion.getMinor().getValueOr(0)
<< '.' << OsVersion.getSubminor().getValueOr(0);
<< OsVersion.getMajor() << '.' << OsVersion.getMinor().value_or(0) << '.'
<< OsVersion.getSubminor().value_or(0);
return OSVersion;
}

View File

@ -700,7 +700,7 @@ void MSVCToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
if (major >= 10) {
llvm::VersionTuple Tuple;
if (!Tuple.tryParse(windowsSDKIncludeVersion) &&
Tuple.getSubminor().getValueOr(0) >= 17134) {
Tuple.getSubminor().value_or(0) >= 17134) {
AddSystemIncludeWithSubfolder(DriverArgs, CC1Args, WindowsSDKDir,
"Include", windowsSDKIncludeVersion,
"cppwinrt");
@ -758,8 +758,8 @@ MSVCToolChain::ComputeEffectiveClangTriple(const ArgList &Args,
// The MSVC version doesn't care about the architecture, even though it
// may look at the triple internally.
VersionTuple MSVT = computeMSVCVersion(/*D=*/nullptr, Args);
MSVT = VersionTuple(MSVT.getMajor(), MSVT.getMinor().getValueOr(0),
MSVT.getSubminor().getValueOr(0));
MSVT = VersionTuple(MSVT.getMajor(), MSVT.getMinor().value_or(0),
MSVT.getSubminor().value_or(0));
// For the rest of the triple, however, a computed architecture name may
// be needed.

View File

@ -63,8 +63,8 @@ Optional<Object> serializeSemanticVersion(const VersionTuple &V) {
Object Version;
Version["major"] = V.getMajor();
Version["minor"] = V.getMinor().getValueOr(0);
Version["patch"] = V.getSubminor().getValueOr(0);
Version["minor"] = V.getMinor().value_or(0);
Version["patch"] = V.getSubminor().value_or(0);
return Version;
}

View File

@ -3711,8 +3711,8 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
VersionTuple GNUCVer;
bool Invalid = GNUCVer.tryParse(A->getValue());
unsigned Major = GNUCVer.getMajor();
unsigned Minor = GNUCVer.getMinor().getValueOr(0);
unsigned Patch = GNUCVer.getSubminor().getValueOr(0);
unsigned Minor = GNUCVer.getMinor().value_or(0);
unsigned Patch = GNUCVer.getSubminor().value_or(0);
if (Invalid || GNUCVer.getBuild() || Minor >= 100 || Patch >= 100) {
Diags.Report(diag::err_drv_invalid_value)
<< A->getAsString(Args) << A->getValue();
@ -3739,8 +3739,8 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
<< A->getValue();
Opts.MSCompatibilityVersion = VT.getMajor() * 10000000 +
VT.getMinor().getValueOr(0) * 100000 +
VT.getSubminor().getValueOr(0);
VT.getMinor().value_or(0) * 100000 +
VT.getSubminor().value_or(0);
}
// Mimicking gcc's behavior, trigraphs are only enabled if -trigraphs

View File

@ -410,7 +410,7 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
if (TI.getTriple().getOS() == llvm::Triple::ShaderModel) {
VersionTuple Version = TI.getTriple().getOSVersion();
Builder.defineMacro("__SHADER_TARGET_MAJOR", Twine(Version.getMajor()));
unsigned Minor = Version.getMinor().getValueOr(0);
unsigned Minor = Version.getMinor().value_or(0);
Builder.defineMacro("__SHADER_TARGET_MINOR", Twine(Minor));
}
return;
@ -822,8 +822,9 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
if (version >= VersionTuple(2, 0))
Builder.defineMacro("__OBJC_GNUSTEP_RUNTIME_ABI__", "20");
else
Builder.defineMacro("__OBJC_GNUSTEP_RUNTIME_ABI__",
"1" + Twine(std::min(8U, version.getMinor().getValueOr(0))));
Builder.defineMacro(
"__OBJC_GNUSTEP_RUNTIME_ABI__",
"1" + Twine(std::min(8U, version.getMinor().value_or(0))));
}
if (LangOpts.ObjCRuntime.getKind() == ObjCRuntime::ObjFW) {

View File

@ -2289,7 +2289,7 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
}
IntegerLiteral AllocationSizeLiteral(
Context, AllocationSize.getValueOr(llvm::APInt::getZero(SizeTyWidth)),
Context, AllocationSize.value_or(llvm::APInt::getZero(SizeTyWidth)),
SizeTy, SourceLocation());
// Otherwise, if we failed to constant-fold the allocation size, we'll
// just give up and pass-in something opaque, that isn't a null pointer.

View File

@ -2395,7 +2395,7 @@ OpenMPClauseKind Sema::isOpenMPPrivateDecl(ValueDecl *D, unsigned Level,
// User-defined allocators are private since they must be defined in the
// context of target region.
if (DSAStack->hasExplicitDirective(isOpenMPTargetExecutionDirective, Level) &&
DSAStack->isUsesAllocatorsDecl(Level, D).getValueOr(
DSAStack->isUsesAllocatorsDecl(Level, D).value_or(
DSAStackTy::UsesAllocatorsDeclKind::AllocatorTrait) ==
DSAStackTy::UsesAllocatorsDeclKind::UserDefinedAllocator)
return OMPC_private;
@ -5189,8 +5189,7 @@ class AllocatorChecker final : public ConstStmtVisitor<AllocatorChecker, bool> {
public:
bool VisitDeclRefExpr(const DeclRefExpr *E) {
return S->isUsesAllocatorsDecl(E->getDecl())
.getValueOr(
DSAStackTy::UsesAllocatorsDeclKind::AllocatorTrait) ==
.value_or(DSAStackTy::UsesAllocatorsDeclKind::AllocatorTrait) ==
DSAStackTy::UsesAllocatorsDeclKind::AllocatorTrait;
}
bool VisitStmt(const Stmt *S) {
@ -7651,7 +7650,7 @@ public:
bool doesCondDependOnLC() const { return CondDependOnLC.hasValue(); }
/// Returns index of the loop we depend on (starting from 1), or 0 otherwise.
unsigned getLoopDependentIdx() const {
return InitDependOnLC.getValueOr(CondDependOnLC.getValueOr(0));
return InitDependOnLC.value_or(CondDependOnLC.value_or(0));
}
private:

View File

@ -3406,7 +3406,7 @@ static unsigned getPackIndexForParam(Sema &S,
for (auto *PD : FunctionTemplate->getTemplatedDecl()->parameters()) {
if (PD->isParameterPack()) {
unsigned NumExpansions =
S.getNumArgumentsInExpansion(PD->getType(), Args).getValueOr(1);
S.getNumArgumentsInExpansion(PD->getType(), Args).value_or(1);
if (Idx + NumExpansions > ParamIdx)
return ParamIdx - Idx;
Idx += NumExpansions;
@ -4637,7 +4637,7 @@ Sema::DeduceAutoType(TypeLoc Type, Expr *&Init, QualType &Result,
}
// Find the depth of template parameter to synthesize.
unsigned Depth = DependentDeductionDepth.getValueOr(0);
unsigned Depth = DependentDeductionDepth.value_or(0);
// If this is a 'decltype(auto)' specifier, do the decltype dance.
// Since 'decltype(auto)' can only occur at the top of the type, we

View File

@ -2596,7 +2596,7 @@ Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(
IsExplicitSpecialization = true;
} else if (const ASTTemplateArgumentListInfo *Info =
ClassScopeSpecializationArgs.getValueOr(
ClassScopeSpecializationArgs.value_or(
D->getTemplateSpecializationArgsAsWritten())) {
SemaRef.LookupQualifiedName(Previous, DC);

View File

@ -2226,7 +2226,7 @@ bool ASTReader::shouldDisableValidationForFile(
// If a PCH is loaded and validation is disabled for PCH then disable
// validation for the PCH and the modules it loads.
ModuleKind K = CurrentDeserializingModuleKind.getValueOr(M.Kind);
ModuleKind K = CurrentDeserializingModuleKind.value_or(M.Kind);
switch (K) {
case MK_MainFile:
@ -2440,8 +2440,8 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
<< Filename << moduleKindForDiagnostic(ImportStack.back()->Kind)
<< TopLevelPCHName << FileChange.Kind
<< (FileChange.Old && FileChange.New)
<< llvm::itostr(FileChange.Old.getValueOr(0))
<< llvm::itostr(FileChange.New.getValueOr(0));
<< llvm::itostr(FileChange.Old.value_or(0))
<< llvm::itostr(FileChange.New.value_or(0));
// Print the import stack.
if (ImportStack.size() > 1) {

View File

@ -824,7 +824,7 @@ void GenericTaintRule::process(const GenericTaintChecker &Checker,
/// Check for taint sinks.
ForEachCallArg([this, &Checker, &C, &State](ArgIdxTy I, const Expr *E, SVal) {
if (SinkArgs.contains(I) && isTaintedOrPointsToTainted(E, State, C))
Checker.generateReportIfTainted(E, SinkMsg.getValueOr(MsgCustomSink), C);
Checker.generateReportIfTainted(E, SinkMsg.value_or(MsgCustomSink), C);
});
/// Check for taint filters.

View File

@ -732,7 +732,7 @@ ProgramStateRef ExprEngine::bindReturnValue(const CallEvent &Call,
// Store the extent of the allocated object(s).
SVal ElementCount;
if (const Expr *SizeExpr = CNE->getArraySize().getValueOr(nullptr)) {
if (const Expr *SizeExpr = CNE->getArraySize().value_or(nullptr)) {
ElementCount = State->getSVal(SizeExpr, LCtx);
} else {
ElementCount = svalBuilder.makeIntVal(1, /*IsUnsigned=*/true);

View File

@ -2735,7 +2735,7 @@ void EnqueueVisitor::VisitCXXNewExpr(const CXXNewExpr *E) {
// Enqueue the initializer , if any.
AddStmt(E->getInitializer());
// Enqueue the array size, if any.
AddStmt(E->getArraySize().getValueOr(nullptr));
AddStmt(E->getArraySize().value_or(nullptr));
// Enqueue the allocated type.
AddTypeLoc(E->getAllocatedTypeSourceInfo());
// Enqueue the placement arguments.

View File

@ -1168,7 +1168,7 @@ CXType clang_Type_getTemplateArgumentAsType(CXType CT, unsigned index) {
return MakeCXType(QualType(), GetTU(CT));
Optional<QualType> QT = FindTemplateArgumentTypeAt(TA.getValue(), index);
return MakeCXType(QT.getValueOr(QualType()), GetTU(CT));
return MakeCXType(QT.value_or(QualType()), GetTU(CT));
}
CXType clang_Type_getObjCObjectBaseType(CXType CT) {

View File

@ -4492,7 +4492,7 @@ void EmitClangAttrDocTable(RecordKeeper &Records, raw_ostream &OS) {
// Only look at the first documentation if there are several.
// (Currently there's only one such attr, revisit if this becomes common).
StringRef Text =
Docs.front()->getValueAsOptionalString("Content").getValueOr("");
Docs.front()->getValueAsOptionalString("Content").value_or("");
OS << "\nstatic const char AttrDoc_" << A->getName() << "[] = "
<< "R\"reST(" << Text.trim() << ")reST\";\n";
}