Skip to content

Commit

Permalink
Merge pull request #458 from MathiasVP/disable-bitwise-workaround
Browse files Browse the repository at this point in the history
C++: Disable the workaround for bitwise operations
  • Loading branch information
jketema authored Nov 29, 2023
2 parents f0ffd4d + f553ba0 commit 7db8a89
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import cpp
import codingstandards.c.misra
import codingstandards.c.misra.EssentialTypes
import codingstandards.cpp.Bitwise

/**
* Holds if the operator `operator` has an operand `child` that is of an inappropriate essential type
Expand Down Expand Up @@ -178,7 +177,7 @@ predicate isInappropriateEssentialType(
child =
[
operator.(BinaryBitwiseOperation).getAnOperand(),
operator.(Bitwise::AssignBitwiseOperation).getAnOperand()
operator.(AssignBitwiseOperation).getAnOperand()
] and
not operator instanceof LShiftExpr and
not operator instanceof RShiftExpr and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@

import cpp
import codingstandards.cpp.autosar
import codingstandards.cpp.Bitwise
import codingstandards.cpp.Conversion

predicate isBinaryBitwiseOperation(Operation o, VariableAccess l, VariableAccess r) {
exists(BinaryBitwiseOperation bbo | bbo = o |
l = bbo.getLeftOperand() and r = bbo.getRightOperand()
)
or
exists(Bitwise::AssignBitwiseOperation abo | abo = o |
exists(AssignBitwiseOperation abo | abo = o |
l = abo.getLValue() and
r = abo.getRValue()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@

import cpp
import codingstandards.cpp.autosar
import codingstandards.cpp.Bitwise

from Operation o, VariableAccess va
where
not isExcluded(o, ExpressionsPackage::bitwiseOperatorAppliedToSignedTypesQuery()) and
(
o instanceof UnaryBitwiseOperation or
o instanceof BinaryBitwiseOperation or
o instanceof Bitwise::AssignBitwiseOperation
o instanceof AssignBitwiseOperation
) and
o.getAnOperand() = va and
va.getTarget().getUnderlyingType().(IntegralType).isSigned()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import cpp
import codingstandards.cpp.autosar
import codingstandards.cpp.Bitwise

class ShiftOperation extends Operation {
Expr leftOperand;
Expand All @@ -34,7 +33,7 @@ class ShiftOperation extends Operation {
rightOperand = o.getRightOperand()
)
or
exists(Bitwise::AssignBitwiseOperation o | this = o |
exists(AssignBitwiseOperation o | this = o |
(
o instanceof AssignLShiftExpr
or
Expand Down
20 changes: 0 additions & 20 deletions cpp/common/src/codingstandards/cpp/Bitwise.qll

This file was deleted.

0 comments on commit 7db8a89

Please sign in to comment.