From 586fb81eee1fba4ca784d136f303b861c1dfd29c Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 26 Jun 2022 19:37:14 -0700 Subject: [PATCH] [lld] Don't use Optional::hasValue (NFC) This patch replaces x.hasValue() with x where x is contextually convertible to bool. --- lld/ELF/InputFiles.cpp | 2 +- lld/MachO/SectionPriorities.cpp | 2 +- lld/wasm/InputChunks.h | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 926400d047ec..25632e5cf0db 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -744,7 +744,7 @@ static void updateARMVFPArgs(const ARMAttributeParser &attributes, static void updateSupportedARMFeatures(const ARMAttributeParser &attributes) { Optional attr = attributes.getAttributeValue(ARMBuildAttrs::CPU_arch); - if (!attr.hasValue()) + if (!attr) return; auto arch = attr.getValue(); switch (arch) { diff --git a/lld/MachO/SectionPriorities.cpp b/lld/MachO/SectionPriorities.cpp index cdabd3e9ef46..ac4878343ac0 100644 --- a/lld/MachO/SectionPriorities.cpp +++ b/lld/MachO/SectionPriorities.cpp @@ -367,7 +367,7 @@ macho::PriorityBuilder::buildInputSectionPriorities() { auto addSym = [&](const Defined *sym) { Optional symbolPriority = getSymbolPriority(sym); - if (!symbolPriority.hasValue()) + if (!symbolPriority) return; size_t &priority = sectionPriorities[sym->isec]; priority = std::max(priority, symbolPriority.getValue()); diff --git a/lld/wasm/InputChunks.h b/lld/wasm/InputChunks.h index f9626160976c..022a8ad5a422 100644 --- a/lld/wasm/InputChunks.h +++ b/lld/wasm/InputChunks.h @@ -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()) { + function(func), + exportName(func && func->ExportName ? (*func->ExportName).str() + : llvm::Optional()) { inputSectionOffset = function->CodeSectionOffset; rawData = file->codeSection->Content.slice(inputSectionOffset, function->Size); @@ -268,8 +268,8 @@ public: } llvm::Optional getExportName() const { - return exportName.hasValue() ? llvm::Optional(*exportName) - : llvm::Optional(); + return exportName ? llvm::Optional(*exportName) + : llvm::Optional(); } void setExportName(std::string exportName) { this->exportName = exportName; } uint32_t getFunctionInputOffset() const { return getInputSectionOffset(); }