[cfe-commits] [patch] Let clang parse typeid() on windows if _HAS_EXCEPTIONS is defined to 0

Nico Weber thakis at chromium.org
Tue Apr 24 19:38:40 PDT 2012


Hi,

if _HAS_EXCEPTIONS is set to 0, typeid() can't be used in clang on
windows. One use case where this happens is ICU in chromium:
http://git.chromium.org/gitweb/?p=chromium/deps/icu46.git;a=commitdiff_plain;h=8ad988882c0a6bb2ac66eecab662141110840e66

This is a reduced reproduction that builds fine with MSVC:

#define _HAS_EXCEPTIONS 0
#include <exception>
#include <typeinfo> // for typeid to work.

void f() {
  (void)typeid(int);  // just typeid
}

clang on the other hand complains about typeid requiring an include
for <typeinfo>. That's because clang tries to look up std::type_info,
and the MS typeinfo header apparently doesn't define type_info in the
std namespace, but only if _HAS_EXCEPTIONS is defined to 0. The
attached patch lets clang look up type_info in the global namespace in
ms compat mode if the lookup for std::type-info fails.

Ok?

Nico
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang-ms-typeinfo.patch
Type: application/octet-stream
Size: 1031 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120424/88d75ca2/attachment.obj>


More information about the cfe-commits mailing list