aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-06 22:04:54 +0000
committerChris Lattner <sabre@nondot.org>2008-04-06 22:04:54 +0000
commit2daa5df1b53f7ef745d724771384409f6f5df5c1 (patch)
treee8511f76731e7179d1aa6f74d092ee8bf73448b6
parent5edb8bfe8472e7d7bf6a82386394ef27359eb846 (diff)
Make EnumType/RecordType classof predicates simpler and more efficient in
some cases. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49287 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/Type.h10
-rw-r--r--lib/AST/Type.cpp12
2 files changed, 12 insertions, 10 deletions
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index b143e4cbe9..4b1f2c6b41 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -1020,7 +1020,10 @@ public:
// the same address space, and return that.
unsigned getAddressSpace() const { return 0; }
- static bool classof(const Type *T);
+ static bool classof(const TagType *T);
+ static bool classof(const Type *T) {
+ return isa<TagType>(T) && classof(cast<TagType>(T));
+ }
static bool classof(const RecordType *) { return true; }
};
@@ -1034,7 +1037,10 @@ public:
return reinterpret_cast<EnumDecl*>(TagType::getDecl());
}
- static bool classof(const Type *T);
+ static bool classof(const TagType *T);
+ static bool classof(const Type *T) {
+ return isa<TagType>(T) && classof(cast<TagType>(T));
+ }
static bool classof(const EnumType *) { return true; }
};
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index c06b1d9914..c8fb386804 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -739,16 +739,12 @@ QualType TypedefType::LookThroughTypedefs() const {
}
}
-bool RecordType::classof(const Type *T) {
- if (const TagType *TT = dyn_cast<TagType>(T))
- return isa<RecordDecl>(TT->getDecl());
- return false;
+bool RecordType::classof(const TagType *TT) {
+ return isa<RecordDecl>(TT->getDecl());
}
-bool EnumType::classof(const Type *T) {
- if (const TagType *TT = dyn_cast<TagType>(T))
- return isa<EnumDecl>(TT->getDecl());
- return false;
+bool EnumType::classof(const TagType *TT) {
+ return isa<EnumDecl>(TT->getDecl());
}