[clang] 06decd0 - [clang] Use value_or instead of getValueOr (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 18 23:21:43 PDT 2022
Author: Kazu Hirata
Date: 2022-06-18T23:21:34-07:00
New Revision: 06decd0b41158cf9571388ee4cf0b5ad9faaa056
URL: https://github.com/llvm/llvm-project/commit/06decd0b41158cf9571388ee4cf0b5ad9faaa056
DIFF: https://github.com/llvm/llvm-project/commit/06decd0b41158cf9571388ee4cf0b5ad9faaa056.diff
LOG: [clang] Use value_or instead of getValueOr (NFC)
Added:
Modified:
clang/include/clang/APINotes/Types.h
clang/include/clang/AST/AbstractBasicReader.h
clang/include/clang/AST/DeclTemplate.h
clang/include/clang/Analysis/PathDiagnostic.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/APValue.cpp
clang/lib/AST/ASTContext.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
clang/lib/ASTMatchers/Dynamic/Parser.cpp
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
clang/lib/Basic/Cuda.cpp
clang/lib/Basic/Targets/OSTargets.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/CodeGen/CGObjC.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/MSVC.cpp
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CXType.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/APINotes/Types.h b/clang/include/clang/APINotes/Types.h
index f741d9b91d76..0df710152e7a 100644
--- a/clang/include/clang/APINotes/Types.h
+++ b/clang/include/clang/APINotes/Types.h
@@ -239,7 +239,7 @@ class ObjCContextInfo : public CommonTypeInfo {
}
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 @@ class ObjCContextInfo : public CommonTypeInfo {
}
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 @@ class ObjCPropertyInfo : public VariableInfo {
}
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 @@ class ParamInfo : public VariableInfo {
}
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 @@ class TagInfo : public CommonTypeInfo {
}
void setFlagEnum(llvm::Optional<bool> Value) {
HasFlagEnum = Value.hasValue();
- IsFlagEnum = Value.getValueOr(false);
+ IsFlagEnum = Value.value_or(false);
}
TagInfo &operator|=(const TagInfo &RHS) {
diff --git a/clang/include/clang/AST/AbstractBasicReader.h b/clang/include/clang/AST/AbstractBasicReader.h
index b2fc2d2c7e4b..3394c68f54eb 100644
--- a/clang/include/clang/AST/AbstractBasicReader.h
+++ b/clang/include/clang/AST/AbstractBasicReader.h
@@ -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:
diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h
index a00917913e41..3e4ccda73111 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -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,
diff --git a/clang/include/clang/Analysis/PathDiagnostic.h b/clang/include/clang/Analysis/PathDiagnostic.h
index 446f67b23e75..47cb549c8e66 100644
--- a/clang/include/clang/Analysis/PathDiagnostic.h
+++ b/clang/include/clang/Analysis/PathDiagnostic.h
@@ -550,9 +550,7 @@ class PathDiagnosticEventPiece : public PathDiagnosticSpotPiece {
}
/// 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;
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 8d9af0ff12c8..90af1005fa5a 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -7655,7 +7655,7 @@ class Sema final {
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(); }
diff --git a/clang/lib/AST/APValue.cpp b/clang/lib/AST/APValue.cpp
index 9a09da774a46..a22031142c7c 100644
--- a/clang/lib/AST/APValue.cpp
+++ b/clang/lib/AST/APValue.cpp
@@ -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()) {
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 2b951c55f44a..4cafa7a0df96 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -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) {
diff --git a/clang/lib/ASTMatchers/Dynamic/Marshallers.cpp b/clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
index 40db70e6f4a5..70b5953fe969 100644
--- a/clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
@@ -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;
}
diff --git a/clang/lib/ASTMatchers/Dynamic/Parser.cpp b/clang/lib/ASTMatchers/Dynamic/Parser.cpp
index cab1476acf94..732c783acaf6 100644
--- a/clang/lib/ASTMatchers/Dynamic/Parser.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Parser.cpp
@@ -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) {
diff --git a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
index 502974186621..f424dba02125 100644
--- a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
@@ -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);
}
diff --git a/clang/lib/Basic/Cuda.cpp b/clang/lib/Basic/Cuda.cpp
index 412f5c3f45e3..d75cc410f2d9 100644
--- a/clang/lib/Basic/Cuda.cpp
+++ b/clang/lib/Basic/Cuda.cpp
@@ -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;
diff --git a/clang/lib/Basic/Targets/OSTargets.cpp b/clang/lib/Basic/Targets/OSTargets.cpp
index f79e20779a3d..f2ed076039a0 100644
--- a/clang/lib/Basic/Targets/OSTargets.cpp
+++ b/clang/lib/Basic/Targets/OSTargets.cpp
@@ -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);
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index 2343c7e4afbb..6b5b715fd8f9 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -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());
diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index 0c538860a10c..213fdff02d9a 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -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);
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 8d3584ff0ba1..46708a6e782f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -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();
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index 665a3894302a..5d98a6497827 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -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;
}
diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp
index c6e8bd04455e..eea4b74ccb57 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -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.
diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index 39d885c7c90a..c4797cea333f 100644
--- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -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;
}
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 5d7916ace87e..d0d17092f5f2 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -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
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index 834946411b84..1032cb2e8e0e 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -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) {
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index fe84e3047a59..572cc6605551 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -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.
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 4c61782e065b..429d5c5910f7 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -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 @@ class OpenMPIterationSpaceChecker {
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:
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 0662dd760223..3087cd1cec63 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -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
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index a6539712fd5a..d7558017948a 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -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);
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 3d20c5914c76..36d7f4186af6 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -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) {
diff --git a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
index 2c02ffe33dea..50eec38404bd 100644
--- a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -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.
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
index 5a9e7169155b..558bc3b5ecfe 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -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);
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index d2a267bc8642..8e0ce6fa8449 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -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.
diff --git a/clang/tools/libclang/CXType.cpp b/clang/tools/libclang/CXType.cpp
index cac5d3d4fa90..10fcb07e0f28 100644
--- a/clang/tools/libclang/CXType.cpp
+++ b/clang/tools/libclang/CXType.cpp
@@ -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) {
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index b6bcd851c6c1..641dd34c7421 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -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";
}
More information about the cfe-commits
mailing list