Skip to content

Commit

Permalink
MC: Remove redundant SetUsed arguments in MCSymbol methods
Browse files Browse the repository at this point in the history
We can probably take this a step further since the only
user of the isUsed flag is AsmParser it should probably
be doing this explicitly. For now this is a step in the
right direction though.

Differential Revision: https://reviews.llvm.org/D41971

llvm-svn: 322386
  • Loading branch information
sbc100 committed Jan 12, 2018
1 parent edff13b commit 5e102ee
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
27 changes: 13 additions & 14 deletions llvm/include/llvm/MC/MCSymbol.h
Expand Up @@ -177,8 +177,8 @@ class MCSymbol {
llvm_unreachable("Constructor throws?");
}

MCSection *getSectionPtr(bool SetUsed = true) const {
if (MCFragment *F = getFragment(SetUsed)) {
MCSection *getSectionPtr() const {
if (MCFragment *F = getFragment()) {
assert(F != AbsolutePseudoFragment);
return F->getParent();
}
Expand Down Expand Up @@ -221,7 +221,6 @@ class MCSymbol {

/// isUsed - Check if this is used.
bool isUsed() const { return IsUsed; }
void setUsed(bool Value) const { IsUsed |= Value; }

/// \brief Check if this symbol is redefinable.
bool isRedefinable() const { return IsRedefinable; }
Expand All @@ -246,28 +245,28 @@ class MCSymbol {
/// isDefined - Check if this symbol is defined (i.e., it has an address).
///
/// Defined symbols are either absolute or in some section.
bool isDefined(bool SetUsed = true) const {
return getFragment(SetUsed) != nullptr;
}
bool isDefined() const { return !isUndefined(); }

/// isInSection - Check if this symbol is defined in some section (i.e., it
/// is defined but not absolute).
bool isInSection(bool SetUsed = true) const {
return isDefined(SetUsed) && !isAbsolute(SetUsed);
bool isInSection() const {
return isDefined() && !isAbsolute();
}

/// isUndefined - Check if this symbol undefined (i.e., implicitly defined).
bool isUndefined(bool SetUsed = true) const { return !isDefined(SetUsed); }
bool isUndefined(bool SetUsed = true) const {
return getFragment(SetUsed) == nullptr;
}

/// isAbsolute - Check if this is an absolute symbol.
bool isAbsolute(bool SetUsed = true) const {
return getFragment(SetUsed) == AbsolutePseudoFragment;
bool isAbsolute() const {
return getFragment() == AbsolutePseudoFragment;
}

/// Get the section associated with a defined, non-absolute symbol.
MCSection &getSection(bool SetUsed = true) const {
assert(isInSection(SetUsed) && "Invalid accessor!");
return *getSectionPtr(SetUsed);
MCSection &getSection() const {
assert(isInSection() && "Invalid accessor!");
return *getSectionPtr();
}

/// Mark the symbol as defined in the fragment \p F.
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/MC/MCCodeView.cpp
Expand Up @@ -507,7 +507,7 @@ void CodeViewContext::encodeInlineLineTable(MCAsmLayout &Layout,
if (!LocAfter.empty()) {
// Only try to compute this difference if we're in the same section.
const MCCVLineEntry &Loc = LocAfter[0];
if (&Loc.getLabel()->getSection(false) == &LastLabel->getSection(false))
if (&Loc.getLabel()->getSection() == &LastLabel->getSection())
LocAfterLength = computeLabelDiff(Layout, LastLabel, Loc.getLabel());
}

Expand Down
Expand Up @@ -124,7 +124,7 @@ void HexagonMCELFStreamer::HexagonMCEmitCommonSymbol(MCSymbol *Symbol,
MCSectionSubPair P = getCurrentSection();
SwitchSection(&Section);

if (ELFSymbol->isUndefined(false)) {
if (ELFSymbol->isUndefined()) {
EmitValueToAlignment(ByteAlignment, 0, 1, 0);
EmitLabel(Symbol);
EmitZeros(Size);
Expand Down

0 comments on commit 5e102ee

Please sign in to comment.