Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
c3325cb5
Commit
c3325cb5
authored
Nov 17, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support GCC and MSVC anonymous namespace encodings
parent
e0aaa1db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
6 deletions
+18
-6
libcaf_core/src/logger.cpp
libcaf_core/src/logger.cpp
+18
-6
No files found.
libcaf_core/src/logger.cpp
View file @
c3325cb5
...
@@ -63,7 +63,12 @@ constexpr string_view fun_prefixes[] = {
...
@@ -63,7 +63,12 @@ constexpr string_view fun_prefixes[] = {
"unsigned "
,
"unsigned "
,
};
};
constexpr
string_view
anon_ns
=
"(anonymous namespace)"
;
// Various spellings of the anonymous namespace as reported by CAF_PRETTY_FUN.
constexpr
string_view
anon_ns
[]
=
{
"(anonymous namespace)"
,
// Clang
"{anonymous}"
,
// GCC
"`anonymous-namespace'"
,
// MSVC
};
/// Reduces symbol by printing all prefixes to `out` and returning the
/// Reduces symbol by printing all prefixes to `out` and returning the
/// remainder. For example, "ns::foo::bar" prints "ns.foo" to `out` and returns
/// remainder. For example, "ns::foo::bar" prints "ns.foo" to `out` and returns
...
@@ -107,13 +112,17 @@ string_view reduce_symbol(std::ostream& out, string_view symbol) {
...
@@ -107,13 +112,17 @@ string_view reduce_symbol(std::ostream& out, string_view symbol) {
case
':'
:
case
':'
:
advance
(
2
);
advance
(
2
);
break
;
break
;
// This either marks the beginning of the argument list *or* on GCC
// These characters are invalid in function names, unless they indicate
// is part of "(anonymous namespace)".
// an anonymous namespace or the beginning of the argument list.
case
'('
:
case
'`'
:
if
(
starts_with
(
symbol
,
anon_ns
))
{
case
'{'
:
case
'('
:
{
auto
pred
=
[
&
](
string_view
x
)
{
return
starts_with
(
symbol
,
x
);
};
auto
i
=
std
::
find_if
(
std
::
begin
(
anon_ns
),
std
::
end
(
anon_ns
),
pred
);
if
(
i
!=
std
::
end
(
anon_ns
))
{
set_last
(
"$"
);
set_last
(
"$"
);
// The anonymous namespace is always followed by "::".
// The anonymous namespace is always followed by "::".
symbol
.
remove_prefix
(
anon_ns
.
size
()
+
2
);
symbol
.
remove_prefix
(
i
->
size
()
+
2
);
pos
=
0
;
pos
=
0
;
break
;
break
;
}
}
...
@@ -123,6 +132,7 @@ string_view reduce_symbol(std::ostream& out, string_view symbol) {
...
@@ -123,6 +132,7 @@ string_view reduce_symbol(std::ostream& out, string_view symbol) {
if
(
!
printed
)
if
(
!
printed
)
out
<<
"GLOBAL"
;
out
<<
"GLOBAL"
;
return
symbol
;
return
symbol
;
}
case
'<'
:
case
'<'
:
flush
();
flush
();
out
<<
'<'
;
out
<<
'<'
;
...
@@ -437,6 +447,8 @@ void logger::render_fun_prefix(std::ostream& out, const event& x) {
...
@@ -437,6 +447,8 @@ void logger::render_fun_prefix(std::ostream& out, const event& x) {
break
;
break
;
}
}
}
}
// MSVC puts '__cdecl' between the return type and the function name.
skip
(
"__cdecl "
);
reduced
.
remove_prefix
(
pos
);
reduced
.
remove_prefix
(
pos
);
};
};
skip_return_type
();
skip_return_type
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment