Skip to content

Commit a2ad2e5

Browse files
committed
workarounds
1 parent 2b8613a commit a2ad2e5

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

include/boost/leaf/detail/demangle.hpp

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,14 @@ namespace n
155155
}
156156
};
157157

158-
#ifdef _WIN32
158+
#ifdef _MSC_VER
159159
# define BOOST_LEAF_CDECL __cdecl
160-
# define BOOST_LEAF_CDECL_S "__cdecl "
161160
#else
162161
# define BOOST_LEAF_CDECL
163-
# define BOOST_LEAF_CDECL_S
164162
#endif
165163

166164
template <class T>
167-
BOOST_LEAF_ALWAYS_INLINE r BOOST_LEAF_CDECL p(int)
165+
BOOST_LEAF_ALWAYS_INLINE r BOOST_LEAF_CDECL p()
168166
{
169167
// C++11 compile-time parsing of __PRETTY_FUNCTION__/__FUNCSIG__. The sizeof hacks are a
170168
// workaround for older GCC versions, where __PRETTY_FUNCTION__ is not constexpr, which triggers
@@ -178,47 +176,52 @@ namespace n
178176

179177
#define BOOST_LEAF_P(P) (sizeof(char[1 + detail::check_prefix(BOOST_LEAF_PRETTY_FUNCTION, P)]) - 1)
180178
// clang style:
181-
std::size_t const p01 = BOOST_LEAF_P("r " BOOST_LEAF_CDECL_S "boost::leaf::n::p(int) [T = ");
179+
std::size_t const p01 = BOOST_LEAF_P("r boost::leaf::n::p() [T = ");
180+
std::size_t const p02 = BOOST_LEAF_P("r __cdecl boost::leaf::n::p(void) [T = ");
182181
// old clang style:
183-
std::size_t const p02 = BOOST_LEAF_P("boost::leaf::n::r " BOOST_LEAF_CDECL_S "boost::leaf::n::p(int) [T = ");
182+
std::size_t const p03 = BOOST_LEAF_P("boost::leaf::n::r boost::leaf::n::p() [T = ");
183+
std::size_t const p04 = BOOST_LEAF_P("boost::leaf::n::r __cdecl boost::leaf::n::p(void) [T = ");
184184
// gcc style:
185-
std::size_t const p03 = BOOST_LEAF_P("boost::leaf::n::r " BOOST_LEAF_CDECL_S "boost::leaf::n::p(int) [with T = ");
186-
// msvc style:
187-
std::size_t const p04 = BOOST_LEAF_P("struct boost::leaf::n::r " BOOST_LEAF_CDECL_S "boost::leaf::n::p<struct ");
188-
std::size_t const p05 = BOOST_LEAF_P("struct boost::leaf::n::r " BOOST_LEAF_CDECL_S "boost::leaf::n::p<class ");
189-
std::size_t const p06 = BOOST_LEAF_P("struct boost::leaf::n::r " BOOST_LEAF_CDECL_S "boost::leaf::n::p<enum ");
190-
std::size_t const p07 = BOOST_LEAF_P("struct boost::leaf::n::r " BOOST_LEAF_CDECL_S "boost::leaf::n::p<");
185+
std::size_t const p05 = BOOST_LEAF_P("boost::leaf::n::r boost::leaf::n::p() [with T = ");
186+
std::size_t const p06 = BOOST_LEAF_P("boost::leaf::n::r __cdecl boost::leaf::n::p() [with T = ");
187+
// msvc style, struct:
188+
std::size_t const p07 = BOOST_LEAF_P("struct boost::leaf::n::r __cdecl boost::leaf::n::p<struct ");
189+
// msvc style, class:
190+
std::size_t const p08 = BOOST_LEAF_P("struct boost::leaf::n::r __cdecl boost::leaf::n::p<class ");
191+
// msvc style, enum:
192+
std::size_t const p09 = BOOST_LEAF_P("struct boost::leaf::n::r __cdecl boost::leaf::n::p<enum ");
193+
// msvc style, built-in type:
194+
std::size_t const p10 = BOOST_LEAF_P("struct boost::leaf::n::r __cdecl boost::leaf::n::p<");
191195
#undef BOOST_LEAF_P
192196

193197
#define BOOST_LEAF_S(S) (sizeof(char[1 + detail::check_suffix(BOOST_LEAF_PRETTY_FUNCTION, S)]) - 1)
194198
// clang/gcc style:
195199
std::size_t const s01 = BOOST_LEAF_S("]");
196200
// msvc style:
197-
std::size_t const s02 = BOOST_LEAF_S(">(int)");
201+
std::size_t const s02 = BOOST_LEAF_S(">(void)");
198202
#undef BOOST_LEAF_S
199203

200204
char static_assert_unrecognized_pretty_function_format_please_file_github_issue[sizeof(
201205
char[
202-
(s01 && (1 == (!!p01 + !!p02 + !!p03)))
206+
(s01 && (1 == (!!p01 + !!p02 + !!p03 + !!p04 + !!p05 + !!p06)))
203207
||
204-
(s02 && (1 == (!!p04 + !!p05 + !!p06)))
208+
(s02 && (1 == (!!p07 + !!p08 + !!p09)))
205209
||
206-
(s02 && !!p07)
210+
(s02 && !!p10)
207211
]
208212
) * 2 - 1];
209213
(void) static_assert_unrecognized_pretty_function_format_please_file_github_issue;
210214

211-
if( std::size_t const p = sizeof(char[1 + !!s01 * (p01 + p02 + p03)]) - 1 )
215+
if( std::size_t const p = sizeof(char[1 + !!s01 * (p01 + p02 + p03 + p04 + p05 + p06)]) - 1 )
212216
return { BOOST_LEAF_PRETTY_FUNCTION + p, s01 - p, detail::compute_hash(BOOST_LEAF_PRETTY_FUNCTION, p, s01) };
213217

214-
if( std::size_t const p = sizeof(char[1 + !!s02 * (p04 + p05 + p06)]) - 1 )
218+
if( std::size_t const p = sizeof(char[1 + !!s02 * (p07 + p08 + p09)]) - 1 )
215219
return { BOOST_LEAF_PRETTY_FUNCTION + p, s02 - p, detail::compute_hash(BOOST_LEAF_PRETTY_FUNCTION, p, s02) };
216220

217-
std::size_t const p = sizeof(char[1 + !!s02 * p07]) - 1;
221+
std::size_t const p = sizeof(char[1 + !!s02 * p10]) - 1;
218222
return { BOOST_LEAF_PRETTY_FUNCTION + p, s02 - p, detail::compute_hash(BOOST_LEAF_PRETTY_FUNCTION, p, s02) };
219223
}
220224

221-
#undef BOOST_LEAF_CDECL_S
222225
#undef BOOST_LEAF_CDECL
223226

224227
} // namespace n
@@ -228,7 +231,7 @@ using parsed = n::r;
228231
template <class T>
229232
parsed parse()
230233
{
231-
return n::p<T>(42);
234+
return n::p<T>();
232235
}
233236

234237
} } // namespace boost::leaf

include/boost/leaf/serialization/diagnostics_writer.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ namespace serialization
150150
}
151151
else
152152
#endif
153+
{
153154
prefix_ = "\nCaught:" BOOST_LEAF_CFG_DIAGNOSTICS_FIRST_DELIMITER;
155+
}
154156
(void) ex;
155157
}
156158

0 commit comments

Comments
 (0)