From 6871d0a330315ad680875fc13f85111bb3ec8f2e Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 10 Apr 2019 10:30:22 +0000 Subject: [PATCH] MCSymbolicELF: simplify. (Flags & (x << s)) >> s is equivalent to Flags >> s & x git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358067 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/MCSymbolELF.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/MC/MCSymbolELF.cpp b/lib/MC/MCSymbolELF.cpp index 3931f1e5721..a07c56c64f8 100644 --- a/lib/MC/MCSymbolELF.cpp +++ b/lib/MC/MCSymbolELF.cpp @@ -65,7 +65,7 @@ void MCSymbolELF::setBinding(unsigned Binding) const { unsigned MCSymbolELF::getBinding() const { if (isBindingSet()) { - uint32_t Val = (getFlags() & (0x3 << ELF_STB_Shift)) >> ELF_STB_Shift; + uint32_t Val = (Flags >> ELF_STB_Shift) & 3; switch (Val) { default: llvm_unreachable("Invalid value"); @@ -125,7 +125,7 @@ void MCSymbolELF::setType(unsigned Type) const { } unsigned MCSymbolELF::getType() const { - uint32_t Val = (getFlags() & (0x7 << ELF_STT_Shift)) >> ELF_STT_Shift; + uint32_t Val = (Flags >> ELF_STT_Shift) & 7; switch (Val) { default: llvm_unreachable("Invalid value"); @@ -155,9 +155,7 @@ void MCSymbolELF::setVisibility(unsigned Visibility) { } unsigned MCSymbolELF::getVisibility() const { - unsigned Visibility = (getFlags() & (0x3 << ELF_STV_Shift)) >> ELF_STV_Shift; - assert(Visibility == ELF::STV_DEFAULT || Visibility == ELF::STV_INTERNAL || - Visibility == ELF::STV_HIDDEN || Visibility == ELF::STV_PROTECTED); + unsigned Visibility = (Flags >> ELF_STV_Shift) & 3; return Visibility; } @@ -170,7 +168,7 @@ void MCSymbolELF::setOther(unsigned Other) { } unsigned MCSymbolELF::getOther() const { - unsigned Other = (getFlags() & (0x7 << ELF_STO_Shift)) >> ELF_STO_Shift; + unsigned Other = (Flags >> ELF_STO_Shift) & 7; return Other << 5; } -- 2.50.1