-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"
Description
https://godbolt.org/z/4jx1dxE3E
#include <iostream>
#include <source_location>
template <typename T>
auto PrettyName() -> char const* {
return std::source_location::current().function_name();
}
void normal() {
struct A{};
std::cout << "normal: " << PrettyName<A>() << '\n';
}
struct A;
int main() {
auto lambda = []{
struct A{};
std::cout << "lambda: " << PrettyName<A>() << '\n';
};
std::cout << "global: " << PrettyName<A>() << '\n';
normal();
lambda();
}clang output:
global: const char *PrettyName() [T = A]
normal: const char *PrettyName() [T = A]
lambda: const char *PrettyName() [T = A]
The GCC output is not ambiguous:
global: const char* PrettyName() [with T = A]
normal: const char* PrettyName() [with T = normal()::A]
lambda: const char* PrettyName() [with T = main()::<lambda()>::A]
I think it might be an good idea to change __PRETTY_FUNCTION__ output for function local types to something similar of what GCC does. Its annoying to look into a log file and see a type that exists globally while another function locale type was used. Thats pretty hard to debug.
Metadata
Metadata
Assignees
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"