[PATCH] D14645: [ARM, AArch64] Store source location for values in assembly files

Oliver Stannard via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 13 03:00:08 PST 2015


olista01 created this revision.
olista01 added a subscriber: llvm-commits.
olista01 set the repository for this revision to rL LLVM.
Herald added subscribers: rengolin, aemerson.

The MCValue class can store a SMLoc to allow better error messages to be emitted if an error is detected after parsing. The ARM and AArch64 assembly parsers were not setting this, so error messages did not have source information.

Repository:
  rL LLVM

http://reviews.llvm.org/D14645

Files:
  lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
  lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
  test/MC/AArch64/error-location.s
  test/MC/ARM/error-location.s

Index: test/MC/ARM/error-location.s
===================================================================
--- /dev/null
+++ test/MC/ARM/error-location.s
@@ -0,0 +1,5 @@
+@ RUN: not llvm-mc -triple armv7a--none-eabi -filetype obj < %s -o /dev/null 2>&1 | FileCheck %s
+
+  .text
+@ CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: symbol 'undef' can not be undefined in a subtraction expression
+  .word (0-undef)
Index: test/MC/AArch64/error-location.s
===================================================================
--- /dev/null
+++ test/MC/AArch64/error-location.s
@@ -0,0 +1,5 @@
+// RUN: not llvm-mc -triple aarch64--none-eabi -filetype obj < %s -o /dev/null 2>&1 | FileCheck %s
+
+  .text
+// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: symbol 'undef' can not be undefined in a subtraction expression
+  .word (0-undef)
Index: lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
===================================================================
--- lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
+++ lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
@@ -513,7 +513,7 @@
         getContext().reportFatalError(Loc, "relocated expression must be 32-bit");
 
     EmitDataMappingSymbol();
-    MCELFStreamer::EmitValueImpl(Value, Size);
+    MCELFStreamer::EmitValueImpl(Value, Size, Loc);
   }
 
   void EmitAssemblerFlag(MCAssemblerFlag Flag) override {
Index: lib/Target/ARM/AsmParser/ARMAsmParser.cpp
===================================================================
--- lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -8801,7 +8801,7 @@
         return false;
       }
 
-      getParser().getStreamer().EmitValue(Value, Size);
+      getParser().getStreamer().EmitValue(Value, Size, L);
 
       if (getLexer().is(AsmToken::EndOfStatement))
         break;
Index: lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
===================================================================
--- lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
+++ lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
@@ -130,7 +130,7 @@
   /// if necessary.
   void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) override {
     EmitDataMappingSymbol();
-    MCELFStreamer::EmitValueImpl(Value, Size);
+    MCELFStreamer::EmitValueImpl(Value, Size, Loc);
   }
 
 private:
Index: lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
===================================================================
--- lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -4131,7 +4131,7 @@
       if (getParser().parseExpression(Value))
         return true;
 
-      getParser().getStreamer().EmitValue(Value, Size);
+      getParser().getStreamer().EmitValue(Value, Size, L);
 
       if (getLexer().is(AsmToken::EndOfStatement))
         break;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14645.40129.patch
Type: text/x-patch
Size: 2822 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151113/c94ae44a/attachment.bin>


More information about the llvm-commits mailing list