mirror of
https://github.com/wolfpld/tracy.git
synced 2026-11-19 22:25:59 +00:00
Fix operator names broken by name shortening.
The '<' of operator< and friends is part of the name, not the start of a template argument list. ns::Foo::operator<(ns::Foo const&) shortens to ns::Foo::operator<(), not ns::Foo::operator<>. The '::' inside a conversion operator's type-id is part of the name as well. ns::Widget::operator ns::Handle() shortens to operator ns::Handle(), not Handle().
This commit is contained in:
@@ -18,6 +18,18 @@ constexpr const char* TypesList[] = {
|
||||
"uint32_t ", "uint64_t ", "ptrdiff_t ", nullptr
|
||||
};
|
||||
|
||||
static constexpr char OpSyms[] = "+-*/%^&|~!<>=[](){}\"";
|
||||
|
||||
static bool IsOperatorBracket( const char* start, const char* ptr )
|
||||
{
|
||||
auto anchor = ptr;
|
||||
while( anchor > start && strchr( OpSyms, anchor[-1] ) != nullptr ) anchor--;
|
||||
if( ptr - anchor >= 2 ) return false;
|
||||
if( ptr - anchor == 1 && ptr[-1] != '<' ) return false;
|
||||
if( anchor - start < 8 || memcmp( anchor - 8, "operator", 8 ) != 0 ) return false;
|
||||
return anchor == start + 8 || anchor[-9] == ' ' || anchor[-9] == ':';
|
||||
}
|
||||
|
||||
const char* ShortenZoneName( ShortenName type, const char* name, ImVec2& tsz, float zsz )
|
||||
{
|
||||
assert( type != ShortenName::Never );
|
||||
@@ -38,6 +50,11 @@ const char* ShortenZoneName( ShortenName type, const char* name, ImVec2& tsz, fl
|
||||
memcpy( dst, start, ptr - start + 1 );
|
||||
dst += ptr - start + 1;
|
||||
if( ptr == end ) break;
|
||||
if( IsOperatorBracket( name, ptr ) )
|
||||
{
|
||||
ptr++;
|
||||
continue;
|
||||
}
|
||||
cnt++;
|
||||
ptr++;
|
||||
while( cnt > 0 )
|
||||
@@ -112,6 +129,7 @@ const char* ShortenZoneName( ShortenName type, const char* name, ImVec2& tsz, fl
|
||||
auto p = ptr;
|
||||
while( p < end && *p != ':' ) p++;
|
||||
if( p == end ) return ptr;
|
||||
if( p - ptr >= 9 && memcmp( ptr, "operator ", 9 ) == 0 ) return ptr;
|
||||
p++;
|
||||
while( p < end && *p == ':' ) p++;
|
||||
ptr = p;
|
||||
|
||||
Reference in New Issue
Block a user