]> granicus.if.org Git - clang/commitdiff
Type traits: No need for switch to handle __builtin_types_compatible_p
authorAlp Toker <alp@nuanti.com>
Sat, 7 Dec 2013 07:20:22 +0000 (07:20 +0000)
committerAlp Toker <alp@nuanti.com>
Sat, 7 Dec 2013 07:20:22 +0000 (07:20 +0000)
__builtin_types_compatible_p() isn't a C++ type trait at all, rather a GNU C
special-case, so it's fine to use BoolTy the default return type for binary
type traits.

This brings BTT in line with other arities that already default to BoolTy.

Cleanup only, no change in behaviour.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196646 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprCXX.cpp

index 46844d7662d08a921298e9bec39c72717711b77b..48b49f550cf3c03492930954e7861705000b239c 100644 (file)
@@ -3938,16 +3938,10 @@ ExprResult Sema::BuildBinaryTypeTrait(BinaryTypeTrait BTT,
   if (!LhsT->isDependentType() && !RhsT->isDependentType())
     Value = EvaluateBinaryTypeTrait(*this, BTT, LhsT, RhsT, KWLoc);
 
-  // Select trait result type.
-  QualType ResultType;
-  switch (BTT) {
-  case BTT_IsBaseOf:       ResultType = Context.BoolTy; break;
-  case BTT_IsConvertible:  ResultType = Context.BoolTy; break;
-  case BTT_IsSame:         ResultType = Context.BoolTy; break;
-  case BTT_TypeCompatible: ResultType = Context.IntTy; break;
-  case BTT_IsConvertibleTo: ResultType = Context.BoolTy; break;
-  case BTT_IsTriviallyAssignable: ResultType = Context.BoolTy;
-  }
+  QualType ResultType = Context.BoolTy;
+  // __builtin_types_compatible_p is a GNU C extension, not a C++ type trait.
+  if (BTT == BTT_TypeCompatible)
+    ResultType = Context.IntTy;
 
   return Owned(new (Context) BinaryTypeTraitExpr(KWLoc, BTT, LhsTSInfo,
                                                  RhsTSInfo, Value, RParen,