add getAsComplexType() for consistency


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41229 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/Type.cpp b/AST/Type.cpp
index dca9404..65ba90a 100644
--- a/AST/Type.cpp
+++ b/AST/Type.cpp
@@ -71,6 +71,10 @@
   return false;
 }
 
+bool Type::isComplexType() const {
+  return isa<ComplexType>(CanonicalType);
+}
+
 const FunctionType *Type::getAsFunctionType() const {
   // If this is directly a function type, return it.
   if (const FunctionType *FTy = dyn_cast<FunctionType>(this))
@@ -161,8 +165,17 @@
   return 0;
 }
 
-bool Type::isComplexType() const {
-  return isa<ComplexType>(CanonicalType);
+const ComplexType *Type::getAsComplexType() const {
+  // Are we directly a complex type?
+  if (const ComplexType *CTy = dyn_cast<ComplexType>(this))
+    return CTy;
+  
+  // If this is a typedef for a complex type, strip the typedef off without
+  // losing all typedef information.
+  if (isa<ComplexType>(CanonicalType))
+    return cast<ComplexType>(cast<TypedefType>(this)->LookThroughTypedefs());
+  
+  return 0;
 }
 
 const VectorType *Type::getAsVectorType() const {