]> granicus.if.org Git - clang/commitdiff
In hasPlaceholderType(Kind) and isSpecificPlaceholderType(Kind), assert
authorJohn McCall <rjmccall@apple.com>
Mon, 17 Oct 2011 23:48:15 +0000 (23:48 +0000)
committerJohn McCall <rjmccall@apple.com>
Mon, 17 Oct 2011 23:48:15 +0000 (23:48 +0000)
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

include/clang/AST/Expr.h
include/clang/AST/Type.h

index 48682dc20562a61f9353b2dbe825d38242bcb28a..9dda1e72dabae347bdd3cbbd1e638e1cc6b1d4f6 100644 (file)
@@ -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;
index 80686a5785562b08f39b0071d027d68c74d40851..f0f78e279a4c0beb1695e42215c4a1cb1da5fe63 100644 (file)
@@ -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;