clang 22.1.0 lambda synthetic-identifier diagnostic
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Hello,
I'm working on a general purpose c++ type- and function-name parser module for my mocking framework, which shall help enhancing certain diagnostic messages. This was and is a lot of work, but I aim to support most of the compiler quirks I encountered.
When it comes to lambdas, compilers notoriously disagree how to present them to the user. While gcc most of the times issues something like ``, clang often uses `(lambda at ...)` or even `(anonymous class)`; both are very distinguishable from a valid parameter-list.
However, clang-22 changes that `(anonymous class)` to `(lambda)`, which unfortunately could actually be interpreted as a parameter-list.
This small snippet reproduces this:
```cpp
#include
#include
constexpr auto l = [] {
return std::source_location::current();
};
int main()
{
std::cout << l().function_name();
}
```
clang-21 (and prior) printed `auto (anonymous class)::operator()() const`,
while clang-22 now prints `auto (lambda)::operator()() const`.
https://godbolt.org/z/9h5dEM7Kb
I wouldn't mind the change, if it couldn't be misinterpreted as a valid identifier. If clang would also add the additional `at ...` part that would also work for me, but just `(lambda)` seems to be quite troublesome.
Contributor guide
Assessment
This issue has not been assessed yet.