From: Alp Toker Date: Sat, 7 Dec 2013 07:20:22 +0000 (+0000) Subject: Type traits: No need for switch to handle __builtin_types_compatible_p X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6e1b192c69294b25d063af27677398dcaaf689da;p=clang Type traits: No need for switch to handle __builtin_types_compatible_p __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 --- diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 46844d7662..48b49f550c 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -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,