[all-commits] [llvm/llvm-project] 19c56e: [MC] Fix ICE with non-newline terminated input

Scott Linder via All-commits all-commits at lists.llvm.org
Wed Dec 9 15:44:16 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 19c56e11fa489cfc461b9ea10faa68e5a1f3eca1
      https://github.com/llvm/llvm-project/commit/19c56e11fa489cfc461b9ea10faa68e5a1f3eca1
  Author: Scott Linder <Scott.Linder at amd.com>
  Date:   2020-12-09 (Wed, 09 Dec 2020)

  Changed paths:
    M llvm/lib/MC/MCParser/AsmLexer.cpp
    A llvm/test/MC/AsmParser/Inputs/no-newline-at-end-of-file.s
    M llvm/test/MC/AsmParser/preserve-comments.s

  Log Message:
  -----------
  [MC] Fix ICE with non-newline terminated input

There is an explicit option for the lexer to support this, but we crash
when `-preserve-comments` is enabled because it checks for
`getTok().getString().empty()` to detect the case. This doesn't
work currently because the lexer reports this case as a string of length
1, containing a null byte.

Change the lexer to instead report this case via an empty string, as the
null terminator isn't logically a part of the textual input, and the
check for `.empty()` seems natural and obvious in the calling code.

Reviewed By: niravd

Differential Revision: https://reviews.llvm.org/D92681




More information about the All-commits mailing list