Added dependent exception support to __cxa_current_exception_type

llvm-svn: 146381
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 7fcad548360a6b9728de6844ddd0ea1807651a16
diff --git a/src/cxa_exception.cpp b/src/cxa_exception.cpp
index 6022740..9cf61a9 100644
--- a/src/cxa_exception.cpp
+++ b/src/cxa_exception.cpp
@@ -305,7 +305,11 @@
     __cxa_exception *current_exception = globals->caughtExceptions;
     if (NULL == current_exception)
         return NULL;        //  No current exception
-//  TODO add stuff for dependent exceptions.
+    if (isDependentException(&current_exception->unwindHeader)) {
+        __cxa_dependent_exception* deh =
+            reinterpret_cast<__cxa_dependent_exception*>(current_exception + 1) - 1;
+        current_exception = static_cast<__cxa_exception*>(deh->primaryException) - 1;
+    }
     return current_exception->exceptionType;
 }