@@ -51,20 +51,44 @@ bool PeelArgName(const char** arg_names, const char** out_arg_name,
51
51
} // namespace
52
52
53
53
void EventDefinition::AppendName (std::string* output) const {
54
- const char * colon = strchr (name_spec_, ' :' );
55
- if (colon) {
56
- output->append (name_spec_, (colon - name_spec_));
57
- } else {
58
- output->append (name_spec_);
54
+ // Colons are used as separators in WTF's binary format so can't be part of
55
+ // identifiers, but '::' commonly appears in auto-generated C++ identifier
56
+ // names, as with the __PRETTY_FUNCTION__ built-in macro.
57
+ // Replace double colons with '#', which is WTF's class/namespace separator.
58
+ //
59
+ // A single : in a name_spec separates the name part from arguments.
60
+ const char *src = name_spec_;
61
+ const char * colon = strchr (src, ' :' );
62
+ while (colon) {
63
+ output->append (src, (colon - src));
64
+ src = colon + 1 ;
65
+ if (*src == ' :' ) {
66
+ // Double colon, replace with # and continue.
67
+ output->append (" #" );
68
+ src += 1 ;
69
+ colon = strchr (src, ' :' );
70
+ } else {
71
+ // This was a single colon. Output no more.
72
+ return ;
73
+ }
59
74
}
75
+ // Append anything remaining in src.
76
+ output->append (src);
60
77
}
61
78
62
79
void EventDefinition::AppendArguments (std::string* output) const {
63
80
if (argument_zipper_ && name_spec_) {
64
81
const char * arg_names = strchr (name_spec_, ' :' );
65
- if (arg_names) {
82
+ while (arg_names) {
66
83
// Colon found - advance.
67
84
arg_names += 1 ;
85
+ if (*arg_names == ' :' ) {
86
+ // Actually a '::' namespace separator, keep looking.
87
+ arg_names += 1 ;
88
+ arg_names = strchr (arg_names, ' :' );
89
+ } else {
90
+ break ;
91
+ }
68
92
}
69
93
argument_zipper_ (output, arg_names);
70
94
}
0 commit comments