[cfe-commits] r41229 - in /cfe/trunk: AST/Type.cpp include/clang/AST/Type.h
Chris Lattner
sabre at nondot.org
Tue Aug 21 09:54:09 PDT 2007
Author: lattner
Date: Tue Aug 21 11:54:08 2007
New Revision: 41229
URL: http://llvm.org/viewvc/llvm-project?rev=41229&view=rev
Log:
add getAsComplexType() for consistency
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=41229&r1=41228&r2=41229&view=diff
==============================================================================
--- cfe/trunk/AST/Type.cpp (original)
+++ cfe/trunk/AST/Type.cpp Tue Aug 21 11:54:08 2007
@@ -71,6 +71,10 @@
return false;
}
+bool Type::isComplexType() const {
+ return isa<ComplexType>(CanonicalType);
+}
+
const FunctionType *Type::getAsFunctionType() const {
// If this is directly a function type, return it.
if (const FunctionType *FTy = dyn_cast<FunctionType>(this))
@@ -161,8 +165,17 @@
return 0;
}
-bool Type::isComplexType() const {
- return isa<ComplexType>(CanonicalType);
+const ComplexType *Type::getAsComplexType() const {
+ // Are we directly a complex type?
+ if (const ComplexType *CTy = dyn_cast<ComplexType>(this))
+ return CTy;
+
+ // If this is a typedef for a complex type, strip the typedef off without
+ // losing all typedef information.
+ if (isa<ComplexType>(CanonicalType))
+ return cast<ComplexType>(cast<TypedefType>(this)->LookThroughTypedefs());
+
+ return 0;
}
const VectorType *Type::getAsVectorType() const {
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=41229&r1=41228&r2=41229&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Tue Aug 21 11:54:08 2007
@@ -37,6 +37,7 @@
class VectorType;
class ArrayType;
class RecordType;
+ class ComplexType;
class TagType;
class FunctionType;
class OCUVectorType;
@@ -269,6 +270,7 @@
const RecordType *getAsStructureType() const;
const RecordType *getAsUnionType() const;
const VectorType *getAsVectorType() const; // GCC vector type.
+ const ComplexType *getAsComplexType() const;
const OCUVectorType *getAsOCUVectorType() const; // OCU vector type.
/// More type predicates useful for type checking/promotion
More information about the cfe-commits
mailing list