MCAsmStreamer::addExplicitComment is not agnostic to line-endings.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
An accidental `CRLF` checkout of `llvm/test/MC/AsmParser/block-comment.s` revealed that the multi-line comment processing in `MCAsmStreamer::addExplicitComment` is not agnostic to the line-ending used. The other paths in the code seems to be.
To reproduce the failure, convert the test file `llvm/test/MC/AsmParser/block-comment.s` to use `CRLF` (_e.g._ via `unix2dos`) and run the test.
```
$ unix2dos ./llvm/test/MC/AsmParser/block-comment.s
$ cd
$ ninja check-llvm-mc-asmparser
```
This will result in an additional blank line not matched by the test.
```
# .---command stderr------------
# | /home/patric.hedlin/gitviews/llvm-MC-AsmParser-agnostic-eol/llvm/test/MC/AsmParser/block-comment.s:14:14: error: CHECK-NEXT: is not on the line after the previous match
# | # CHECK-NEXT: # two lines{{ }}
# | ^^^
# | :9:1: note: 'next' match was here
# | # two lines
# | ^^^^^^^^
# | :7:12: note: previous match ended here
# | # spanning
# | ^
# | :8:1: note: non-matching line after previous match is here
# | #
# | ^^^^^^^^
# |
# | Input file:
# | Check file: /home/patric.hedlin/gitviews/llvm-MC-AsmParser-agnostic-eol/llvm/test/MC/AsmParser/block-comment.s
# |
# | -dump-input=help explains the following input dump.
# |
# | Input was:
# | <<<<<<
# | 1: # comment
# | 2: nop
# | 3:
# | 4: # space+comment
# | 5: nop
# | 6:
# | 7: # spanning
# | next:14'0 { search range start (exclusive)
# | 8: #
# | 9: # two lines
# | next:14'1 !~~~~~~~~~~~~~ error: match on wrong line
# | 10: nop
# | 11:
# | 12: nop # then an instruction
# | 13:
# | 14: nop # line comment
# | 15:
# | 16: # at end of file
# | 17:
# | next:14'2 } search range end (exclusive)
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1
[eol-agnostic.patch](https://github.com/user-attachments/files/31957870/eol-agnostic.patch)
```
Tested with LLVM 24 built from source.
Contributor guide
Research direction
Start in MCAsmStreamer::addExplicitComment and reproduce the failure by converting llvm/test/MC/AsmParser/block-comment.s to CRLF, then run ninja check-llvm-mc-asmparser from the build directory. Compare the multi-line comment handling with the other line-ending paths; done means the block-comment test passes unchanged with CRLF input and existing tests remain passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100