Adjust casting rules on implied varnodes

This commit is contained in:
caheckman 2021-09-23 16:10:29 -04:00
parent 1508f3fee8
commit 75cf11634c
3 changed files with 44 additions and 7 deletions

View file

@ -352,9 +352,13 @@ bool CastStrategyC::isSubpieceCastEndian(Datatype *outtype,Datatype *intype,uint
bool CastStrategyC::isSextCast(Datatype *outtype,Datatype *intype) const
{
if (outtype->getMetatype()!=TYPE_INT) return false;
type_metatype metaout = outtype->getMetatype();
if (metaout != TYPE_UINT && metaout != TYPE_INT)
return false;
type_metatype metain = intype->getMetatype();
if ((metain!=TYPE_INT)&&(metain!=TYPE_UINT)&&(metain!=TYPE_BOOL))
// Casting to larger storage always extends based on signedness of the input data-type
// So the input must be SIGNED in order to treat SEXT as a cast
if ((metain!=TYPE_INT)&&(metain!=TYPE_BOOL))
return false;
return true;
}
@ -362,9 +366,13 @@ bool CastStrategyC::isSextCast(Datatype *outtype,Datatype *intype) const
bool CastStrategyC::isZextCast(Datatype *outtype,Datatype *intype) const
{
if (outtype->getMetatype()!=TYPE_UINT) return false;
type_metatype metaout = outtype->getMetatype();
if (metaout != TYPE_UINT && metaout != TYPE_INT)
return false;
type_metatype metain = intype->getMetatype();
if ((metain!=TYPE_INT)&&(metain!=TYPE_UINT)&&(metain!=TYPE_BOOL))
// Casting to larger storage always extends based on signedness of the input data-type
// So the input must be UNSIGNED in order to treat ZEXT as a cast
if ((metain!=TYPE_UINT)&&(metain!=TYPE_BOOL))
return false;
return true;
}