Page MenuHomePhabricator

[libcxx] refactor for throw
Needs ReviewPublic

Authored by weimingz on Jun 24 2016, 4:13 PM.

Details

Summary

Replacing macro guarded throw with __libcpp_throw

Diff Detail

Event Timeline

weimingz updated this revision to Diff 61854.Jun 24 2016, 4:13 PM
weimingz retitled this revision from to [libcxx] refactor for throw or assert.
weimingz updated this object.
weimingz added reviewers: rmaprath, grandinj.
weimingz added a subscriber: cfe-commits.

Before replacing all throw/assert to macros, let's first check if we're on the right path.

EricWF added a subscriber: EricWF.

We actually have a non-macro that does this. It's called __libcpp_throw and it lives in <exception>. Please use that instead.

EricWF requested changes to this revision.Jun 29 2016, 11:43 PM
EricWF edited edge metadata.

Please make the changes in the above comment.

This revision now requires changes to proceed.Jun 29 2016, 11:43 PM

Please make the changes in the above comment.

Sure. I'm working on it. Just got interrupted/distracted by other tasks time to time. :(

weimingz updated this revision to Diff 62470.Jun 30 2016, 11:51 PM
weimingz retitled this revision from [libcxx] refactor for throw or assert to [libcxx] refactor for throw.
weimingz updated this object.
weimingz edited edge metadata.
grandinj added inline comments.Jul 1 2016, 12:15 AM
include/array
209

the error message of the assert was perhaps better?

219

the error message of the assert was perhaps better?

include/experimental/dynarray
279

the error message of the assert was perhaps better?

291

ditto

include/map
1446

looks like extra spaces in this message (which was there in the original, I know)

1457

extra spaces here too

rmaprath edited edge metadata.Jul 1 2016, 1:26 AM

Generally looks OK to me.

There are similar uses in test sources as well, but those can be taken care of separately (I'm hoping to get back to the -fno-exceptions XFAILs soon).

weimingz updated this revision to Diff 62515.Jul 1 2016, 11:20 AM
weimingz edited edge metadata.
weimingz marked 5 inline comments as done.

fix issues per Noel's suggestion

mclow.lists edited edge metadata.Jul 1 2016, 12:57 PM

This is getting close. A nit, and a couple of non-trivial comments.

include/exception
262

I thought that we were going to add a macro for the "no return if no exceptions"

src/future.cpp
96

Is the indentation right here? (or is phab lying to me?)

src/locale.cpp
527

Did you miss one here?

weimingz added inline comments.Jul 1 2016, 1:38 PM
include/exception
262

something like this?

#ifndef __LIBCPP_NO_EXCEPTIONS

#define NORETURN_EXP __attribute__((noreturn))

#else

#define NORETURN_EXP

#endif

inline NORETURN_EXP void libcpp_throw(_Exception const& e) {

...

}

src/future.cpp
96

It looks ok here. The first underscore is on the same column as "__has_value" (the line above). 4 space indention

src/locale.cpp
527

The reason I skipeed this and two or three other similar cases is the constructor expects the function __libcpp_throw() to return a pointer.

Hi Marshall, do you have any comments?

I just realized that this will break the following code:

try {  __cxxabiv1:: __cxa_bad_cast(); }
catch ( std::bad_cast &ex ) {}

because what gets thrown is a const std::bad_cast &

Yes, people should catch by value or const reference.
But that doesn't mean that they always do.

include/exception
262

There's another patch out for review that adds noreturn attributes for some functions when exceptions are disabled. I suggested a macro name like _LIBCPP_NO_RETURN_WHEN_EXCEPTIONS_DISABLED for this instead of using the [[noreturn]] or __attribute__((noreturn)) .

I can't find the review at the moment, but I'll turn it up.

rmaprath resigned from this revision.Sep 27 2016, 1:07 PM
rmaprath removed a reviewer: rmaprath.
EricWF resigned from this revision.Oct 9 2016, 11:15 PM
EricWF removed a reviewer: EricWF.

I think we've got most of this now. Do we still need this patch?