Skip to content

Commit 7d00a59

Browse files
authored
Merge pull request #426 from rvermeulen/rvermeulen/m5-0-20-pointers-alert-update
Include the names of the types that are different in the alert
2 parents 2218b3f + 753cc4f commit 7d00a59

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@ predicate isBinaryBitwiseOperation(Operation o, VariableAccess l, VariableAccess
2929
)
3030
}
3131

32-
from Operation o, Variable left, Variable right
32+
from
33+
Operation o, Variable left, Variable right, Type leftUnderlyingType, Type rightUnderlyingType
3334
where
3435
not isExcluded(o, ExpressionsPackage::bitwiseOperatorOperandsHaveDifferentUnderlyingTypeQuery()) and
3536
not o.isFromUninstantiatedTemplate(_) and
3637
isBinaryBitwiseOperation(o, left.getAnAccess(), right.getAnAccess()) and
37-
left.getUnderlyingType() != right.getUnderlyingType()
38-
select o, "Operands of the '" + o.getOperator() + "' operation have different underlying types."
38+
leftUnderlyingType = left.getUnderlyingType() and
39+
rightUnderlyingType = right.getUnderlyingType() and
40+
leftUnderlyingType != rightUnderlyingType
41+
select o,
42+
"Operands of the '" + o.getOperator() + "' operation have different underlying types '" + leftUnderlyingType.getName() + "' and '" + rightUnderlyingType.getName() + "'."
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
| test.cpp:18:3:18:6 | ... & ... | Operands of the '&' operation have different underlying types. |
2-
| test.cpp:19:3:19:7 | ... \| ... | Operands of the '\|' operation have different underlying types. |
3-
| test.cpp:20:3:20:7 | ... ^ ... | Operands of the '^' operation have different underlying types. |
4-
| test.cpp:21:3:21:8 | ... << ... | Operands of the '<<' operation have different underlying types. |
5-
| test.cpp:22:3:22:8 | ... >> ... | Operands of the '>>' operation have different underlying types. |
6-
| test.cpp:23:3:23:8 | ... &= ... | Operands of the '&=' operation have different underlying types. |
7-
| test.cpp:24:3:24:8 | ... \|= ... | Operands of the '\|=' operation have different underlying types. |
8-
| test.cpp:25:3:25:8 | ... ^= ... | Operands of the '^=' operation have different underlying types. |
9-
| test.cpp:26:3:26:9 | ... <<= ... | Operands of the '<<=' operation have different underlying types. |
10-
| test.cpp:27:3:27:9 | ... >>= ... | Operands of the '>>=' operation have different underlying types. |
11-
| test.cpp:45:3:45:6 | ... & ... | Operands of the '&' operation have different underlying types. |
12-
| test.cpp:46:3:46:7 | ... \| ... | Operands of the '\|' operation have different underlying types. |
13-
| test.cpp:47:3:47:7 | ... ^ ... | Operands of the '^' operation have different underlying types. |
14-
| test.cpp:48:3:48:8 | ... << ... | Operands of the '<<' operation have different underlying types. |
15-
| test.cpp:49:3:49:8 | ... >> ... | Operands of the '>>' operation have different underlying types. |
16-
| test.cpp:50:3:50:8 | ... &= ... | Operands of the '&=' operation have different underlying types. |
17-
| test.cpp:51:3:51:8 | ... \|= ... | Operands of the '\|=' operation have different underlying types. |
18-
| test.cpp:52:3:52:8 | ... ^= ... | Operands of the '^=' operation have different underlying types. |
19-
| test.cpp:53:3:53:9 | ... <<= ... | Operands of the '<<=' operation have different underlying types. |
20-
| test.cpp:54:3:54:9 | ... >>= ... | Operands of the '>>=' operation have different underlying types. |
21-
| test.cpp:67:3:67:14 | ... << ... | Operands of the '<<' operation have different underlying types. |
1+
| test.cpp:18:3:18:6 | ... & ... | Operands of the '&' operation have different underlying types 'unsigned int' and 'unsigned short'. |
2+
| test.cpp:19:3:19:7 | ... \| ... | Operands of the '\|' operation have different underlying types 'unsigned int' and 'unsigned short'. |
3+
| test.cpp:20:3:20:7 | ... ^ ... | Operands of the '^' operation have different underlying types 'unsigned int' and 'unsigned short'. |
4+
| test.cpp:21:3:21:8 | ... << ... | Operands of the '<<' operation have different underlying types 'unsigned int' and 'unsigned short'. |
5+
| test.cpp:22:3:22:8 | ... >> ... | Operands of the '>>' operation have different underlying types 'unsigned int' and 'unsigned short'. |
6+
| test.cpp:23:3:23:8 | ... &= ... | Operands of the '&=' operation have different underlying types 'unsigned int' and 'unsigned short'. |
7+
| test.cpp:24:3:24:8 | ... \|= ... | Operands of the '\|=' operation have different underlying types 'unsigned int' and 'unsigned short'. |
8+
| test.cpp:25:3:25:8 | ... ^= ... | Operands of the '^=' operation have different underlying types 'unsigned int' and 'unsigned short'. |
9+
| test.cpp:26:3:26:9 | ... <<= ... | Operands of the '<<=' operation have different underlying types 'unsigned int' and 'unsigned short'. |
10+
| test.cpp:27:3:27:9 | ... >>= ... | Operands of the '>>=' operation have different underlying types 'unsigned int' and 'unsigned short'. |
11+
| test.cpp:45:3:45:6 | ... & ... | Operands of the '&' operation have different underlying types 'unsigned char' and 'unsigned short'. |
12+
| test.cpp:46:3:46:7 | ... \| ... | Operands of the '\|' operation have different underlying types 'unsigned char' and 'unsigned short'. |
13+
| test.cpp:47:3:47:7 | ... ^ ... | Operands of the '^' operation have different underlying types 'unsigned char' and 'unsigned short'. |
14+
| test.cpp:48:3:48:8 | ... << ... | Operands of the '<<' operation have different underlying types 'unsigned char' and 'unsigned short'. |
15+
| test.cpp:49:3:49:8 | ... >> ... | Operands of the '>>' operation have different underlying types 'unsigned char' and 'unsigned short'. |
16+
| test.cpp:50:3:50:8 | ... &= ... | Operands of the '&=' operation have different underlying types 'unsigned char' and 'unsigned short'. |
17+
| test.cpp:51:3:51:8 | ... \|= ... | Operands of the '\|=' operation have different underlying types 'unsigned char' and 'unsigned short'. |
18+
| test.cpp:52:3:52:8 | ... ^= ... | Operands of the '^=' operation have different underlying types 'unsigned char' and 'unsigned short'. |
19+
| test.cpp:53:3:53:9 | ... <<= ... | Operands of the '<<=' operation have different underlying types 'unsigned char' and 'unsigned short'. |
20+
| test.cpp:54:3:54:9 | ... >>= ... | Operands of the '>>=' operation have different underlying types 'unsigned char' and 'unsigned short'. |
21+
| test.cpp:67:3:67:14 | ... << ... | Operands of the '<<' operation have different underlying types 'int &' and 'char &'. |

0 commit comments

Comments
 (0)