diff options
author | Abramo Bagnara <abramo.bagnara@gmail.com> | 2011-04-07 09:26:19 +0000 |
---|---|---|
committer | Abramo Bagnara <abramo.bagnara@gmail.com> | 2011-04-07 09:26:19 +0000 |
commit | 737d5447b5d20633992ee5388eca5270c28c8ae7 (patch) | |
tree | 0ec8f1d02da32efbeba8edbd42095c665e80647b /lib/Sema/Sema.cpp | |
parent | 1de4d4e8cb2e9c88809fea8092bc6e835a5473d2 (diff) |
In C++ the argument of logical not should always be bool. Added missing implicit cast for scalars.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129066 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/Sema.cpp')
-rw-r--r-- | lib/Sema/Sema.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 0846845e26..0e783018ec 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -235,6 +235,21 @@ void Sema::ImpCastExprToType(Expr *&Expr, QualType Ty, Expr = ImplicitCastExpr::Create(Context, Ty, Kind, Expr, BasePath, VK); } +/// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding +/// to the conversion from scalar type ScalarTy to the Boolean type. +CastKind Sema::ScalarTypeToBooleanCastKind(QualType ScalarTy) { + switch (ScalarTy->getScalarTypeKind()) { + case Type::STK_Bool: return CK_NoOp; + case Type::STK_Pointer: return CK_PointerToBoolean; + case Type::STK_MemberPointer: return CK_MemberPointerToBoolean; + case Type::STK_Integral: return CK_IntegralToBoolean; + case Type::STK_Floating: return CK_FloatingToBoolean; + case Type::STK_IntegralComplex: return CK_IntegralComplexToBoolean; + case Type::STK_FloatingComplex: return CK_FloatingComplexToBoolean; + } + return CK_Invalid; +} + ExprValueKind Sema::CastCategory(Expr *E) { Expr::Classification Classification = E->Classify(Context); return Classification.isRValue() ? VK_RValue : |