Metadata holds positions of the beginning of each line of the inline assembly no matter what is the leading character
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
In ```CGStmt.cpp```, function ```getAsmSrcLocInfo()``` returns ```MDNode``` that contains positions of a start of each new line of the inline assembly in the source code.
In a case where the instruction is not at the beginning of the assembly line and the assembly line is split into two or more lines in the source code, it can happen that the beginning of the assembly line and the assembly instruction are not the same line in the source code. In that case source location that contains the beginning of this assembly line will be printed and the line where the instruction is won't be printed.
Below is an example that demonstrates this issue:
```
#include
#include
void *memset(void *dest, int c, size_t n)__attribute__((naked));
void *memset(void *dest, int c, size_t n) {
__asm__(
"\t"
"mov rdi, 1\n"
);
}
int main() {return 0;}
```
Command: ```clang -o test.o test.c```
Output:
```
test.c:7:9: error: unknown use of instruction mnemonic
without a size suffix
7 | "\t"
| ^
:1:3: note: instantiated into assembly here
1 | mov rdi, 1
| ^
1 error generated.
```
As one can see, the printed line of the source code is not the one where the assembly instruction is.
**A potential solution can be to modify ```getAsmSrcLocInfo()``` so it catches the position of a character that comes after leading horizontal tabulators, blank spaces and similar characters.**
Contributor guide
Assessment
This issue has not been assessed yet.