]> granicus.if.org Git - clang/commitdiff
as a very useful feature, make isVectorType and isPointerType return
authorChris Lattner <sabre@nondot.org>
Mon, 16 Jul 2007 00:13:25 +0000 (00:13 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 16 Jul 2007 00:13:25 +0000 (00:13 +0000)
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

AST/Type.cpp
include/clang/AST/Type.h

index 5bcc19c2a33118302125ce36787c994a2e38c004..74e47936a90b97ec98019c8d6f14a32919539c4e 100644 (file)
@@ -60,8 +60,10 @@ bool Type::isFunctionType() const {
   return isa<FunctionType>(CanonicalType);
 }
 
-bool Type::isPointerType() const {
-  return isa<PointerType>(CanonicalType);
+PointerType *Type::isPointerType() const {
+  if (PointerType *PTy = dyn_cast<PointerType>(CanonicalType))
+    return PTy;
+  return 0;
 }
 
 bool Type::isReferenceType() const {
@@ -291,8 +293,10 @@ bool Type::isComplexType() const {
   return isa<ComplexType>(CanonicalType);
 }
 
-bool Type::isVectorType() const {
-  return isa<VectorType>(CanonicalType);
+VectorType *Type::isVectorType() const {
+  if (VectorType *VTy = dyn_cast<VectorType>(CanonicalType))
+    return VTy;
+  return 0;
 }
 
 bool Type::isArithmeticType() const {
index c84f8ebf46a3f1babc50301b1472e90cf64099ba..b2ca8eb5d78ee60fa2aafd10fbf49073c3f2fb85 100644 (file)
@@ -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;