diff options
author | Jim Grosbach <grosbach@apple.com> | 2012-01-27 00:37:08 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2012-01-27 00:37:08 +0000 |
commit | ebd4c05c3cbd61215366d4d16f1c1a2e57e7156d (patch) | |
tree | 97d9f1a971c21688223b77711c5541748ae0c7f6 /lib/MC | |
parent | 3b0714d993a37c722603f7cbfab71848a99e91cd (diff) | |
download | external_llvm-ebd4c05c3cbd61215366d4d16f1c1a2e57e7156d.zip external_llvm-ebd4c05c3cbd61215366d4d16f1c1a2e57e7156d.tar.gz external_llvm-ebd4c05c3cbd61215366d4d16f1c1a2e57e7156d.tar.bz2 |
Better diagnostic for malformed .org assembly directive.
Provide source line number information.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149101 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r-- | lib/MC/MCAsmStreamer.cpp | 5 | ||||
-rw-r--r-- | lib/MC/MCNullStreamer.cpp | 4 | ||||
-rw-r--r-- | lib/MC/MCObjectStreamer.cpp | 7 | ||||
-rw-r--r-- | lib/MC/MCParser/AsmParser.cpp | 9 | ||||
-rw-r--r-- | lib/MC/MCPureStreamer.cpp | 5 |
5 files changed, 18 insertions, 12 deletions
diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp index a2fb7a4..afad5d5 100644 --- a/lib/MC/MCAsmStreamer.cpp +++ b/lib/MC/MCAsmStreamer.cpp @@ -199,7 +199,7 @@ public: virtual void EmitCodeAlignment(unsigned ByteAlignment, unsigned MaxBytesToEmit = 0); - virtual void EmitValueToOffset(const MCExpr *Offset, + virtual bool EmitValueToOffset(const MCExpr *Offset, unsigned char Value = 0); virtual void EmitFileDirective(StringRef Filename); @@ -744,11 +744,12 @@ void MCAsmStreamer::EmitCodeAlignment(unsigned ByteAlignment, 1, MaxBytesToEmit); } -void MCAsmStreamer::EmitValueToOffset(const MCExpr *Offset, +bool MCAsmStreamer::EmitValueToOffset(const MCExpr *Offset, unsigned char Value) { // FIXME: Verify that Offset is associated with the current section. OS << ".org " << *Offset << ", " << (unsigned) Value; EmitEOL(); + return false; } diff --git a/lib/MC/MCNullStreamer.cpp b/lib/MC/MCNullStreamer.cpp index 432974f..ba7f81f 100644 --- a/lib/MC/MCNullStreamer.cpp +++ b/lib/MC/MCNullStreamer.cpp @@ -80,8 +80,8 @@ namespace { virtual void EmitCodeAlignment(unsigned ByteAlignment, unsigned MaxBytesToEmit = 0) {} - virtual void EmitValueToOffset(const MCExpr *Offset, - unsigned char Value = 0) {} + virtual bool EmitValueToOffset(const MCExpr *Offset, + unsigned char Value = 0) { return false; } virtual void EmitFileDirective(StringRef Filename) {} virtual bool EmitDwarfFileDirective(unsigned FileNo, StringRef Directory, diff --git a/lib/MC/MCObjectStreamer.cpp b/lib/MC/MCObjectStreamer.cpp index d8f1826..f2911fa 100644 --- a/lib/MC/MCObjectStreamer.cpp +++ b/lib/MC/MCObjectStreamer.cpp @@ -232,12 +232,12 @@ void MCObjectStreamer::EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel, new MCDwarfCallFrameFragment(*AddrDelta, getCurrentSectionData()); } -void MCObjectStreamer::EmitValueToOffset(const MCExpr *Offset, +bool MCObjectStreamer::EmitValueToOffset(const MCExpr *Offset, unsigned char Value) { int64_t Res; if (Offset->EvaluateAsAbsolute(Res, getAssembler())) { new MCOrgFragment(*Offset, Value, getCurrentSectionData()); - return; + return false; } MCSymbol *CurrentPos = getContext().CreateTempSymbol(); @@ -249,8 +249,9 @@ void MCObjectStreamer::EmitValueToOffset(const MCExpr *Offset, MCBinaryExpr::Create(MCBinaryExpr::Sub, Offset, Ref, getContext()); if (!Delta->EvaluateAsAbsolute(Res, getAssembler())) - report_fatal_error("expected assembly-time absolute expression"); + return true; EmitFill(Res, Value, 0); + return false; } // Associate GPRel32 fixup with data and resize data area diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index 64d0dd8..1af7cd9 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -1970,6 +1970,7 @@ bool AsmParser::ParseDirectiveOrg() { CheckForValidSection(); const MCExpr *Offset; + SMLoc Loc = getTok().getLoc(); if (ParseExpression(Offset)) return true; @@ -1989,9 +1990,11 @@ bool AsmParser::ParseDirectiveOrg() { Lex(); - // FIXME: Only limited forms of relocatable expressions are accepted here, it - // has to be relative to the current section. - getStreamer().EmitValueToOffset(Offset, FillExpr); + // Only limited forms of relocatable expressions are accepted here, it + // has to be relative to the current section. The streamer will return + // 'true' if the expression wasn't evaluatable. + if (getStreamer().EmitValueToOffset(Offset, FillExpr)) + return Error(Loc, "expected assembly-time absolute expression"); return false; } diff --git a/lib/MC/MCPureStreamer.cpp b/lib/MC/MCPureStreamer.cpp index 8a3bf87..a770c97 100644 --- a/lib/MC/MCPureStreamer.cpp +++ b/lib/MC/MCPureStreamer.cpp @@ -46,7 +46,7 @@ public: unsigned MaxBytesToEmit = 0); virtual void EmitCodeAlignment(unsigned ByteAlignment, unsigned MaxBytesToEmit = 0); - virtual void EmitValueToOffset(const MCExpr *Offset, + virtual bool EmitValueToOffset(const MCExpr *Offset, unsigned char Value = 0); virtual void FinishImpl(); @@ -184,9 +184,10 @@ void MCPureStreamer::EmitCodeAlignment(unsigned ByteAlignment, getCurrentSectionData()->setAlignment(ByteAlignment); } -void MCPureStreamer::EmitValueToOffset(const MCExpr *Offset, +bool MCPureStreamer::EmitValueToOffset(const MCExpr *Offset, unsigned char Value) { new MCOrgFragment(*Offset, Value, getCurrentSectionData()); + return false; } void MCPureStreamer::EmitInstToFragment(const MCInst &Inst) { |