aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-06 21:58:47 +0000
committerChris Lattner <sabre@nondot.org>2008-04-06 21:58:47 +0000
commit5edb8bfe8472e7d7bf6a82386394ef27359eb846 (patch)
tree1823bf52b6856781ecb13418c66a0cbe84b765d4
parent984d0b414bc76d3530b9bc55a5a55834ba76c607 (diff)
add a helper EnumType object for asking about tagtypes for enums.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49286 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/Type.h63
-rw-r--r--lib/AST/Type.cpp6
2 files changed, 46 insertions, 23 deletions
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index 7ed12abf48..b143e4cbe9 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -1001,6 +1001,46 @@ protected:
friend class Type;
};
+/// RecordType - This is a helper class that allows the use of isa/cast/dyncast
+/// to detect TagType objects of structs/unions/classes.
+class RecordType : public TagType {
+ RecordType(); // DO NOT IMPLEMENT
+public:
+
+ RecordDecl *getDecl() const {
+ return reinterpret_cast<RecordDecl*>(TagType::getDecl());
+ }
+
+ // FIXME: This predicate is a helper to QualType/Type. It needs to
+ // recursively check all fields for const-ness. If any field is declared
+ // const, it needs to return false.
+ bool hasConstFields() const { return false; }
+
+ // FIXME: RecordType needs to check when it is created that all fields are in
+ // the same address space, and return that.
+ unsigned getAddressSpace() const { return 0; }
+
+ static bool classof(const Type *T);
+ static bool classof(const RecordType *) { return true; }
+};
+
+/// EnumType - This is a helper class that allows the use of isa/cast/dyncast
+/// to detect TagType objects of enums.
+class EnumType : public TagType {
+ EnumType(); // DO NOT IMPLEMENT
+public:
+
+ EnumDecl *getDecl() const {
+ return reinterpret_cast<EnumDecl*>(TagType::getDecl());
+ }
+
+ static bool classof(const Type *T);
+ static bool classof(const EnumType *) { return true; }
+};
+
+
+
+
class ObjCInterfaceType : public Type {
ObjCInterfaceDecl *Decl;
protected:
@@ -1094,29 +1134,6 @@ public:
};
-/// RecordType - This is a helper class that allows the use of isa/cast/dyncast
-/// to detect TagType objects of structs/unions/classes.
-class RecordType : public TagType {
- RecordType(); // DO NOT IMPLEMENT
-public:
-
- RecordDecl *getDecl() const {
- return reinterpret_cast<RecordDecl*>(TagType::getDecl());
- }
-
- // FIXME: This predicate is a helper to QualType/Type. It needs to
- // recursively check all fields for const-ness. If any field is declared
- // const, it needs to return false.
- bool hasConstFields() const { return false; }
-
- // FIXME: RecordType needs to check when it is created that all fields are in
- // the same address space, and return that.
- unsigned getAddressSpace() const { return 0; }
-
- static bool classof(const Type *T);
- static bool classof(const RecordType *) { return true; }
-};
-
// Inline function definitions.
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 40b376bbd9..c06b1d9914 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -745,6 +745,12 @@ bool RecordType::classof(const Type *T) {
return false;
}
+bool EnumType::classof(const Type *T) {
+ if (const TagType *TT = dyn_cast<TagType>(T))
+ return isa<EnumDecl>(TT->getDecl());
+ return false;
+}
+
//===----------------------------------------------------------------------===//
// Type Printing