From: Chris Lattner Date: Tue, 21 Aug 2007 16:54:08 +0000 (+0000) Subject: add getAsComplexType() for consistency X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c6fb90a7246c2d5d3233e70107bf9d8c7c9e535b;p=clang 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 dca9404dc9..65ba90a75d 100644 --- a/AST/Type.cpp +++ b/AST/Type.cpp @@ -71,6 +71,10 @@ bool Type::isUnionType() const { return false; } +bool Type::isComplexType() const { + return isa(CanonicalType); +} + const FunctionType *Type::getAsFunctionType() const { // If this is directly a function type, return it. if (const FunctionType *FTy = dyn_cast(this)) @@ -161,8 +165,17 @@ const RecordType *Type::getAsUnionType() const { return 0; } -bool Type::isComplexType() const { - return isa(CanonicalType); +const ComplexType *Type::getAsComplexType() const { + // Are we directly a complex type? + if (const ComplexType *CTy = dyn_cast(this)) + return CTy; + + // If this is a typedef for a complex type, strip the typedef off without + // losing all typedef information. + if (isa(CanonicalType)) + return cast(cast(this)->LookThroughTypedefs()); + + return 0; } const VectorType *Type::getAsVectorType() const { diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index 5b22a42494..de5e48ee2c 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -37,6 +37,7 @@ namespace clang { class VectorType; class ArrayType; class RecordType; + class ComplexType; class TagType; class FunctionType; class OCUVectorType; @@ -269,6 +270,7 @@ public: const RecordType *getAsStructureType() const; const RecordType *getAsUnionType() const; const VectorType *getAsVectorType() const; // GCC vector type. + const ComplexType *getAsComplexType() const; const OCUVectorType *getAsOCUVectorType() const; // OCU vector type. /// More type predicates useful for type checking/promotion