Commit Graph

859 Commits

Author SHA1 Message Date
Howard Hinnant 3f0d2384aa Add -fstrict-aliasing -Wstrict-aliasing and change optimization from -Os to -O3
llvm-svn: 149250
2012-01-30 16:03:23 +00:00
Howard Hinnant 5bbc597f1e Put throw() clauses back on these functions in cxxabi.h. This header must be C++03 compatible and these throw specs are consistent with the current cxxabi.h that Apple ships.
llvm-svn: 149249
2012-01-30 16:02:11 +00:00
Howard Hinnant 9aa4684fbb Minor updates to a couple of comments.
llvm-svn: 149158
2012-01-28 00:34:46 +00:00
Howard Hinnant ece71ead6d Add a little paranoia for testing purposes.
llvm-svn: 149157
2012-01-28 00:32:31 +00:00
Howard Hinnant 805036cc83 Minor header fixups for test.
llvm-svn: 149156
2012-01-28 00:30:38 +00:00
Howard Hinnant 44e3703639 Silence a warning.
llvm-svn: 149155
2012-01-28 00:29:27 +00:00
Howard Hinnant ad048719a7 Sometimes it takes all day to write a decent comment. This is one of those times, and I'm still not quite sure I have them correct.
llvm-svn: 149154
2012-01-28 00:28:31 +00:00
Howard Hinnant 113cf60e0b These commits are intended to be temporary in nature and are to facilitate the testing of libc++abi.dylib at this point in time.
llvm-svn: 148967
2012-01-25 19:27:42 +00:00
Howard Hinnant db97064263 Add comment documenting extension behavior of __cxa_get_globals_fast().
llvm-svn: 148966
2012-01-25 19:19:13 +00:00
Howard Hinnant 5d6b9d28f7 cxa_guard.cpp didn't quite make it on the last commit: Restricted headers to cxa_guard.cpp and abort_messsage.h, and added a comment regarding reentrancy brought up by John McCall. Thanks John.
llvm-svn: 148965
2012-01-25 19:02:40 +00:00
Howard Hinnant 2449538500 Restricted headers to cxa_guard.cpp and abort_messsage.h, and added a comment regarding reentrancy brought up by John McCall. Thanks John.
llvm-svn: 148963
2012-01-25 18:50:55 +00:00
Howard Hinnant abc770690a By changing all of the throw() specs to noexcept I've been able to compile and link all of the source files into a dylib. Prior to this substitution the changed functions were calling __cxa_call_unexpected which isn't implemented yet. However in none of these cases do we actaully want __cxa_call_unexpected to be called. Primative buildit script added.
llvm-svn: 148880
2012-01-24 23:42:30 +00:00
Howard Hinnant 7fdfd5d269 Add some needed symbols in exception.cpp and eliminate dependence upon uncaught_exception() from cxa_vector.cpp. libc++abi is very nearly a self-contained (though not complete) library now.
llvm-svn: 148866
2012-01-24 21:48:10 +00:00
Howard Hinnant 73ab1864ef Marshall Clow reminded me that fallback_malloc.cpp was broken out for testing purposes. We've agreed to simply rename fallback_malloc.cpp to fallback_malloc.ipp. Thanks Marshall.
llvm-svn: 148863
2012-01-24 21:41:27 +00:00
Howard Hinnant 421bbe5cc5 Add some needed symbols to cxa_new_delete.cpp and put the display() stuff under #DEBUG (again).
llvm-svn: 148860
2012-01-24 21:35:18 +00:00
Howard Hinnant 378a59f15c Got fooled by fallback_malloc.cpp source file: it is really a private header. I've manually included it into the only place it is used: cxa_exception.cpp.
llvm-svn: 148854
2012-01-24 21:02:21 +00:00
Howard Hinnant 8b26c3713b Add new file for public type_info-related signatures
llvm-svn: 148853
2012-01-24 21:01:01 +00:00
Howard Hinnant 0d517a4278 CrashReporterClient.h is back, but this time protected with __has_include. Thanks for the suggestion Doug. The use is consistent with how the same header is used in llvm/lib/Support/PrettyStackTrace.cpp (though there autoconfig is used instead of __has_include).
llvm-svn: 148851
2012-01-24 19:58:25 +00:00
Howard Hinnant a9d8ec45f6 Remove dependence upon std::exception_ptr from the default_terminate_handler. Recovered the equivalent functionality at a lower level.
llvm-svn: 148830
2012-01-24 18:26:29 +00:00
Howard Hinnant 9e5d74b239 Forgot to include this file in the last commit: Move kOurExceptionClass and kOurDependentExceptionClass from source to header so that they can be used in multiple sources. This is a private header, these constants are not publicly exposed.
llvm-svn: 148829
2012-01-24 18:17:40 +00:00
Howard Hinnant 6830b2a493 Move kOurExceptionClass and kOurDependentExceptionClass from source to header so that they can be used in multiple sources. This is a private header, these constants are not publicly exposed.
llvm-svn: 148827
2012-01-24 18:15:20 +00:00
Howard Hinnant 82a39907f1 Removed reference to internal header
llvm-svn: 148763
2012-01-24 00:52:33 +00:00
Howard Hinnant e33b2f5c97 Changed my mind about __cxa_uncaught_exception and added it.
llvm-svn: 148754
2012-01-24 00:01:31 +00:00
Howard Hinnant bfbf700151 I renamed abort_message to be a C++ file to simplify my simplistic build script which I'm still working on. I also added a struct for the crash reporter on __APPLE__.
llvm-svn: 148752
2012-01-23 23:58:26 +00:00
Howard Hinnant fad744dd50 A lot of the code in cxa_exception.cpp depends on __cxa_get_globals_fast() returning null if __cxa_get_globals() hasn't been called yet. However it doesn't reliably do that, at least on OS X if __cxa_get_globals_fast() is called prior to pthread_key_create() running. Our choice is to either limit our use of __cxa_get_globals_fast() more than we have, or to have __cxa_get_globals_fast() initialize with pthread_key_create() if necessary. I chose the latter, and replaced pthread_once with a C++11 local static (which should do the same thing).
llvm-svn: 148750
2012-01-23 23:55:58 +00:00
Howard Hinnant 671caae892 Added missing #include
llvm-svn: 148749
2012-01-23 23:51:56 +00:00
Howard Hinnant 53418916fc I'm beginning to be able to throw/catch a wide variety of objects.
llvm-svn: 148713
2012-01-23 18:39:47 +00:00
Howard Hinnant 699692a04c Getting started on matching a thrown exception to a catch clause, and setting the adjusted pointer to the caught object appearing in the catch clause.
llvm-svn: 148666
2012-01-22 21:47:40 +00:00
Howard Hinnant afcf7ac5f6 I kept getting confused among the __cxa_exception*, the _Unwind_Exception* and the void* to the thrown object. So I've gone through these two files and attempted to institute a consistent variable naming scheme, and in a few instances, turned void* into a concrete* to have the type system help me out. No change in functionality for this commit is intended.
llvm-svn: 148663
2012-01-22 19:14:27 +00:00
Howard Hinnant 1a56ee3798 Add __shim_type_info which fits below std::type_info and above all of the other type_info-derived classes. This is where all of the virtual functions that serve as details of the inner-workings of type_info will live (safely hidden from public view). All type_info objects will be safely down-castable to __shim_type_info, so as to access implementation detail virtual functions. Also temporarily add some print/display statements to each type_info-derived class. This is in support of the continuing development on the personality function.
llvm-svn: 148647
2012-01-22 01:23:02 +00:00
Howard Hinnant 242566e552 Change header to generic, instead of implementation specific
llvm-svn: 148646
2012-01-22 01:19:20 +00:00
Howard Hinnant b24c9441d1 One more small optimization: Where possible, for loops that do a search and then try to break out of the loop early, eliminate the attempt to break out of the loop after the last search. And with that, I'm declaring __dynamic_cast done. Though if anyone sees any problems, has suggestions for improvements, or wants to contribute some test cases, that is certainly welcome feedback.
llvm-svn: 148246
2012-01-16 18:21:05 +00:00
Howard Hinnant 44a2895a03 Comment smithing. Changed some casts from C-style to C++. And added timings to all of the tests.
llvm-svn: 148241
2012-01-16 17:06:51 +00:00
Howard Hinnant 77fb8ab9f2 I think this is getting close on __dynamic_cast. There's been quite a bit of code rearrangement, renaming, and better commenting. This exercise has exposed and fixed a few more bugs. I've also added several more tests (there's definitely a need for more tests here).
llvm-svn: 148227
2012-01-16 00:13:46 +00:00
Howard Hinnant f55694af01 Two bug fixes, several clarifications, and a few comment updates.
llvm-svn: 148180
2012-01-14 14:15:43 +00:00
Howard Hinnant fcf732c7a6 A bug fix involving the updating of path_dst_ptr_to_static_ptr. Some minor code rearrangement optimizations (putting most likely 'if' first in an if-else series. And some major optimizations which involve stopping the search prior to an exhaustive walk over the entire tree. Some of these stops are because an ambiguity is detected earlier. And some of the short circuiting is due to the information from the bits __diamond_shaped_mask and __non_diamond_repeat_mask. The stress test checked in last night is now about 28% faster for the B<Width/2, Depth> -O3 case. I'm still playing with some more optimization possibilities but I'm not sure they will play out.
llvm-svn: 148153
2012-01-13 23:06:03 +00:00
Howard Hinnant 50f7eeec9d Enclosed is a stress test for dynamic_cast. It stresses both libc++abi, and clang itself. It creates a ridiculously large class hierarchy using variadic templates. You can specify both the width and depth of the class hierarchy. And you can specify whether the cast is to the actual run time type, or to an intermediate layer in the class. About 1/3 of the time I compile this, it crashes the compiler. There seems to be an uninitialized area of memory, and I'm probably blowing past an assumption on class hierarchy size within clang (and understandably so). I can get it work most of the time with a class hierarchy width of 20 and a depth of 7. I'm making timings with both -O3 and -Os, using both cast to root and cast to intermediate, on both libc++abi, and gcc's dynamic_cast. I've put the results in a comment/table at the bottom of the test.
llvm-svn: 148083
2012-01-13 01:22:31 +00:00
Howard Hinnant b1ca881191 Oops, forgot to svn add the new test.
llvm-svn: 148047
2012-01-12 21:08:25 +00:00
Howard Hinnant b7d59ec6e1 Put debug print statments under a flag so that I can get a first glimpse at performance. So far I haven't noticed any performance difference between this new __dynamic_cast and gcc's implementation. But I've barely started looking. Also adding a couple of tests which come straight out of the standard.
llvm-svn: 148046
2012-01-12 21:06:12 +00:00
Howard Hinnant af07bfdb67 Fixed a couple of bugs, updated many comments, and am including a comprehensive test for when there are only 3 types in place. I need to do something similar for 4 and maybe more types, but I'm not sure how comprehensive I can make the test at 4 and above types.
llvm-svn: 148038
2012-01-12 19:48:14 +00:00
Howard Hinnant f88480363e Initial implementaiton of __dynamic_cast. There is still lots of debugging code in here that needs to be stripped out. And many, many unit tests need to be written. And comments and probably code cleanliness needs to be improved. But I *think* the basic algorithm is sound. There also may still be some oportunities for algorithm optimization, I'm not positive.
llvm-svn: 147981
2012-01-11 23:49:18 +00:00
Howard Hinnant d9e7393741 This is a transitory commit for __dynamic_cast. It contains debugging statements that are not intended to be in the finished product. However some of the dubbing statements themselves contain important documentation such as how to navigate a __class_type_info hierarchy, documenting object offset and inheritance access. The intention is that this debugging code will migrate into both actual code and comments. And capturing it here so that there is no chance this stuff will be lost.
llvm-svn: 147898
2012-01-11 00:11:17 +00:00
Howard Hinnant d88ba82a47 Getting a start on the typeinfo infrastructure.
llvm-svn: 147776
2012-01-09 17:10:00 +00:00
Howard Hinnant 86b4dfac01 First brush with testing __gxx_personality_v0 reveals there is still a long way to go. But my understanding of what it is supposed to do continues to improve. I am currently contemplating whether I need to implement typeinfo before completing __gxx_personality_v0 in order to get matching catch handlers correct.
llvm-svn: 147761
2012-01-08 23:50:46 +00:00
Howard Hinnant 7530f19d03 Add a few TODO's and FIXME's. Making notes as I go along, but not slowing down to fix these yet. Just don't want anything to fall through the cracks.
llvm-svn: 147760
2012-01-08 23:40:41 +00:00
Howard Hinnant 5dc3179e5d Correct comment regarding members of __cxa_dependent_exception. Actually it is useful to disguise a __cxa_dependent_exception as a __cxa_exception by filling in most (not all) of these members at __cxa_dependent_exception construction time. That way most routines don't have to care which kind of exception they have.
llvm-svn: 147759
2012-01-08 23:39:14 +00:00
Howard Hinnant d3dba31762 __gxx_personality_v0 update. This is completely untested code. But my brain is scrambled and I wanted to get it checked in. Code review from anyone who knows anything at all about personality functions would be much appreciated. What is in here is borrowed heavily from llvm/examples/ExceptionDemo/ExceptionDemo.cpp. There are some calls to abort() that should probably be changed to return an error code instead. There may be encodings under readEncodedPointer that need to be implemented. And my handling of type_info is almost a complete guess.
llvm-svn: 147680
2012-01-06 20:39:47 +00:00
Marshall Clow d2bab35080 Improved comment to explain why we can use __cxa_get_globals_fast here
llvm-svn: 147554
2012-01-04 22:18:10 +00:00
Howard Hinnant 66d9327b80 Just getting started on the personality routine. This is just a skeleton. Still learning how to fill it in...
llvm-svn: 147547
2012-01-04 20:49:43 +00:00
Marshall Clow f368486f4c Better comment
llvm-svn: 147532
2012-01-04 14:56:09 +00:00
Marshall Clow f83663a9cd Don't allocate TLS storage when checking to see if an exception has been thrown - really
llvm-svn: 147497
2012-01-03 23:26:09 +00:00
Marshall Clow 3e417e7a5c Don't allocate TLS storage when checking to see if an exception has been thrown
llvm-svn: 147492
2012-01-03 23:10:20 +00:00
Howard Hinnant f5bde09cc1 credits adjustment
llvm-svn: 147148
2011-12-22 16:00:06 +00:00
Marshall Clow 1de4fc0dfa Updated __cxa_current_exception_type to call __cxa_get_globals_fast - will not allocate globals
llvm-svn: 147147
2011-12-22 15:45:05 +00:00
Howard Hinnant 2aa433398a Updated spec.html regarding __cxa_uncaught_exception.
llvm-svn: 147110
2011-12-22 00:03:36 +00:00
Howard Hinnant 22f28b2d52 Forgot to increment uncaughtExceptions in __cxa_rethrow_primary_exception
llvm-svn: 147108
2011-12-21 23:48:05 +00:00
Howard Hinnant e04f51662c Added __cxa_increment_exception_refcount, __cxa_decrement_exception_refcount, __cxa_current_primary_exception, __cxa_rethrow_primary_exception
llvm-svn: 147106
2011-12-21 23:32:11 +00:00
Howard Hinnant 72a05a9198 Add new and delete operators
llvm-svn: 146989
2011-12-20 20:38:05 +00:00
Howard Hinnant bf8a39bb94 Fixed several bugs, implemented support for vector types, and cleaned out dead code.
llvm-svn: 146677
2011-12-15 20:02:15 +00:00
Howard Hinnant 7a084fdd39 Fix size calculation for pointer to member function
llvm-svn: 146463
2011-12-13 01:23:16 +00:00
Howard Hinnant 58926c9a9b Made some minor tweaks to __cxa_rethrow
llvm-svn: 146396
2011-12-12 19:11:42 +00:00
Howard Hinnant 7fcad54836 Added dependent exception support to __cxa_current_exception_type
llvm-svn: 146381
2011-12-12 18:16:10 +00:00
Howard Hinnant 8de583abf2 Added support for <special-name> ::= TC <first type> <number> _ <second type> # construction vtable for second-in-first, and for <special-name> ::= GR <object name> # reference temporary for object
llvm-svn: 146274
2011-12-09 20:07:56 +00:00
Howard Hinnant 6ccae15ef0 Modified __cxa_end_catch to handle dependent exceptions.
llvm-svn: 146172
2011-12-08 19:35:18 +00:00
Howard Hinnant 5ec9183afc Reviewing cxa_exception.cpp and marking as implemented as I go. Not marking as implemented on arm when I'm not sure about that platform.
llvm-svn: 146072
2011-12-07 21:16:40 +00:00
Howard Hinnant b3344a3ac7 Added __cxa_allocate_dependent_exception and __cxa_free_dependent_exception and marked them as done.
llvm-svn: 146045
2011-12-07 18:30:06 +00:00
Howard Hinnant dfb34fcb1a Substituted std::get_terminate() for direct access to the handler function pointer (which is now a static in cxa_handlers.cpp). This has the advantage of going through the atomic API and so is less likely to cause a data race. Ditto for unexpected.
llvm-svn: 145951
2011-12-06 19:02:03 +00:00
Howard Hinnant 987afbeede Add/update copyright notices
llvm-svn: 145949
2011-12-06 18:01:47 +00:00
Howard Hinnant 2642af9e23 terminate, unexpected and new handlers. If terminating while an exception is unwinding, an attempt is made to print out the what() string if the exception is derived from std::exception. __terminate(handler) and __unexpected(handler) helpers are present in anticipation of other parts of libc++abi needing to call these interfaces with custom handlers.
llvm-svn: 145948
2011-12-06 17:51:25 +00:00
Howard Hinnant dc82cca6bf Updated heuristic regulating small string buffer
llvm-svn: 145543
2011-12-01 00:08:59 +00:00
Howard Hinnant 148b3f64ec Add alignment requirement to char buffer
llvm-svn: 145277
2011-11-28 21:03:21 +00:00
Marshall Clow 9b454bc912 reformatted to match Clang style; thanks to John McCall for the nudge
llvm-svn: 137623
2011-08-15 18:06:47 +00:00
Howard Hinnant 26a9d23657 demangler: Drop preceeding () from function types, but not from pointers and references to function types
llvm-svn: 137469
2011-08-12 17:33:10 +00:00
Marshall Clow 8769449b61 First cut at exception handling; missing dependent exceptions. Next step: tests
llvm-svn: 137118
2011-08-09 15:09:41 +00:00
Howard Hinnant 49b607a2cd Silence some -Wall warnings pointed out by Marshall Clow
llvm-svn: 137047
2011-08-08 15:49:07 +00:00
Marshall Clow 7c9f1fa9cf Remove include reference to non-existant file cxa_exception_storage.hpp
llvm-svn: 137046
2011-08-08 15:12:08 +00:00
Nick Kledzik 2dfc79b19e make cxxabi.h safe for C code to include
llvm-svn: 136682
2011-08-02 05:15:26 +00:00
Nick Kledzik 1c839a945b use LIBCXXABI_NORETURN
llvm-svn: 136681
2011-08-02 05:01:31 +00:00
Nick Kledzik 12a10bc046 make LIBCXXABI_NORETURN be the right attribute
llvm-svn: 136680
2011-08-02 05:01:17 +00:00
Nick Kledzik 7cb4926da1 use abort_message() for pthread errors in __cxa_get_globals
llvm-svn: 136672
2011-08-02 01:34:26 +00:00
Nick Kledzik 18ab5f4164 use abort_message()
llvm-svn: 136671
2011-08-02 01:19:07 +00:00
Nick Kledzik 49cbb02a6a move abort_message() to its own file
llvm-svn: 136670
2011-08-02 01:18:14 +00:00
Nick Kledzik d5b690d39c add abort_message() utility function
llvm-svn: 136669
2011-08-02 01:16:03 +00:00
Nick Kledzik 476e600cd4 Added kledzik to CREDITS.TXT
llvm-svn: 136667
2011-08-02 01:05:24 +00:00
Marshall Clow b226908bea Updated comments
llvm-svn: 135909
2011-07-25 15:00:11 +00:00
Marshall Clow e41bb4dd69 Added copyright header
llvm-svn: 135601
2011-07-20 18:41:23 +00:00
Howard Hinnant c6b4318b9a Update status: http://libcxxabi.llvm.org/spec.html . Looking good! :-)
llvm-svn: 135590
2011-07-20 16:32:57 +00:00
Marshall Clow e2dcb75b2e Memory manangement routines for exception objects
llvm-svn: 135587
2011-07-20 15:04:39 +00:00
Marshall Clow 1df50ca6a2 Exception handling stuctures, and thread-local variables for exception handling
llvm-svn: 135586
2011-07-20 14:53:53 +00:00
Marshall Clow 60fa2d232a Fixed struct/class mismatch for std::type_info and added NORETURN flags
llvm-svn: 135584
2011-07-20 14:27:46 +00:00
Howard Hinnant 4af8869934 Update by Marshall Clow
llvm-svn: 135397
2011-07-18 16:38:32 +00:00
Howard Hinnant 08ad085712 A stawman specification for libc++abi and status page
llvm-svn: 135181
2011-07-14 20:16:50 +00:00
Howard Hinnant 471e111324 In cxa_demangle.cpp, rewrite __parse_unresolved_name to reflect updated understanding and sync with updated clang mangling. Also fix think-o in __parse_encoding enabling the parsing of trailing .eh and .b.
llvm-svn: 133632
2011-06-22 19:27:39 +00:00
Marshall Clow 92091dbe41 Clean up the vector tests
llvm-svn: 132921
2011-06-13 17:57:10 +00:00
Marshall Clow 280ddee8bd Implement vector new and delete functionality
llvm-svn: 132832
2011-06-10 03:40:19 +00:00
Marshall Clow 8da97113c2 Added Marshall to CREDITS.TXT as requested
llvm-svn: 132754
2011-06-08 16:58:01 +00:00
Howard Hinnant 575498b52f tabs to spaces
llvm-svn: 132729
2011-06-07 19:56:49 +00:00
Nick Lewycky 69e35a7f55 Add support for the ARM EABI variant of the __cxa_guard methods, controlled by
the LIBCXXABI_ARMEABI macro.

llvm-svn: 132723
2011-06-07 18:46:10 +00:00
Nick Lewycky 6fde150697 Add more tests for cxa_guard methods. This includes our first two tests using
actual threads!

There's no build file for libcxxabi, so I'll tell you that I built it with this:
$ g++-4.6 -pthread -std=gnu++0x test_guard.cpp ../src/cxa_guard.o -o test_guard

llvm-svn: 132644
2011-06-04 18:01:24 +00:00
Marshall Clow f8da5b22af Tests for bad_typeid and bad_cast
llvm-svn: 132545
2011-06-03 13:54:37 +00:00
Marshall Clow ad3dea06a9 Added __cxa_bad_cast and __cxa_bad_typeid and placeholder NORETURN macro
llvm-svn: 132524
2011-06-03 02:04:41 +00:00
Howard Hinnant 4a88971ac1 Introduce cxa_virtual.cpp and cxa_guard.cpp. Contributed by Nick Lewycky, Howard Hinnant and John McCall
llvm-svn: 132009
2011-05-24 22:01:16 +00:00
Howard Hinnant f3f1a9c942 Add goal
llvm-svn: 131703
2011-05-19 23:38:38 +00:00
Howard Hinnant 30ab971979 Fix think-o
llvm-svn: 131700
2011-05-19 23:37:21 +00:00
Howard Hinnant d13581e492 testing
llvm-svn: 131694
2011-05-19 22:57:05 +00:00
Howard Hinnant 58bc7ff892 testing
llvm-svn: 131693
2011-05-19 22:56:33 +00:00
Howard Hinnant 7b0290da3f Add Mac OS X as supported platform.
llvm-svn: 131686
2011-05-19 22:03:11 +00:00
Howard Hinnant 4ed80a3372 Add Mac OS X as supported platform.
llvm-svn: 131685
2011-05-19 22:02:38 +00:00
Howard Hinnant d3da57f99b initial import
llvm-svn: 130921
2011-05-05 15:27:28 +00:00