C++: Fix case where implicit downcasts were not detected when using reference

This commit is contained in:
Anders Fugmann
2021-08-23 14:44:49 +02:00
parent 8939a9b2c1
commit 9324d8f348
3 changed files with 12 additions and 5 deletions

View File

@@ -13,10 +13,16 @@
import cpp
from BitField fi, VariableAccess va
from BitField fi, VariableAccess va, Type fct
where
fi.getNumBits() > va.getFullyConverted().getType().getSize() * 8 and
va.getExplicitlyConverted().getType().getSize() > va.getFullyConverted().getType().getSize() and
(
if va.getFullyConverted().getType() instanceof ReferenceType
then fct = va.getFullyConverted().getType().(ReferenceType).getBaseType()
else fct = va.getFullyConverted().getType()
) and
fi.getNumBits() > fct.getSize() * 8 and
va.getExplicitlyConverted().getType().getSize() > fct.getSize() and
va.getTarget() = fi and
not va.getActualType() instanceof BoolType
not fct.getUnspecifiedType() instanceof BoolType and
any()
select va, "Implicit downcast of bitfield $@", fi, fi.toString()