<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/128195>128195</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
diags without usable source location after #127338
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nico
</td>
</tr>
</table>
<pre>
```
$ cat repro.cc
class Location {
public:
static Location CurrentWithoutFunctionName(
const char* file_name = __builtin_FILE(),
int line_number = __builtin_LINE());
};
class NotReachedNoreturnError {
public:
explicit NotReachedNoreturnError(
const Location& location =
Location::CurrentWithoutFunctionName());
[[noreturn]] [[clang::nomerge]] [[clang::noinline]] [[clang::not_tail_called]]
~NotReachedNoreturnError();
};
#define NOTREACHED() NotReachedNoreturnError()
int f() {
NOTREACHED();
return 4;
}
int g() {
return 4;
NOTREACHED();
}
```
```
$ out/gn/bin/clang -c repro.cc -Wunreachable-code-aggressive
repro.cc:22:10: warning: 'return' will never be executed [-Wunreachable-code-return]
22 | return 4;
| ^
repro.cc:12:11: warning: code will never be executed [-Wunreachable-code]
12 | Location::CurrentWithoutFunctionName());
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.
```
The first diag points at the line that has the problem. That's good.
The second diag doesn't point even close to the problem. If the macro is in a header and the diag is in a file that uses the macro 20+ times, it's very hard to see where the problem is.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVcuO6jgTfhqzKYESJyGwyCLNRX9LLX7pqKWzRI5dJB45NvIFztmcZx85SUPfRzMWAuyq-uqrm82ck61GrEjxQIrtjAXfGVtpyc2sMeJ3RZbJ9ElqQnPgzIPFszULzklSc8WcgyfDmZdGAykfSFLDOTRKcpLVcQPOMy_5XWkTrEXtf0rfmeD3QfN4fGA9EroaLOLiRjsPvGOW0BpOUuFRsx6BZFs4HpsglZf6uH982kUruiZ0c7OV2oOSGo869A3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