]> granicus.if.org Git - clang/commitdiff
[AST] Change Type::isIntegerType to be inlined(). It is very popular.
authorDaniel Dunbar <daniel@zuster.org>
Thu, 8 Mar 2012 02:52:18 +0000 (02:52 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 8 Mar 2012 02:52:18 +0000 (02:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152289 91177308-0d34-0410-b5e6-96231b3b80d8

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

index aafb27e8ab449329677162922b0f6db7894b24e7..1a8d353f4511f2a650d59df8259f085a77431d38 100644 (file)
@@ -3283,6 +3283,14 @@ inline bool IsEnumDeclComplete(EnumDecl *ED) {
   return ED->isComplete();
 }
 
+/// \brief Check if the given decl is scoped.
+///
+/// We use this function to break a cycle between the inline definitions in
+/// Type.h and Decl.h.
+inline bool IsEnumDeclScoped(EnumDecl *ED) {
+  return ED->isScoped();
+}
+
 }  // end namespace clang
 
 #endif
index 1b00594d6bdb64b5307d16d84de241d742d7df7a..3176f1909c4f6f8e3a57360ea971686d2d848e25 100644 (file)
@@ -4830,6 +4830,20 @@ inline bool Type::isNullPtrType() const {
 }
 
 extern bool IsEnumDeclComplete(EnumDecl *);
+extern bool IsEnumDeclScoped(EnumDecl *);
+
+inline bool Type::isIntegerType() const {
+  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
+    return BT->getKind() >= BuiltinType::Bool &&
+           BT->getKind() <= BuiltinType::Int128;
+  if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
+    // Incomplete enum types are not treated as integer types.
+    // FIXME: In C++, enum types are never integer types.
+    return IsEnumDeclComplete(ET->getDecl()) &&
+      !IsEnumDeclScoped(ET->getDecl());
+  }
+  return false;
+}
 
 inline bool Type::isScalarType() const {
   if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
index ce805617f89dcb310898dc53b569175b6cb4e09e..fd8a03fd1a1d947ef6fadbb5fc35173ed693af7a 100644 (file)
@@ -612,17 +612,6 @@ bool Type::isIntegralOrUnscopedEnumerationType() const {
 
 
 
-bool Type::isIntegerType() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
-    return BT->getKind() >= BuiltinType::Bool &&
-           BT->getKind() <= BuiltinType::Int128;
-  if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
-    // Incomplete enum types are not treated as integer types.
-    // FIXME: In C++, enum types are never integer types.
-    return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
-  return false;
-}
-
 bool Type::isCharType() const {
   if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->getKind() == BuiltinType::Char_U ||