]> granicus.if.org Git - clang/commitdiff
Make EnumType/RecordType classof predicates simpler and more efficient in
authorChris Lattner <sabre@nondot.org>
Sun, 6 Apr 2008 22:04:54 +0000 (22:04 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 6 Apr 2008 22:04:54 +0000 (22:04 +0000)
some cases.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49287 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Type.h
lib/AST/Type.cpp

index b143e4cbe9367f5f55e1500d5b2a1405edfca770..4b1f2c6b41113df5e4629810af197f56290ef2a0 100644 (file)
@@ -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; }
 };
 
index c06b1d9914759d0cd8bd3375b132b304fafee3f1..c8fb38680460ac2028f46567f3520db8d8206f35 100644 (file)
@@ -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());
 }