From: Daniel Dunbar Date: Thu, 8 Mar 2012 02:52:18 +0000 (+0000) Subject: [AST] Change Type::isIntegerType to be inlined(). It is very popular. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=76e035a529775dc8fd31124f819745a33a085796;p=clang [AST] Change Type::isIntegerType to be inlined(). It is very popular. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152289 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index aafb27e8ab..1a8d353f45 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -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 diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index 1b00594d6b..3176f1909c 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -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(CanonicalType)) + return BT->getKind() >= BuiltinType::Bool && + BT->getKind() <= BuiltinType::Int128; + if (const EnumType *ET = dyn_cast(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(CanonicalType)) diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index ce805617f8..fd8a03fd1a 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -612,17 +612,6 @@ bool Type::isIntegralOrUnscopedEnumerationType() const { -bool Type::isIntegerType() const { - if (const BuiltinType *BT = dyn_cast(CanonicalType)) - return BT->getKind() >= BuiltinType::Bool && - BT->getKind() <= BuiltinType::Int128; - if (const EnumType *ET = dyn_cast(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(CanonicalType)) return BT->getKind() == BuiltinType::Char_U ||