Skip to content

Commit 51938af

Browse files
committed
Rule 7.0.1: Address review feedback
1 parent 1cc458b commit 51938af

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

cpp/misra/src/rules/RULE-7-0-1/NoConversionFromBool.ql

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import cpp
1717
import codingstandards.cpp.misra
18+
import codingstandards.cpp.misra.BuiltInTypeRules
1819

1920
from Expr e, Conversion conv
2021
where
@@ -31,13 +32,9 @@ where
3132
eq.getRightOperand().getType().stripTopLevelSpecifiers() instanceof BoolType
3233
)
3334
or
34-
// Exception: explicit constructor calls
35-
exists(ConstructorCall cc | cc.getAnArgument() = e)
36-
or
3735
// Exception: assignment to bit-field of length 1
38-
exists(AssignExpr assign |
39-
assign.getRValue() = e and
40-
assign.getLValue().(ValueFieldAccess).getTarget().(BitField).getNumBits() = 1
41-
)
36+
isAssignedToBitfield(e, _)
37+
// Note: conversions that result in a constructor call are not represented as `Conversion`s
38+
// in our model, so do not need to be excluded here.
4239
)
43-
select e, "Conversion from 'bool' to '" + conv.getType().toString() + "'."
40+
select e, "Conversion from 'bool' to '" + conv.getType() + "'."

0 commit comments

Comments
 (0)