[lld] Don't use Optional::hasValue (NFC)

This patch replaces x.hasValue() with x where x is contextually
convertible to bool.
This commit is contained in:
Kazu Hirata 2022-06-26 19:37:14 -07:00
parent 96d1b4ddb2
commit 586fb81eee
3 changed files with 7 additions and 7 deletions

View File

@ -744,7 +744,7 @@ static void updateARMVFPArgs(const ARMAttributeParser &attributes,
static void updateSupportedARMFeatures(const ARMAttributeParser &attributes) {
Optional<unsigned> attr =
attributes.getAttributeValue(ARMBuildAttrs::CPU_arch);
if (!attr.hasValue())
if (!attr)
return;
auto arch = attr.getValue();
switch (arch) {

View File

@ -367,7 +367,7 @@ macho::PriorityBuilder::buildInputSectionPriorities() {
auto addSym = [&](const Defined *sym) {
Optional<size_t> symbolPriority = getSymbolPriority(sym);
if (!symbolPriority.hasValue())
if (!symbolPriority)
return;
size_t &priority = sectionPriorities[sym->isec];
priority = std::max(priority, symbolPriority.getValue());

View File

@ -249,9 +249,9 @@ class InputFunction : public InputChunk {
public:
InputFunction(const WasmSignature &s, const WasmFunction *func, ObjFile *f)
: InputChunk(f, InputChunk::Function, func->SymbolName), signature(s),
function(func), exportName(func && func->ExportName.hasValue()
? (*func->ExportName).str()
: llvm::Optional<std::string>()) {
function(func),
exportName(func && func->ExportName ? (*func->ExportName).str()
: llvm::Optional<std::string>()) {
inputSectionOffset = function->CodeSectionOffset;
rawData =
file->codeSection->Content.slice(inputSectionOffset, function->Size);
@ -268,8 +268,8 @@ public:
}
llvm::Optional<StringRef> getExportName() const {
return exportName.hasValue() ? llvm::Optional<StringRef>(*exportName)
: llvm::Optional<StringRef>();
return exportName ? llvm::Optional<StringRef>(*exportName)
: llvm::Optional<StringRef>();
}
void setExportName(std::string exportName) { this->exportName = exportName; }
uint32_t getFunctionInputOffset() const { return getInputSectionOffset(); }