summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2012-03-08 02:52:18 +0000
committerDaniel Dunbar <daniel@zuster.org>2012-03-08 02:52:18 +0000
commitd043733ad9dac1da34900bf2418c2ba274f8cd95 (patch)
treed655fa7a192f83167621f573e398eccea2685327 /clang
parentfaa48ebbba35654ef8f8d424e245ea63c18aea15 (diff)
downloadbcm5719-llvm-d043733ad9dac1da34900bf2418c2ba274f8cd95.tar.gz
bcm5719-llvm-d043733ad9dac1da34900bf2418c2ba274f8cd95.zip
[AST] Change Type::isIntegerType to be inlined(). It is very popular.
llvm-svn: 152289
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/AST/Decl.h8
-rw-r--r--clang/include/clang/AST/Type.h14
-rw-r--r--clang/lib/AST/Type.cpp11
3 files changed, 22 insertions, 11 deletions
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index aafb27e8ab4..1a8d353f451 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/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/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 1b00594d6bd..3176f1909c4 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/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<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))
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index ce805617f89..fd8a03fd1a1 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -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 ||
OpenPOWER on IntegriCloud