From: John McCall Date: Mon, 17 Oct 2011 23:48:15 +0000 (+0000) Subject: In hasPlaceholderType(Kind) and isSpecificPlaceholderType(Kind), assert X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=85def357129b6cdfd69a66ad0e6994506418a2a9;p=clang 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 --- 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(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(this)) return (BT->getKind() == (BuiltinType::Kind) K); return false;