[PATCH] D28785: Split exception.cpp and new.cpp implementation into different files for different runtimes

Shoaib Meenai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 17 00:14:31 PST 2017

smeenai added a comment.

I really like the cleanup, but I'm not the biggest fan of taking more Microsoft dependencies than necessary. I don't see any way around `operator new`/`operator delete` (since replacement in COFF can only work with a static library with one function per object file, the way `msvcrt.lib` does it, and it doesn't seem to be worth the trouble to provide our own corresponding static library), but I think the rest are avoidable (though it's entirely possible I'm missing something, of course).

Comment at: include/exception:85
+#include <vcruntime_exception.h>
What's the rationale for relying on Microsoft's exception implementation rather than libc++'s?

Comment at: include/new:96
+#include <new.h>
`new.h` will pull in `new` unless you define certain macros. Is that desirable?

Comment at: include/new:138
+typedef void (*new_handler)();
+_LIBCPP_FUNC_VIS new_handler set_new_handler(new_handler) _NOEXCEPT;
Again, why defer these to Microsoft's STL? In particular, `set_new_handler` and `get_new_handler` seem to be part of `msvcprt`, which means we would take a runtime dependency on Microsoft's C++ library, which doesn't seem great.

These functions should map pretty well to `_query_new_handler` and `_set_new_handler` (apart from the different function pointer signature, which can be thunked around), right?

Comment at: include/new:177
+#if !defined(_LIBCPP_ABI_MICROSOFT)
Might be helpful to have a comment explaining why we wanna defer these to msvcrt on Windows?

Also, VS 2015 doesn't seem to have the sized and aligned allocation and deallocation functions. I haven't checked 2017.


More information about the cfe-commits mailing list