now works with -fno-exceptions and -fno-rtti

llvm-svn: 110828
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 54b409fdb9489b305bf95f4d4f52b49c7926c429
diff --git a/src/ios.cpp b/src/ios.cpp
index eb597bf..4139cd4 100644
--- a/src/ios.cpp
+++ b/src/ios.cpp
@@ -260,8 +260,10 @@
         __rdstate_ = state;
     else
         __rdstate_ = state | badbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
     if (((state | (__rdbuf_ ? goodbit : badbit)) & __exceptions_) != 0)
         throw failure("ios_base::clear");
+#endif
 }
 
 // init
@@ -300,23 +302,31 @@
     if (__event_cap_ < rhs.__event_size_)
     {
         new_callbacks.reset((event_callback*)malloc(sizeof(event_callback) * rhs.__event_size_));
+#ifndef _LIBCPP_NO_EXCEPTIONS
         if (!new_callbacks)
             throw bad_alloc();
+#endif
         new_ints.reset((int*)malloc(sizeof(int) * rhs.__event_size_));
+#ifndef _LIBCPP_NO_EXCEPTIONS
         if (!new_ints)
             throw bad_alloc();
+#endif
     }
     if (__iarray_cap_ < rhs.__iarray_size_)
     {
         new_longs.reset((long*)malloc(sizeof(long) * rhs.__iarray_size_));
+#ifndef _LIBCPP_NO_EXCEPTIONS
         if (!new_longs)
             throw bad_alloc();
+#endif
     }
     if (__parray_cap_ < rhs.__parray_size_)
     {
         new_pointers.reset((void**)malloc(sizeof(void*) * rhs.__parray_size_));
+#ifndef _LIBCPP_NO_EXCEPTIONS
         if (!new_pointers)
             throw bad_alloc();
+#endif
     }
     // Got everything we need.  Copy everything but __rdstate_, __rdbuf_ and __exceptions_
     __fmtflags_ = rhs.__fmtflags_;
@@ -417,16 +427,20 @@
 ios_base::__set_badbit_and_consider_rethrow()
 {
     __rdstate_ |= badbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__exceptions_ & badbit)
         throw;
+#endif
 }
 
 void
 ios_base::__set_failbit_and_consider_rethrow()
 {
     __rdstate_ |= failbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__exceptions_ & failbit)
         throw;
+#endif
 }
 
 bool