[cfe-commits] r39498 - /cfe/cfe/trunk/AST/Type.cpp

bwendlin at cs.uiuc.edu bwendlin at cs.uiuc.edu
Wed Jul 11 09:45:00 PDT 2007


Author: bwendlin
Date: Wed Jul 11 11:45:00 2007
New Revision: 39498

URL: http://llvm.org/viewvc/llvm-project?rev=39498&view=rev
Log:
Bug #:
Submitted by: Bill Wendling
Reviewed by: Chris Lattner

- Rework the isDerivedType method so that if a language doesn't support
  references, it won't have to pay the price for them. This inlines the
  checks for derived types and turns it into a switch statement instead.

Modified:
    cfe/cfe/trunk/AST/Type.cpp

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

==============================================================================
--- cfe/cfe/trunk/AST/Type.cpp (original)
+++ cfe/cfe/trunk/AST/Type.cpp Wed Jul 11 11:45:00 2007
@@ -39,8 +39,21 @@
 }
 
 bool Type::isDerivedType() const {
-  return isPointerType() || isReferenceType() || isArrayType() ||
-         isFunctionType() || isStructureType() || isUnionType();
+  switch (CanonicalType->getTypeClass()) {
+  default:
+    if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) {
+      const Decl::Kind Kind = TT->getDecl()->getKind();
+      if (Kind == Decl::Struct || Kind == Decl::Union)
+        return true;
+    }
+    return false;
+  case Pointer:
+  case Array:
+  case FunctionProto:
+  case FunctionNoProto:
+  case Reference:
+    return true;
+  }
 }
 
 bool Type::isFunctionType() const {





More information about the cfe-commits mailing list