From 2fa744e631cbabe583da010ec56560edbc7a5384 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Fri, 16 Dec 2022 22:44:08 +0000 Subject: std::optional::value => operator*/operator-> value() has undesired exception checking semantics and calls __throw_bad_optional_access in libc++. Moreover, the API is unavailable without _LIBCPP_NO_EXCEPTIONS on older Mach-O platforms (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). This commit fixes LLVMAnalysis and its dependencies. --- llvm/lib/Object/ELFObjectFile.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'llvm/lib/Object/ELFObjectFile.cpp') diff --git a/llvm/lib/Object/ELFObjectFile.cpp b/llvm/lib/Object/ELFObjectFile.cpp index a3593eae..6b29703 100644 --- a/llvm/lib/Object/ELFObjectFile.cpp +++ b/llvm/lib/Object/ELFObjectFile.cpp @@ -169,11 +169,11 @@ SubtargetFeatures ELFObjectFileBase::getARMFeatures() const { std::optional Attr = Attributes.getAttributeValue(ARMBuildAttrs::CPU_arch); if (Attr) - isV7 = Attr.value() == ARMBuildAttrs::v7; + isV7 = *Attr == ARMBuildAttrs::v7; Attr = Attributes.getAttributeValue(ARMBuildAttrs::CPU_arch_profile); if (Attr) { - switch (Attr.value()) { + switch (*Attr) { case ARMBuildAttrs::ApplicationProfile: Features.AddFeature("aclass"); break; @@ -192,7 +192,7 @@ SubtargetFeatures ELFObjectFileBase::getARMFeatures() const { Attr = Attributes.getAttributeValue(ARMBuildAttrs::THUMB_ISA_use); if (Attr) { - switch (Attr.value()) { + switch (*Attr) { default: break; case ARMBuildAttrs::Not_Allowed: @@ -207,7 +207,7 @@ SubtargetFeatures ELFObjectFileBase::getARMFeatures() const { Attr = Attributes.getAttributeValue(ARMBuildAttrs::FP_arch); if (Attr) { - switch (Attr.value()) { + switch (*Attr) { default: break; case ARMBuildAttrs::Not_Allowed: @@ -231,7 +231,7 @@ SubtargetFeatures ELFObjectFileBase::getARMFeatures() const { Attr = Attributes.getAttributeValue(ARMBuildAttrs::Advanced_SIMD_arch); if (Attr) { - switch (Attr.value()) { + switch (*Attr) { default: break; case ARMBuildAttrs::Not_Allowed: @@ -250,7 +250,7 @@ SubtargetFeatures ELFObjectFileBase::getARMFeatures() const { Attr = Attributes.getAttributeValue(ARMBuildAttrs::MVE_arch); if (Attr) { - switch (Attr.value()) { + switch (*Attr) { default: break; case ARMBuildAttrs::Not_Allowed: @@ -269,7 +269,7 @@ SubtargetFeatures ELFObjectFileBase::getARMFeatures() const { Attr = Attributes.getAttributeValue(ARMBuildAttrs::DIV_use); if (Attr) { - switch (Attr.value()) { + switch (*Attr) { default: break; case ARMBuildAttrs::DisallowDIV: @@ -546,7 +546,7 @@ void ELFObjectFileBase::setARMSubArch(Triple &TheTriple) const { std::optional Attr = Attributes.getAttributeValue(ARMBuildAttrs::CPU_arch); if (Attr) { - switch (Attr.value()) { + switch (*Attr) { case ARMBuildAttrs::v4: Triple += "v4"; break; @@ -578,7 +578,7 @@ void ELFObjectFileBase::setARMSubArch(Triple &TheTriple) const { std::optional ArchProfileAttr = Attributes.getAttributeValue(ARMBuildAttrs::CPU_arch_profile); if (ArchProfileAttr && - ArchProfileAttr.value() == ARMBuildAttrs::MicroControllerProfile) + *ArchProfileAttr == ARMBuildAttrs::MicroControllerProfile) Triple += "v7m"; else Triple += "v7"; -- cgit v1.1