From: Chris Lattner Date: Mon, 16 Jul 2007 00:13:25 +0000 (+0000) Subject: as a very useful feature, make isVectorType and isPointerType return X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3acb13805673d47be95829bd5a4b1707952c0b6f;p=clang as a very useful feature, make isVectorType and isPointerType return the actual vectortype or pointertype when they return success. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39890 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/AST/Type.cpp b/AST/Type.cpp index 5bcc19c2a3..74e47936a9 100644 --- a/AST/Type.cpp +++ b/AST/Type.cpp @@ -60,8 +60,10 @@ bool Type::isFunctionType() const { return isa(CanonicalType); } -bool Type::isPointerType() const { - return isa(CanonicalType); +PointerType *Type::isPointerType() const { + if (PointerType *PTy = dyn_cast(CanonicalType)) + return PTy; + return 0; } bool Type::isReferenceType() const { @@ -291,8 +293,10 @@ bool Type::isComplexType() const { return isa(CanonicalType); } -bool Type::isVectorType() const { - return isa(CanonicalType); +VectorType *Type::isVectorType() const { + if (VectorType *VTy = dyn_cast(CanonicalType)) + return VTy; + return 0; } bool Type::isArithmeticType() const { diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index c84f8ebf46..b2ca8eb5d7 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -32,6 +32,8 @@ namespace clang { class EnumDecl; class Expr; class SourceLocation; + class PointerType; + class VectorType; /// QualType - For efficiency, we don't store CVR-qualified types as nodes on /// their own: instead each reference to a type stores the qualifiers. This @@ -228,11 +230,11 @@ public: bool isArithmeticType() const; // C99 6.2.5p18 (integer + floating) /// Vector types - bool isVectorType() const; // GCC vector type. + VectorType *isVectorType() const; // GCC vector type. /// Derived types (C99 6.2.5p20). isFunctionType() is also a derived type. bool isDerivedType() const; - bool isPointerType() const; + PointerType *isPointerType() const; bool isReferenceType() const; bool isArrayType() const; bool isStructureType() const;