[cfe-commits] r39890 - in /cfe/trunk: AST/Type.cpp include/clang/AST/Type.h

Chris Lattner sabre at nondot.org
Sun Jul 15 17:13:25 PDT 2007


Author: lattner
Date: Sun Jul 15 19:13:25 2007
New Revision: 39890

URL: http://llvm.org/viewvc/llvm-project?rev=39890&view=rev
Log:
as a very useful feature, make isVectorType and isPointerType return
the actual vectortype or pointertype when they return success.

Modified:
    cfe/trunk/AST/Type.cpp
    cfe/trunk/include/clang/AST/Type.h

Modified: cfe/trunk/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Type.cpp?rev=39890&r1=39889&r2=39890&view=diff

==============================================================================
--- cfe/trunk/AST/Type.cpp (original)
+++ cfe/trunk/AST/Type.cpp Sun Jul 15 19:13:25 2007
@@ -60,8 +60,10 @@
   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 @@
   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 {

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=39890&r1=39889&r2=39890&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Sun Jul 15 19:13:25 2007
@@ -32,6 +32,8 @@
   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 @@
   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;   





More information about the cfe-commits mailing list