Skip to content

Commit d20a1f6

Browse files
committed
test _LIBCPP_HIDE_FROM_ABI on sentry methods
1 parent 47f81a8 commit d20a1f6

File tree

2 files changed

+50
-46
lines changed

2 files changed

+50
-46
lines changed

libcxx/include/__ostream/basic_ostream.h

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -180,43 +180,45 @@ class basic_ostream : virtual public basic_ios<_CharT, _Traits> {
180180
_LIBCPP_HIDE_FROM_ABI basic_ostream() {} // extension, intentially does not initialize
181181
};
182182

183+
#if defined(__MINGW32__) || defined(__CYGWIN__)
184+
# define _LIBCPP_HIDE_INNER_CLASS_METHOD _LIBCPP_HIDE_FROM_ABI
185+
#else
186+
# define _LIBCPP_HIDE_INNER_CLASS_METHOD _LIBCPP_HIDE_FROM_ABI_AFTER_V1
187+
#endif
188+
183189
template <class _CharT, class _Traits>
184190
class basic_ostream<_CharT, _Traits>::sentry {
185191
bool __ok_;
186192
basic_ostream<_CharT, _Traits>& __os_;
187193

188194
public:
189-
explicit sentry(basic_ostream<_CharT, _Traits>& __os);
190-
~sentry();
191-
sentry(const sentry&) = delete;
192-
sentry& operator=(const sentry&) = delete;
193-
194-
_LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return __ok_; }
195-
};
196-
197-
template <class _CharT, class _Traits>
198-
basic_ostream<_CharT, _Traits>::sentry::sentry(basic_ostream<_CharT, _Traits>& __os) : __ok_(false), __os_(__os) {
199-
if (__os.good()) {
200-
if (__os.tie())
201-
__os.tie()->flush();
202-
__ok_ = true;
195+
_LIBCPP_HIDE_INNER_CLASS_METHOD explicit sentry(basic_ostream<_CharT, _Traits>& __os) : __ok_(false), __os_(__os) {
196+
if (__os.good()) {
197+
if (__os.tie())
198+
__os.tie()->flush();
199+
__ok_ = true;
200+
}
203201
}
204-
}
205202

206-
template <class _CharT, class _Traits>
207-
basic_ostream<_CharT, _Traits>::sentry::~sentry() {
208-
if (__os_.rdbuf() && __os_.good() && (__os_.flags() & ios_base::unitbuf) && uncaught_exceptions() == 0) {
203+
_LIBCPP_HIDE_INNER_CLASS_METHOD ~sentry() {
204+
if (__os_.rdbuf() && __os_.good() && (__os_.flags() & ios_base::unitbuf) && uncaught_exceptions() == 0) {
209205
# if _LIBCPP_HAS_EXCEPTIONS
210-
try {
206+
try {
211207
# endif // _LIBCPP_HAS_EXCEPTIONS
212-
if (__os_.rdbuf()->pubsync() == -1)
213-
__os_.setstate(ios_base::badbit);
208+
if (__os_.rdbuf()->pubsync() == -1)
209+
__os_.setstate(ios_base::badbit);
214210
# if _LIBCPP_HAS_EXCEPTIONS
215-
} catch (...) {
216-
}
211+
} catch (...) {
212+
}
217213
# endif // _LIBCPP_HAS_EXCEPTIONS
214+
}
218215
}
219-
}
216+
217+
sentry(const sentry&) = delete;
218+
sentry& operator=(const sentry&) = delete;
219+
220+
_LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return __ok_; }
221+
};
220222

221223
template <class _CharT, class _Traits>
222224
basic_ostream<_CharT, _Traits>::basic_ostream(basic_ostream&& __rhs) {

libcxx/include/istream

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,30 @@ class basic_istream<_CharT, _Traits>::sentry {
309309
bool __ok_;
310310

311311
public:
312-
explicit sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
312+
#if defined(__MINGW32__) || defined(__CYGWIN__)
313+
_LIBCPP_HIDE_FROM_ABI
314+
#else
315+
_LIBCPP_HIDE_FROM_ABI_AFTER_V1
316+
#endif
317+
explicit sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false) : __ok_(false) {
318+
if (__is.good()) {
319+
if (__is.tie())
320+
__is.tie()->flush();
321+
if (!__noskipws && (__is.flags() & ios_base::skipws)) {
322+
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
323+
const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
324+
_Ip __i(__is);
325+
_Ip __eof;
326+
for (; __i != __eof; ++__i)
327+
if (!__ct.is(__ct.space, *__i))
328+
break;
329+
if (__i == __eof)
330+
__is.setstate(ios_base::failbit | ios_base::eofbit);
331+
}
332+
__ok_ = __is.good();
333+
} else
334+
__is.setstate(ios_base::failbit);
335+
}
313336
// ~sentry() = default;
314337

315338
_LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return __ok_; }
@@ -318,27 +341,6 @@ public:
318341
sentry& operator=(const sentry&) = delete;
319342
};
320343

321-
template <class _CharT, class _Traits>
322-
basic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws) : __ok_(false) {
323-
if (__is.good()) {
324-
if (__is.tie())
325-
__is.tie()->flush();
326-
if (!__noskipws && (__is.flags() & ios_base::skipws)) {
327-
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
328-
const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
329-
_Ip __i(__is);
330-
_Ip __eof;
331-
for (; __i != __eof; ++__i)
332-
if (!__ct.is(__ct.space, *__i))
333-
break;
334-
if (__i == __eof)
335-
__is.setstate(ios_base::failbit | ios_base::eofbit);
336-
}
337-
__ok_ = __is.good();
338-
} else
339-
__is.setstate(ios_base::failbit);
340-
}
341-
342344
template <class _CharT, class _Traits>
343345
basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs) : __gc_(__rhs.__gc_) {
344346
__rhs.__gc_ = 0;

0 commit comments

Comments
 (0)