On Windows, typeids are different between DLLs and EXEs, so comparing

type_info* will work for typeids from the same compiled file but fail
for typeids from a DLL and an executable. Among other things, exceptions
are not caught by handlers since can_catch() returns false.

Defining _LIBCXX_DYNAMIC_FALLBACK does not help since can_catch() calls
is_equal() with use_strcmp=false so the string names are not compared.

This patch compares typeids first (cheap) and only they are different
calls strcmp.

llvm-svn: 195502
This commit is contained in:
Yaron Keren 2013-11-22 21:43:23 +00:00
parent 374c2bb37e
commit 7c6bb6500e

View File

@ -40,6 +40,18 @@
#include <sys/syslog.h>
#endif
// On Windows, typeids are different between DLLs and EXEs, so comparing
// type_info* will work for typeids from the same compiled file but fail
// for typeids from a DLL and an executable. Among other things, exceptions
// are not caught by handlers since can_catch() returns false.
//
// Defining _LIBCXX_DYNAMIC_FALLBACK does not help since can_catch() calls
// is_equal() with use_strcmp=false so the string names are not compared.
#ifdef _WIN32
#include <string.h>
#endif
namespace __cxxabiv1
{
@ -62,7 +74,11 @@ inline
bool
is_equal(const std::type_info* x, const std::type_info* y, bool)
{
#ifndef _WIN32
return x == y;
#else
return (x == y) || (strcmp(x->name(), y->name()) == 0);
#endif
}
#endif // _LIBCXX_DYNAMIC_FALLBACK