Sema: Don't crash when __try/__except/__finally appears in a template function

We wouldn't transform the compound statement in any of these forms,
causing crashes when it got time to act on them.  Additionally, we
wouldn't check to see if the handler was invalid before deciding whether
or not we should continue acting on the __try.

This fixes PR17584.

llvm-svn: 192682
diff --git a/clang/test/SemaCXX/__try.cpp b/clang/test/SemaCXX/__try.cpp
index a0f503a..1c45581 100644
--- a/clang/test/SemaCXX/__try.cpp
+++ b/clang/test/SemaCXX/__try.cpp
@@ -57,3 +57,23 @@
   }
   return e;
 }
+
+namespace PR17584 {
+template <typename>
+void Except() {
+  __try {
+  } __except(true) {
+  }
+}
+
+template <typename>
+void Finally() {
+  __try {
+  } __finally {
+  }
+}
+
+template void Except<void>();
+template void Finally<void>();
+
+}