[lld] 586fb81 - [lld] Don't use Optional::hasValue (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 26 19:37:20 PDT 2022
Author: Kazu Hirata
Date: 2022-06-26T19:37:14-07:00
New Revision: 586fb81eee1fba4ca784d136f303b861c1dfd29c
URL: https://github.com/llvm/llvm-project/commit/586fb81eee1fba4ca784d136f303b861c1dfd29c
DIFF: https://github.com/llvm/llvm-project/commit/586fb81eee1fba4ca784d136f303b861c1dfd29c.diff
LOG: [lld] Don't use Optional::hasValue (NFC)
This patch replaces x.hasValue() with x where x is contextually
convertible to bool.
Added:
Modified:
lld/ELF/InputFiles.cpp
lld/MachO/SectionPriorities.cpp
lld/wasm/InputChunks.h
Removed:
################################################################################
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 926400d047ece..25632e5cf0db2 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<unsigned> 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 cdabd3e9ef465..ac4878343ac04 100644
--- a/lld/MachO/SectionPriorities.cpp
+++ b/lld/MachO/SectionPriorities.cpp
@@ -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());
diff --git a/lld/wasm/InputChunks.h b/lld/wasm/InputChunks.h
index f9626160976ce..022a8ad5a4221 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<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 @@ class InputFunction : public InputChunk {
}
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(); }
More information about the llvm-commits
mailing list