aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-10-17 23:48:15 +0000
committerJohn McCall <rjmccall@apple.com>2011-10-17 23:48:15 +0000
commit85def357129b6cdfd69a66ad0e6994506418a2a9 (patch)
treed68395a66914b507734b48223857c4ab5a8c6b5f
parentb56e6ad87feb654e4ca265311344f4467a55a810 (diff)
In hasPlaceholderType(Kind) and isSpecificPlaceholderType(Kind), assert
that the parameter is actually a placeholder type kind. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142312 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/Expr.h1
-rw-r--r--include/clang/AST/Type.h8
2 files changed, 8 insertions, 1 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index 48682dc205..9dda1e72da 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -398,6 +398,7 @@ public:
/// \brief Returns whether this expression has a specific placeholder type.
bool hasPlaceholderType(BuiltinType::Kind K) const {
+ assert(BuiltinType::isPlaceholderTypeKind(K));
if (const BuiltinType *BT = dyn_cast<BuiltinType>(getType()))
return BT->getKind() == K;
return false;
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index 80686a5785..f0f78e279a 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -1790,11 +1790,16 @@ public:
return getKind() >= Half && getKind() <= LongDouble;
}
+ /// Determines whether the given kind corresponds to a placeholder type.
+ static bool isPlaceholderTypeKind(Kind K) {
+ return K >= Overload;
+ }
+
/// Determines whether this type is a placeholder type, i.e. a type
/// which cannot appear in arbitrary positions in a fully-formed
/// expression.
bool isPlaceholderType() const {
- return getKind() >= Overload;
+ return isPlaceholderTypeKind(getKind());
}
static bool classof(const Type *T) { return T->getTypeClass() == Builtin; }
@@ -4775,6 +4780,7 @@ inline const BuiltinType *Type::getAsPlaceholderType() const {
}
inline bool Type::isSpecificPlaceholderType(unsigned K) const {
+ assert(BuiltinType::isPlaceholderTypeKind((BuiltinType::Kind) K));
if (const BuiltinType *BT = dyn_cast<BuiltinType>(this))
return (BT->getKind() == (BuiltinType::Kind) K);
return false;