OCUVectorComponent::ComponentType OCUVectorComponent::getComponentType() const {
// derive the component type, no need to waste space.
const char *compStr = Accessor.getName();
- const OCUVectorType *VT = getType()->isOCUVectorType();
+ const OCUVectorType *VT = getType()->getAsOCUVectorType();
if (VT->isPointAccessor(*compStr)) return Point;
if (VT->isColorAccessor(*compStr)) return Color;
if (VT->isTextureAccessor(*compStr)) return Texture;
}
}
-const FunctionType *Type::isFunctionType() const {
+// FIXME: move inline
+bool Type::isFunctionType() const { return isa<FunctionType>(CanonicalType); }
+bool Type::isPointerType() const { return isa<PointerType>(CanonicalType); }
+bool Type::isReferenceType() const { return isa<ReferenceType>(CanonicalType); }
+bool Type::isArrayType() const { return isa<ArrayType>(CanonicalType); }
+bool Type::isRecordType() const { return isa<RecordType>(CanonicalType); }
+bool Type::isStructureType() const {
+ if (const RecordType *RT = dyn_cast<RecordType>(this))
+ if (RT->getDecl()->getKind() == Decl::Struct)
+ return true;
+ return false;
+}
+bool Type::isUnionType() const {
+ if (const RecordType *RT = dyn_cast<RecordType>(this))
+ if (RT->getDecl()->getKind() == Decl::Union)
+ return true;
+ return false;
+}
+bool Type::isVectorType() const { return isa<VectorType>(CanonicalType); }
+bool Type::isOCUVectorType() const { return isa<OCUVectorType>(CanonicalType); }
+
+
+const FunctionType *Type::getAsFunctionType() const {
// If this is directly a function type, return it.
if (const FunctionType *FTy = dyn_cast<FunctionType>(this))
return FTy;
-
+
// If this is a typedef for a function type, strip the typedef off without
// losing all typedef information.
if (isa<FunctionType>(CanonicalType))
return 0;
}
-// FIXME: move inline
-bool Type::isPointerType() const { return isa<PointerType>(CanonicalType); }
-bool Type::isReferenceType() const { return isa<ReferenceType>(CanonicalType); }
-
const PointerType *Type::getAsPointerType() const {
// If this is directly a pointer type, return it.
if (const PointerType *PTy = dyn_cast<PointerType>(this))
return 0;
}
-const ArrayType *Type::isArrayType() const {
+const ArrayType *Type::getAsArrayType() const {
// If this is directly a reference type, return it.
if (const ArrayType *ATy = dyn_cast<ArrayType>(this))
return ATy;
return 0;
}
-const RecordType *Type::isRecordType() const {
+const RecordType *Type::getAsRecordType() const {
// If this is directly a reference type, return it.
if (const RecordType *RTy = dyn_cast<RecordType>(this))
return RTy;
return 0;
}
-const TagType *Type::isStructureType() const {
+const RecordType *Type::getAsStructureType() const {
// If this is directly a structure type, return it.
- if (const TagType *TT = dyn_cast<TagType>(this)) {
- if (TT->getDecl()->getKind() == Decl::Struct)
- return TT;
+ if (const RecordType *RT = dyn_cast<RecordType>(this)) {
+ if (RT->getDecl()->getKind() == Decl::Struct)
+ return RT;
}
// If this is a typedef for a structure type, strip the typedef off without
// losing all typedef information.
- if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) {
- if (TT->getDecl()->getKind() == Decl::Struct)
- return cast<TagType>(cast<TypedefType>(this)->LookThroughTypedefs());
+ if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType)) {
+ if (RT->getDecl()->getKind() == Decl::Struct)
+ return cast<RecordType>(cast<TypedefType>(this)->LookThroughTypedefs());
}
return 0;
}
-const TagType *Type::isUnionType() const {
+const RecordType *Type::getAsUnionType() const {
// If this is directly a union type, return it.
- if (const TagType *TT = dyn_cast<TagType>(this)) {
- if (TT->getDecl()->getKind() == Decl::Union)
- return TT;
+ if (const RecordType *RT = dyn_cast<RecordType>(this)) {
+ if (RT->getDecl()->getKind() == Decl::Union)
+ return RT;
}
// If this is a typedef for a union type, strip the typedef off without
// losing all typedef information.
- if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) {
- if (TT->getDecl()->getKind() == Decl::Union)
- return cast<TagType>(cast<TypedefType>(this)->LookThroughTypedefs());
+ if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType)) {
+ if (RT->getDecl()->getKind() == Decl::Union)
+ return cast<RecordType>(cast<TypedefType>(this)->LookThroughTypedefs());
}
return 0;
}
return isa<ComplexType>(CanonicalType);
}
-const VectorType *Type::isVectorType() const {
+const VectorType *Type::getAsVectorType() const {
// Are we directly a vector type?
if (const VectorType *VTy = dyn_cast<VectorType>(this))
return VTy;
return 0;
}
-const OCUVectorType *Type::isOCUVectorType() const {
+const OCUVectorType *Type::getAsOCUVectorType() const {
// Are we directly an OpenCU vector type?
if (const OCUVectorType *VTy = dyn_cast<OCUVectorType>(this))
return VTy;
IndexExpr = LHSExp;
// FIXME: need to deal with const...
ResultType = PTy->getPointeeType();
- } else if (const VectorType *VTy = LHSTy->isVectorType()) { // vectors: V[123]
- BaseExpr = LHSExp;
+ } else if (const VectorType *VTy = LHSTy->getAsVectorType()) {
+ BaseExpr = LHSExp; // vectors: V[123]
IndexExpr = RHSExp;
// FIXME: need to deal with const...
ResultType = VTy->getElementType();
QualType Sema::
CheckOCUVectorComponent(QualType baseType, SourceLocation OpLoc,
IdentifierInfo &CompName, SourceLocation CompLoc) {
- const OCUVectorType *vecType = baseType->isOCUVectorType();
+ const OCUVectorType *vecType = baseType->getAsOCUVectorType();
// The vector accessor can't exceed the number of elements.
const char *compStr = CompName.getName();
SourceRange(MemberLoc));
}
// The base type is either a record or an OCUVectorType.
- if (const RecordType *RTy = BaseType->isRecordType()) {
+ if (const RecordType *RTy = BaseType->getAsRecordType()) {
RecordDecl *RDecl = RTy->getDecl();
if (RTy->isIncompleteType())
return Diag(OpLoc, diag::err_typecheck_incomplete_tag, RDecl->getName(),
QualType rhsType = argExpr->getType();
// If necessary, apply function/array conversion. C99 6.7.5.3p[7,8].
- if (const ArrayType *ary = lhsType->isArrayType())
+ if (const ArrayType *ary = lhsType->getAsArrayType())
lhsType = Context.getPointerType(ary->getElementType());
else if (lhsType->isFunctionType())
lhsType = Context.getPointerType(lhsType);
}
if (t->isFunctionType())
promoteExprToType(e, Context.getPointerType(t));
- else if (const ArrayType *ary = t->isArrayType())
+ else if (const ArrayType *ary = t->getAsArrayType())
promoteExprToType(e, Context.getPointerType(ary->getElementType()));
}
bool isFloatingType() const; // C99 6.2.5p11 (real floating + complex)
bool isRealType() const; // C99 6.2.5p17 (real floating + integer)
bool isArithmeticType() const; // C99 6.2.5p18 (integer + floating)
+ bool isVoidType() const; // C99 6.2.5p19
+ bool isDerivedType() const; // C99 6.2.5p20
+ bool isScalarType() const; // C99 6.2.5p21 (arithmetic + pointers)
+ bool isAggregateType() const; // C99 6.2.5p21 (arrays, structures)
- /// Vector types
- const VectorType *isVectorType() const; // GCC vector type.
- const OCUVectorType *isOCUVectorType() const; // OCU vector type.
-
- /// Derived types (C99 6.2.5p20).
- bool isDerivedType() const;
- const FunctionType *isFunctionType() const;
-
+ // Type Predicates: Check to see if this type is structurally the specified
+ // type, ignoring typedefs.
+ bool isFunctionType() const;
bool isPointerType() const;
bool isReferenceType() const;
+ bool isArrayType() const;
+ bool isRecordType() const;
+ bool isStructureType() const;
+ bool isUnionType() const;
+ bool isVectorType() const; // GCC vector type.
+ bool isOCUVectorType() const; // OCU vector type.
+
+ // Type Checking Functions: Check to see if this type is structurally the
+ // specified type, ignoring typedefs, and return a pointer to the best type
+ // we can.
+ const FunctionType *getAsFunctionType() const;
const PointerType *getAsPointerType() const;
const ReferenceType *getAsReferenceType() const;
- const ArrayType *isArrayType() const;
- const RecordType *isRecordType() const;
- const TagType *isStructureType() const;
- const TagType *isUnionType() const;
-
- bool isVoidType() const; // C99 6.2.5p19
- bool isScalarType() const; // C99 6.2.5p21 (arithmetic + pointers)
- bool isAggregateType() const; // C99 6.2.5p21 (arrays, structures)
+ const ArrayType *getAsArrayType() const;
+ const RecordType *getAsRecordType() const;
+ const RecordType *getAsStructureType() const;
+ const RecordType *getAsUnionType() const;
+ const VectorType *getAsVectorType() const; // GCC vector type.
+ const OCUVectorType *getAsOCUVectorType() const; // OCU vector type.
/// More type predicates useful for type checking/promotion
bool isPromotableIntegerType() const; // C99 6.3.1.1p2
RecordType(); // DO NOT IMPLEMENT
public:
- const RecordDecl *getDecl() {
- return reinterpret_cast<RecordDecl*>(TagType::getDecl());
- }
RecordDecl *getDecl() const {
return reinterpret_cast<RecordDecl*>(TagType::getDecl());
}