Only use cxxabi.h's demangler, if it is actually available.
[oota-llvm.git] / lib / Support / Unix / Signals.inc
index 66338f17d88fac41dc189fd46f4a91d02a75eee7..1f8c8158d7f30586e47071a46cab22d0d5636f85 100644 (file)
 #if HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
-#if HAVE_DLFCN_H && __GNUG__
+#if HAVE_CXXABI_H
+#include cxxabi.h>
+#endif
+#if HAVE_DLFCN_H
 #include <dlfcn.h>
-#include <cxxabi.h>
 #endif
 #if HAVE_MACH_MACH_H
 #include <mach/mach.h>
@@ -292,7 +294,11 @@ void llvm::sys::PrintStackTrace(FILE *FD) {
     if (dlinfo.dli_sname != NULL) {
       int res;
       fputc(' ', FD);
+#  if HAVE_CXXABI_H
       char* d = abi::__cxa_demangle(dlinfo.dli_sname, NULL, NULL, &res);
+#  else
+      char* d = NULL;
+#  endif
       if (d == NULL) fputs(dlinfo.dli_sname, FD);
       else           fputs(d, FD);
       free(d);