[PATCH] D57772: [MC] Don't error on numberless .file directives on MachO

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 5 13:14:10 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL353218: [MC] Don't error on numberless .file directives on MachO (authored by rnk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D57772?vs=185358&id=185388#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57772/new/

https://reviews.llvm.org/D57772

Files:
  llvm/trunk/lib/MC/MCParser/AsmParser.cpp
  llvm/trunk/test/MC/MachO/file-single.s
  llvm/trunk/test/MC/MachO/file.s


Index: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
===================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp
@@ -3370,10 +3370,11 @@
   }
 
   if (FileNumber == -1) {
-    if (!getContext().getAsmInfo()->hasSingleParameterDotFile())
-      return Error(DirectiveLoc,
-                   "target does not support '.file' without a number");
-    getStreamer().EmitFileDirective(Filename);
+    // Ignore the directive if there is no number and the target doesn't support
+    // numberless .file directives. This allows some portability of assembler
+    // between different object file formats.
+    if (getContext().getAsmInfo()->hasSingleParameterDotFile())
+      getStreamer().EmitFileDirective(Filename);
   } else {
     // In case there is a -g option as well as debug info from directive .file,
     // we turn off the -g option, directly use the existing debug info instead.
Index: llvm/trunk/test/MC/MachO/file.s
===================================================================
--- llvm/trunk/test/MC/MachO/file.s
+++ llvm/trunk/test/MC/MachO/file.s
@@ -1,5 +1,8 @@
 // RUN: llvm-mc -triple i386-apple-darwin9 %s -filetype=obj -o - | llvm-readobj -s -section-data | FileCheck %s
 
+// This number-less file directive is ignored on MachO.
+        .file "bar/baz.s"
+
         .file	1 "dir/foo"
         nop
 
Index: llvm/trunk/test/MC/MachO/file-single.s
===================================================================
--- llvm/trunk/test/MC/MachO/file-single.s
+++ llvm/trunk/test/MC/MachO/file-single.s
@@ -1,8 +0,0 @@
-// RUN: not llvm-mc -triple i386-apple-darwin9 %s -o /dev/null 2>&1 | FileCheck %s
-
-// Previously this crashed MC.
-
-// CHECK: error: target does not support '.file' without a number
-
-        .file "dir/foo"
-        nop


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57772.185388.patch
Type: text/x-patch
Size: 1863 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190205/c66e3bd5/attachment.bin>


More information about the llvm-commits mailing list