as a very useful feature, make isVectorType and isPointerType return

the actual vectortype or pointertype when they return success.

llvm-svn: 39890
This commit is contained in:
Chris Lattner 2007-07-16 00:13:25 +00:00
parent 5981db49a2
commit 68ebef886a
2 changed files with 12 additions and 6 deletions

View 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 {

View 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;