PR13022: cope with parenthesized function types in MS name mangling.

llvm-svn: 157959
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp
index 7bcc2f3..5984881 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -198,7 +198,7 @@
   
   // We should never ever see a FunctionNoProtoType at this point.
   // We don't even know how to mangle their types anyway :).
-  const FunctionProtoType *FT = cast<FunctionProtoType>(FD->getType());
+  const FunctionProtoType *FT = FD->getType()->castAs<FunctionProtoType>();
 
   bool InStructor = false, InInstMethod = false;
   const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD);
diff --git a/clang/test/CodeGenCXX/mangle-ms.cpp b/clang/test/CodeGenCXX/mangle-ms.cpp
index 6556ab7..ff75768 100644
--- a/clang/test/CodeGenCXX/mangle-ms.cpp
+++ b/clang/test/CodeGenCXX/mangle-ms.cpp
@@ -116,3 +116,8 @@
   delete [] array;
 // CHECK: @"\01??_V@YAXPAX@Z"
 }
+
+// PR13022
+void (redundant_parens)();
+void redundant_parens_use() { redundant_parens(); }
+// CHECK: @"\01?redundant_parens@@YAXXZ"