Commit 30ce79ed authored by Reid Kleckner's avatar Reid Kleckner
Browse files

Merging rr353218:

------------------------------------------------------------------------
r353218 | rnk | 2019-02-05 13:14:09 -0800 (Tue, 05 Feb 2019) | 19 lines

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

Summary:
Before r349976, MC ignored such directives when producing an object file
and asserted when re-producing textual assembly output. I turned this
assertion into a hard error in both cases in r349976, but this makes it
unnecessarily difficult to write a single assembly file that supports
both MachO and other object formats that support .file. A user reported
this as PR40578, and we decided to go back to ignoring the directive.

Fixes PR40578

Reviewers: mstorsjo

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57772
------------------------------------------------------------------------

llvm-svn: 353220
parent a9a9c27e
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -3364,9 +3364,10 @@ bool AsmParser::parseDirectiveFile(SMLoc DirectiveLoc) {
  }

  if (FileNumber == -1) {
    if (!getContext().getAsmInfo()->hasSingleParameterDotFile())
      return Error(DirectiveLoc,
                   "target does not support '.file' without a number");
    // 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,

llvm/test/MC/MachO/file-single.s

deleted100644 → 0
+0 −8
Original line number Diff line number Diff line
// 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
+3 −0
Original line number Diff line number Diff line
// 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