diff options
Diffstat (limited to 'lib/MC/MCFragment.cpp')
-rw-r--r-- | lib/MC/MCFragment.cpp | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/lib/MC/MCFragment.cpp b/lib/MC/MCFragment.cpp index 8ff8f8aba1c1c..90b44177cf5e8 100644 --- a/lib/MC/MCFragment.cpp +++ b/lib/MC/MCFragment.cpp @@ -7,30 +7,29 @@ // //===----------------------------------------------------------------------===// -#include "llvm/MC/MCFragment.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Twine.h" #include "llvm/MC/MCAssembler.h" -#include "llvm/MC/MCAsmBackend.h" -#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCAsmLayout.h" #include "llvm/MC/MCContext.h" -#include "llvm/MC/MCDwarf.h" #include "llvm/MC/MCExpr.h" -#include "llvm/MC/MCFixupKindInfo.h" +#include "llvm/MC/MCFixup.h" +#include "llvm/MC/MCFragment.h" #include "llvm/MC/MCSection.h" -#include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCValue.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/LEB128.h" -#include "llvm/Support/TargetRegistry.h" #include "llvm/Support/raw_ostream.h" +#include <cassert> +#include <cstdint> +#include <utility> + using namespace llvm; -MCAsmLayout::MCAsmLayout(MCAssembler &Asm) - : Assembler(Asm), LastValidFragment() - { +MCAsmLayout::MCAsmLayout(MCAssembler &Asm) : Assembler(Asm) { // Compute the section layout order. Virtual sections must go last. for (MCSection &Sec : Asm) if (!Sec.isVirtualSection()) @@ -145,14 +144,14 @@ const MCSymbol *MCAsmLayout::getBaseSymbol(const MCSymbol &Symbol) const { MCValue Value; if (!Expr->evaluateAsValue(Value, *this)) { Assembler.getContext().reportError( - SMLoc(), "expression could not be evaluated"); + Expr->getLoc(), "expression could not be evaluated"); return nullptr; } const MCSymbolRefExpr *RefB = Value.getSymB(); if (RefB) { Assembler.getContext().reportError( - SMLoc(), Twine("symbol '") + RefB->getSymbol().getName() + + Expr->getLoc(), Twine("symbol '") + RefB->getSymbol().getName() + "' could not be evaluated in a subtraction expression"); return nullptr; } @@ -164,8 +163,7 @@ const MCSymbol *MCAsmLayout::getBaseSymbol(const MCSymbol &Symbol) const { const MCSymbol &ASym = A->getSymbol(); const MCAssembler &Asm = getAssembler(); if (ASym.isCommon()) { - // FIXME: we should probably add a SMLoc to MCExpr. - Asm.getContext().reportError(SMLoc(), + Asm.getContext().reportError(Expr->getLoc(), "Common symbol '" + ASym.getName() + "' cannot be used in assignment expr"); return nullptr; @@ -234,7 +232,7 @@ uint64_t llvm::computeBundlePadding(const MCAssembler &Assembler, void ilist_alloc_traits<MCFragment>::deleteNode(MCFragment *V) { V->destroy(); } -MCFragment::~MCFragment() { } +MCFragment::~MCFragment() = default; MCFragment::MCFragment(FragmentType Kind, bool HasInstructions, uint8_t BundlePadding, MCSection *Parent) @@ -295,8 +293,6 @@ void MCFragment::destroy() { } } -/* *** */ - // Debugging methods namespace llvm { @@ -308,10 +304,11 @@ raw_ostream &operator<<(raw_ostream &OS, const MCFixup &AF) { return OS; } -} +} // end namespace llvm +#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void MCFragment::dump() { - raw_ostream &OS = llvm::errs(); + raw_ostream &OS = errs(); OS << "<"; switch (getKind()) { @@ -449,7 +446,7 @@ LLVM_DUMP_METHOD void MCFragment::dump() { } LLVM_DUMP_METHOD void MCAssembler::dump() { - raw_ostream &OS = llvm::errs(); + raw_ostream &OS = errs(); OS << "<MCAssembler\n"; OS << " Sections:[\n "; @@ -469,3 +466,4 @@ LLVM_DUMP_METHOD void MCAssembler::dump() { } OS << "]>\n"; } +#endif |