forked from OSchip/llvm-project
Use Optional::getValueOr (NFC)
This commit is contained in:
parent
a8cbddc994
commit
9c0a4227a9
|
@ -240,7 +240,7 @@ public:
|
|||
}
|
||||
void setSwiftImportAsNonGeneric(llvm::Optional<bool> Value) {
|
||||
SwiftImportAsNonGenericSpecified = Value.hasValue();
|
||||
SwiftImportAsNonGeneric = Value.hasValue() ? *Value : false;
|
||||
SwiftImportAsNonGeneric = Value.getValueOr(false);
|
||||
}
|
||||
|
||||
llvm::Optional<bool> getSwiftObjCMembers() const {
|
||||
|
@ -249,7 +249,7 @@ public:
|
|||
}
|
||||
void setSwiftObjCMembers(llvm::Optional<bool> Value) {
|
||||
SwiftObjCMembersSpecified = Value.hasValue();
|
||||
SwiftObjCMembers = Value.hasValue() ? *Value : false;
|
||||
SwiftObjCMembers = Value.getValueOr(false);
|
||||
}
|
||||
|
||||
/// Strip off any information within the class information structure that is
|
||||
|
@ -368,7 +368,7 @@ public:
|
|||
}
|
||||
void setSwiftImportAsAccessors(llvm::Optional<bool> Value) {
|
||||
SwiftImportAsAccessorsSpecified = Value.hasValue();
|
||||
SwiftImportAsAccessors = Value.hasValue() ? *Value : false;
|
||||
SwiftImportAsAccessors = Value.getValueOr(false);
|
||||
}
|
||||
|
||||
friend bool operator==(const ObjCPropertyInfo &, const ObjCPropertyInfo &);
|
||||
|
@ -433,7 +433,7 @@ public:
|
|||
}
|
||||
void setNoEscape(llvm::Optional<bool> Value) {
|
||||
NoEscapeSpecified = Value.hasValue();
|
||||
NoEscape = Value.hasValue() ? *Value : false;
|
||||
NoEscape = Value.getValueOr(false);
|
||||
}
|
||||
|
||||
llvm::Optional<RetainCountConventionKind> getRetainCountConvention() const {
|
||||
|
@ -671,7 +671,7 @@ public:
|
|||
}
|
||||
void setFlagEnum(llvm::Optional<bool> Value) {
|
||||
HasFlagEnum = Value.hasValue();
|
||||
IsFlagEnum = Value.hasValue() ? *Value : false;
|
||||
IsFlagEnum = Value.getValueOr(false);
|
||||
}
|
||||
|
||||
TagInfo &operator|=(const TagInfo &RHS) {
|
||||
|
|
|
@ -21,7 +21,7 @@ inline T makeNullableFromOptional(const Optional<T> &value) {
|
|||
|
||||
template <class T>
|
||||
inline T *makePointerFromOptional(Optional<T *> value) {
|
||||
return (value ? *value : nullptr);
|
||||
return value.getValueOr(nullptr);
|
||||
}
|
||||
|
||||
// PropertyReader is a class concept that requires the following method:
|
||||
|
|
|
@ -1211,13 +1211,12 @@ class TemplateTypeParmDecl final : public TypeDecl,
|
|||
DefArgStorage DefaultArgument;
|
||||
|
||||
TemplateTypeParmDecl(DeclContext *DC, SourceLocation KeyLoc,
|
||||
SourceLocation IdLoc, IdentifierInfo *Id,
|
||||
bool Typename, bool HasTypeConstraint,
|
||||
Optional<unsigned> NumExpanded)
|
||||
SourceLocation IdLoc, IdentifierInfo *Id, bool Typename,
|
||||
bool HasTypeConstraint, Optional<unsigned> NumExpanded)
|
||||
: TypeDecl(TemplateTypeParm, DC, IdLoc, Id, KeyLoc), Typename(Typename),
|
||||
HasTypeConstraint(HasTypeConstraint), TypeConstraintInitialized(false),
|
||||
ExpandedParameterPack(NumExpanded),
|
||||
NumExpanded(NumExpanded ? *NumExpanded : 0) {}
|
||||
HasTypeConstraint(HasTypeConstraint), TypeConstraintInitialized(false),
|
||||
ExpandedParameterPack(NumExpanded),
|
||||
NumExpanded(NumExpanded.getValueOr(0)) {}
|
||||
|
||||
public:
|
||||
static TemplateTypeParmDecl *Create(const ASTContext &C, DeclContext *DC,
|
||||
|
|
|
@ -645,7 +645,7 @@ bool Parser::parseMatcherExpressionImpl(const TokenInfo &NameToken,
|
|||
Tokenizer->SkipNewlines();
|
||||
|
||||
{
|
||||
ScopedContextEntry SCE(this, Ctor ? *Ctor : nullptr);
|
||||
ScopedContextEntry SCE(this, Ctor.getValueOr(nullptr));
|
||||
|
||||
while (Tokenizer->nextTokenKind() != TokenInfo::TK_Eof) {
|
||||
if (Tokenizer->nextTokenKind() == TokenInfo::TK_CloseParen) {
|
||||
|
|
|
@ -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 ? *Min : 0));
|
||||
Args.push_back(llvm::ConstantInt::get(CGM.Int32Ty, SMin ? *SMin : 0));
|
||||
Args.push_back(llvm::ConstantInt::get(CGM.Int32Ty, Min.getValueOr(0)));
|
||||
Args.push_back(llvm::ConstantInt::get(CGM.Int32Ty, SMin.getValueOr(0)));
|
||||
};
|
||||
|
||||
assert(!Version.empty() && "unexpected empty version");
|
||||
|
@ -3952,8 +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 ? *Min : 0),
|
||||
llvm::ConstantInt::get(CGM.Int32Ty, SMin ? *SMin : 0),
|
||||
llvm::ConstantInt::get(CGM.Int32Ty, Min.getValueOr(0)),
|
||||
llvm::ConstantInt::get(CGM.Int32Ty, SMin.getValueOr(0))
|
||||
};
|
||||
|
||||
llvm::Value *CallRes =
|
||||
|
|
|
@ -1338,7 +1338,7 @@ std::vector<PhdrEntry *> LinkerScript::createPhdrs() {
|
|||
// Process PHDRS and FILEHDR keywords because they are not
|
||||
// real output sections and cannot be added in the following loop.
|
||||
for (const PhdrsCommand &cmd : phdrsCommands) {
|
||||
PhdrEntry *phdr = make<PhdrEntry>(cmd.type, cmd.flags ? *cmd.flags : PF_R);
|
||||
PhdrEntry *phdr = make<PhdrEntry>(cmd.type, cmd.flags.getValueOr(PF_R));
|
||||
|
||||
if (cmd.hasFilehdr)
|
||||
phdr->add(Out::elfHeader);
|
||||
|
|
|
@ -153,7 +153,7 @@ public:
|
|||
const DWARFAbbreviationDeclarationSet *GetAbbreviations() const;
|
||||
dw_offset_t GetAbbrevOffset() const;
|
||||
uint8_t GetAddressByteSize() const { return m_header.GetAddressByteSize(); }
|
||||
dw_addr_t GetAddrBase() const { return m_addr_base ? *m_addr_base : 0; }
|
||||
dw_addr_t GetAddrBase() const { return m_addr_base.getValueOr(0); }
|
||||
dw_addr_t GetBaseAddress() const { return m_base_addr; }
|
||||
dw_offset_t GetLineTableOffset();
|
||||
dw_addr_t GetRangesBase() const { return m_ranges_base; }
|
||||
|
|
|
@ -73,8 +73,7 @@ bool CommandObjectThreadTraceExportCTF::DoExecute(Args &command,
|
|||
|
||||
if (thread == nullptr) {
|
||||
const uint32_t num_threads = process->GetThreadList().GetSize();
|
||||
size_t tid = m_options.m_thread_index ? *m_options.m_thread_index
|
||||
: LLDB_INVALID_THREAD_ID;
|
||||
size_t tid = m_options.m_thread_index.getValueOr(LLDB_INVALID_THREAD_ID);
|
||||
result.AppendErrorWithFormatv(
|
||||
"Thread index {0} is out of range (valid values are 1 - {1}).\n", tid,
|
||||
num_threads);
|
||||
|
|
|
@ -607,7 +607,7 @@ bool DWARFUnit::parseDWO() {
|
|||
DWO->setAddrOffsetSection(AddrOffsetSection, *AddrOffsetSectionBase);
|
||||
if (getVersion() == 4) {
|
||||
auto DWORangesBase = UnitDie.getRangesBaseAttribute();
|
||||
DWO->setRangesSection(RangeSection, DWORangesBase ? *DWORangesBase : 0);
|
||||
DWO->setRangesSection(RangeSection, DWORangesBase.getValueOr(0));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -4407,7 +4407,7 @@ void SwitchInstProfUpdateWrapper::addCase(
|
|||
Weights.getValue()[SI.getNumSuccessors() - 1] = *W;
|
||||
} else if (Weights) {
|
||||
Changed = true;
|
||||
Weights.getValue().push_back(W ? *W : 0);
|
||||
Weights.getValue().push_back(W.getValueOr(0));
|
||||
}
|
||||
if (Weights)
|
||||
assert(SI.getNumSuccessors() == Weights->size() &&
|
||||
|
|
|
@ -877,8 +877,8 @@ uint64_t MachObjectWriter::writeObject(MCAssembler &Asm,
|
|||
[&](const MCAssembler::VersionInfoType &VersionInfo) {
|
||||
auto EncodeVersion = [](VersionTuple V) -> uint32_t {
|
||||
assert(!V.empty() && "empty version");
|
||||
unsigned Update = V.getSubminor() ? *V.getSubminor() : 0;
|
||||
unsigned Minor = V.getMinor() ? *V.getMinor() : 0;
|
||||
unsigned Update = V.getSubminor().getValueOr(0);
|
||||
unsigned Minor = V.getMinor().getValueOr(0);
|
||||
assert(Update < 256 && "unencodable update target version");
|
||||
assert(Minor < 256 && "unencodable minor target version");
|
||||
assert(V.getMajor() < 65536 && "unencodable major target version");
|
||||
|
|
Loading…
Reference in New Issue