[PATCH] D42728: Add more warnings for implict conversions (e.g. double truncation to float).
John McCall via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 1 10:09:32 PST 2018
rjmccall added inline comments.
================
Comment at: lib/Sema/SemaChecking.cpp:9222
+ const BuiltinType *SourceBT = dyn_cast<BuiltinType>(
+ S.Context.getCanonicalType(E->getRHS()->getType()).getTypePtr());
+ const BuiltinType *TargetBT =
----------------
avt77 wrote:
> rjmccall wrote:
> > `E->getComputationResultType()->getType()->getAs<BuiltinType>()`
> Unfortunatelly, it does not work because getComputationResultType() returns 'double':
>
> CompoundAssignOperator 0xd2db9a0 'float' '+=' ComputeLHSTy='double' ComputeResultTy='double'
> |-UnaryOperator 0xd2db940 'float' lvalue prefix '*' cannot overflow
> | `-ImplicitCastExpr 0xd2db928 'float *' <LValueToRValue>
> | `-DeclRefExpr 0xd2db900 'float *' lvalue ParmVar 0xd2db780 'b' 'float *'
> `-ImplicitCastExpr 0xd2db988 'double' <LValueToRValue>
> `-DeclRefExpr 0xd2db960 'double' lvalue ParmVar 0xd2db6d8 'a' 'double'
>
> (gdb) p CAOp->getComputationLHSType()->dump()
> BuiltinType 0xd25a9b0 'double'
>
> (gdb) p CAOp->getComputationResultType ()->dump()
> BuiltinType 0xd25a9b0 'double'
>
Sorry, I mean instead of E->getRHS()->getType().
https://reviews.llvm.org/D42728
More information about the llvm-commits
mailing list