llvm-6502/lib/MC/MCNullStreamer.cpp
Kevin Enderby 29c96f133e Fix the assembler to print a better relocatable expression error
diagnostic that includes location information.

Currently if one has this assembly:

	.quad (0x1234 + (4 * SOME_VALUE))

where SOME_VALUE is undefined ones gets the less than
useful error message with no location information:

% clang -c x.s
clang -cc1as: fatal error: error in backend: expected relocatable expression

With this fix one now gets a more useful error message
with location information:

% clang -c x.s 
x.s:5:8: error: expected relocatable expression
 .quad (0x1234 + (4 * SOME_VALUE))
       ^

To do this I plumbed the SMLoc through the MCObjectStreamer
EmitValue() and EmitValueImpl() interfaces so it could be used
when creating the MCFixup.

rdar://12391022


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206906 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-22 17:27:29 +00:00

116 lines
4.5 KiB
C++

//===- lib/MC/MCNullStreamer.cpp - Dummy Streamer Implementation ----------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCSymbol.h"
using namespace llvm;
namespace {
class MCNullStreamer : public MCStreamer {
public:
MCNullStreamer(MCContext &Context) : MCStreamer(Context) {}
/// @name MCStreamer Interface
/// @{
void ChangeSection(const MCSection *Section,
const MCExpr *Subsection) override {
}
void EmitLabel(MCSymbol *Symbol) override {
assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
assert(getCurrentSection().first &&"Cannot emit before setting section!");
AssignSection(Symbol, getCurrentSection().first);
}
void EmitDebugLabel(MCSymbol *Symbol) override {
EmitLabel(Symbol);
}
void EmitAssemblerFlag(MCAssemblerFlag Flag) override {}
void EmitThumbFunc(MCSymbol *Func) override {}
void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override {}
void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override {}
void EmitDwarfAdvanceLineAddr(int64_t LineDelta,
const MCSymbol *LastLabel,
const MCSymbol *Label,
unsigned PointerSize) override {}
bool EmitSymbolAttribute(MCSymbol *Symbol,
MCSymbolAttr Attribute) override {
return true;
}
void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override {}
void BeginCOFFSymbolDef(const MCSymbol *Symbol) override {}
void EmitCOFFSymbolStorageClass(int StorageClass) override {}
void EmitCOFFSymbolType(int Type) override {}
void EndCOFFSymbolDef() override {}
void EmitCOFFSecRel32(MCSymbol const *Symbol) override {}
void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) override {}
void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
unsigned ByteAlignment) override {}
void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
unsigned ByteAlignment) override {}
void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = nullptr,
uint64_t Size = 0, unsigned ByteAlignment = 0) override {}
void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
uint64_t Size, unsigned ByteAlignment) override {}
void EmitBytes(StringRef Data) override {}
void EmitValueImpl(const MCExpr *Value, unsigned Size,
const SMLoc &Loc = SMLoc()) override {}
void EmitULEB128Value(const MCExpr *Value) override {}
void EmitSLEB128Value(const MCExpr *Value) override {}
void EmitGPRel32Value(const MCExpr *Value) override {}
void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
unsigned ValueSize = 1,
unsigned MaxBytesToEmit = 0) override {}
void EmitCodeAlignment(unsigned ByteAlignment,
unsigned MaxBytesToEmit = 0) override {}
bool EmitValueToOffset(const MCExpr *Offset,
unsigned char Value = 0) override { return false; }
void EmitFileDirective(StringRef Filename) override {}
unsigned EmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
StringRef Filename,
unsigned CUID = 0) override {
return 0;
}
void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
unsigned Column, unsigned Flags,
unsigned Isa, unsigned Discriminator,
StringRef FileName) override {}
void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo&) override {}
void EmitBundleAlignMode(unsigned AlignPow2) override {}
void EmitBundleLock(bool AlignToEnd) override {}
void EmitBundleUnlock() override {}
void FinishImpl() override {}
void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override {
RecordProcEnd(Frame);
}
};
}
MCStreamer *llvm::createNullStreamer(MCContext &Context) {
return new MCNullStreamer(Context);
}