Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit01a73a0

Browse files
authored
Merge pull request#631 from github/mbaluda/importMisra23Complete
Implement MISRA23 Import rules [complete]
2 parents4690ecb +9bdc84d commit01a73a0

File tree

719 files changed

+8382
-1421
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

719 files changed

+8382
-1421
lines changed

‎c/cert/src/rules/INT30-C/UnsignedIntegerOperationsWrapAround.ql‎

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,11 @@
1515

1616
import cpp
1717
import codingstandards.c.cert
18-
import codingstandards.cpp.Overflow
19-
import semmle.code.cpp.controlflow.Guards
20-
import semmle.code.cpp.valuenumbering.GlobalValueNumbering
18+
import codingstandards.cpp.rules.unsignedoperationwithconstantoperandswraps.UnsignedOperationWithConstantOperandsWraps
2119

22-
fromInterestingOverflowingOperationop
23-
where
24-
notisExcluded(op, IntegerOverflowPackage::unsignedIntegerOperationsWrapAroundQuery())and
25-
op.getType().getUnderlyingType().(IntegralType).isUnsigned()and
26-
// Not within a guard condition
27-
notexists(GuardConditiongc|gc.getAChild*()=op)and
28-
// Not guarded by a check, where the check is not an invalid overflow check
29-
notop.hasValidPreCheck()and
30-
// Is not checked after the operation
31-
notop.hasValidPostCheck()and
32-
// Permitted by exception 3
33-
notopinstanceofLShiftExprand
34-
// Permitted by exception 2 - zero case is handled in separate query
35-
notopinstanceofDivExprand
36-
notopinstanceofRemExpr
37-
selectop,
38-
"Operation "+op.getOperator()+" of type "+op.getType().getUnderlyingType()+" may wrap."
20+
classUnsignedIntegerOperationsWrapAroundQueryextendsUnsignedOperationWithConstantOperandsWrapsSharedQuery
21+
{
22+
UnsignedIntegerOperationsWrapAroundQuery(){
23+
this= IntegerOverflowPackage::unsignedIntegerOperationsWrapAroundQuery()
24+
}
25+
}

‎c/cert/test/rules/INT30-C/UnsignedIntegerOperationsWrapAround.expected‎

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎c/cert/test/rules/INT30-C/UnsignedIntegerOperationsWrapAround.qlref‎

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
c/common/test/rules/unsignedoperationwithconstantoperandswraps/UnsignedOperationWithConstantOperandsWraps.ql
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cpp/common/test/rules/donotuserandforgeneratingpseudorandomnumbers/DoNotUseRandForGeneratingPseudorandomNumbers.ql
1+
c/common/test/rules/donotuserandforgeneratingpseudorandomnumbers/DoNotUseRandForGeneratingPseudorandomNumbers.ql

‎c/common/src/codingstandards/c/Literals.qll‎

Lines changed: 0 additions & 4 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
| test.c:4:1:4:41 | #define BAD_MACRO_WITH_ARG(x) (x) + wow ## x | Macro BAD_MACRO_WITH_ARG contains use of parameter x used in multiple contexts. |
2-
| test.c:5:1:5:48 | #define BAD_MACRO_WITH_ARG_TWO(x,y) (x) + wow ## x | Macro BAD_MACRO_WITH_ARG_TWO contains use of parameter x used in multiple contexts. |
1+
| test.c:5:1:5:41 | #define BAD_MACRO_WITH_ARG(x) (x) + wow ## x | Macro BAD_MACRO_WITH_ARG contains use of parameter x used in multiple contexts. |
2+
| test.c:6:1:6:48 | #define BAD_MACRO_WITH_ARG_TWO(x,y) (x) + wow ## x | Macro BAD_MACRO_WITH_ARG_TWO contains use of parameter x used in multiple contexts. |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// GENERATED FILE - DO NOT MODIFY
2+
import codingstandards.cpp.rules.amixedusemacroargumentsubjecttoexpansion.AMixedUseMacroArgumentSubjectToExpansion
3+
4+
classTestFileQueryextendsAMixedUseMacroArgumentSubjectToExpansionSharedQuery,TestQuery{}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// NOTICE: THE TEST CASES BELOW ARE ALSO INCLUDED IN THE C++ TEST CASE AND
2+
// CHANGES SHOULD BE REFLECTED THERE AS WELL.
3+
#defineGOOD_MACRO_WITH_ARG(X) ((X)*X##_scale) // COMPLIANT
4+
#defineMACRO 1
5+
#defineBAD_MACRO_WITH_ARG(x) (x) + wow##x // NON_COMPLIANT
6+
#defineBAD_MACRO_WITH_ARG_TWO(x,y) (x) + wow##x // NON_COMPLIANT
7+
#defineMACROONE(x) #x // COMPLIANT
8+
#defineMACROTWO(x) x *x // COMPLIANT
9+
#defineMACROTHREE(x) "##\"\"'" + (x) // COMPLIANT
10+
#defineFOO(x) #x MACROONE(x) // COMPLIANT - no further arg expansion
11+
12+
voidf() {
13+
14+
intx;
15+
intx_scale;
16+
inty;
17+
intwowMACRO=0;
18+
19+
y=GOOD_MACRO_WITH_ARG(x);
20+
wowMACRO=BAD_MACRO_WITH_ARG(MACRO);
21+
wowMACRO=BAD_MACRO_WITH_ARG_TWO(MACRO,1);
22+
chars[]=MACROONE(MACRO);
23+
y=MACROTWO(MACRO);
24+
MACROTHREE(MACRO);
25+
FOO(x);
26+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
| test.c:8:14:8:17 | call to atof | Call to banned function atof. |
2+
| test.c:9:12:9:15 | call to atoi | Call to banned function atoi. |
3+
| test.c:10:13:10:16 | call to atol | Call to banned function atol. |
4+
| test.c:11:18:11:22 | call to atoll | Call to banned function atoll. |

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp