Skip to content

Commit fc5a174

Browse files
committed
Encapsulate Bitwise class in module.
1 parent 6c5a62f commit fc5a174

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

c/misra/src/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ predicate isInappropriateEssentialType(
178178
child =
179179
[
180180
operator.(BinaryBitwiseOperation).getAnOperand(),
181-
operator.(AssignBitwiseOperationFixed).getAnOperand()
181+
operator.(Bitwise::AssignBitwiseOperation).getAnOperand()
182182
] and
183183
not operator instanceof LShiftExpr and
184184
not operator instanceof RShiftExpr and

cpp/autosar/src/rules/M5-0-20/BitwiseOperatorOperandsHaveDifferentUnderlyingType.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ predicate isBinaryBitwiseOperation(Operation o, VariableAccess l, VariableAccess
2323
l = bbo.getLeftOperand() and r = bbo.getRightOperand()
2424
)
2525
or
26-
exists(AssignBitwiseOperationFixed abo | abo = o |
26+
exists(Bitwise::AssignBitwiseOperation abo | abo = o |
2727
l = abo.getLValue() and
2828
r = abo.getRValue()
2929
)

cpp/autosar/src/rules/M5-0-21/BitwiseOperatorAppliedToSignedTypes.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ where
2525
(
2626
o instanceof UnaryBitwiseOperation or
2727
o instanceof BinaryBitwiseOperation or
28-
o instanceof AssignBitwiseOperationFixed
28+
o instanceof Bitwise::AssignBitwiseOperation
2929
) and
3030
o.getAnOperand() = va and
3131
va.getTarget().getUnderlyingType().(IntegralType).isSigned()

cpp/common/src/codingstandards/cpp/Bitwise.qll

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
* A library for addressing issues in bitwise operator modelling in our database schema.
33
*/
44

5-
import cpp
5+
private import cpp as cpp
66

7-
/**
8-
* A binary bitwise assign operation, excluding += and -= on pointers, which seem to be erroneously
9-
* included.
10-
*/
11-
class AssignBitwiseOperationFixed extends AssignBitwiseOperation {
12-
AssignBitwiseOperationFixed() {
13-
// exclude += and -= on pointers, which seem to be erroneously included
14-
// in the database schema
15-
not this instanceof AssignPointerAddExpr and
16-
not this instanceof AssignPointerSubExpr
7+
module Bitwise {
8+
/**
9+
* A binary bitwise assign operation, excluding += and -= on pointers, which seem to be erroneously
10+
* included.
11+
*/
12+
class AssignBitwiseOperation extends cpp::AssignBitwiseOperation {
13+
AssignBitwiseOperation() {
14+
// exclude += and -= on pointers, which seem to be erroneously included
15+
// in the database schema
16+
not this instanceof cpp::AssignPointerAddExpr and
17+
not this instanceof cpp::AssignPointerSubExpr
18+
}
1719
}
1820
}

0 commit comments

Comments
 (0)