[cfe-commits] r49287 - in /cfe/trunk: include/clang/AST/Type.h lib/AST/Type.cpp

Chris Lattner sabre at nondot.org
Sun Apr 6 15:04:54 PDT 2008


Author: lattner
Date: Sun Apr  6 17:04:54 2008
New Revision: 49287

URL: http://llvm.org/viewvc/llvm-project?rev=49287&view=rev
Log:
Make EnumType/RecordType classof predicates simpler and more efficient in
some cases.

Modified:
    cfe/trunk/include/clang/AST/Type.h
    cfe/trunk/lib/AST/Type.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=49287&r1=49286&r2=49287&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Sun Apr  6 17:04:54 2008
@@ -1020,7 +1020,10 @@
   // 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 @@
     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; }
 };
 

Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=49287&r1=49286&r2=49287&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Sun Apr  6 17:04:54 2008
@@ -739,16 +739,12 @@
   }
 }
 
-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());
 }
 
 





More information about the cfe-commits mailing list