[llvm] Improving ThinLTO error message for inline assembly errors (PR #102211)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 11 15:41:08 PDT 2024


https://github.com/MaskRay commented:

The clang style `t.c:2:7: error:` plus `<inline asm>:1:16: note: ` was from e06b2b7012de1c04c746df1c1ced0eefe23f42d5 (2011).
(The code is currently around clang/lib/CodeGen/CodeGenAction.cpp:502).

I think the ideal diagnostic should look like the following:

```
a.cc:3:17: error: unknown token in expression
<inline asm>:1:14: note: instantiated into assembly here
    1 |         BAD SYNTAX$%
      |                     ^
```

> And yes, this is only a best-effort patch -- there are still problems that I'm not sure if there's an easy way to fix...

While these limitations still remain, printing error+note offers the best clarity.

I think we should:

* drop `BaseLine + ...` `LineNo -= BaseLine;` twiddling.
* add a second line member to `SMDiagnostic`
* change LLCDiagnosticHandler::handleDiagnostics to print error+note if inline asm diagnostic information (from debug info) is available and remove `WithColor::note() << "!srcloc = " << DISM.getLocCookie() << "\n"`.


https://github.com/llvm/llvm-project/pull/102211


More information about the llvm-commits mailing list