Skip to content

Commit f2ce331

Browse files
committed
Add SidePackage3 rule description and metadata
1 parent 25d82e7 commit f2ce331

File tree

5 files changed

+124
-4
lines changed

5 files changed

+124
-4
lines changed

.vscode/tasks.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@
203203
"Concurrency1",
204204
"Concurrency2",
205205
"Concurrency3",
206-
"Concurrency4",
207-
"Concurrency5",
206+
"Concurrency4",
207+
"Concurrency5",
208208
"Conditionals",
209209
"Const",
210210
"DeadCode",
@@ -255,6 +255,7 @@
255255
"Scope",
256256
"SideEffects1",
257257
"SideEffects2",
258+
"SideEffects3",
258259
"SmartPointers1",
259260
"SmartPointers2",
260261
"Strings",

cpp/common/src/codingstandards/cpp/exclusions/c/RuleMetadata.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import Preprocessor5
5050
import Preprocessor6
5151
import SideEffects1
5252
import SideEffects2
53+
import SideEffects3
5354
import SignalHandlers
5455
import StandardLibraryFunctionTypes
5556
import Statements1
@@ -113,6 +114,7 @@ newtype TCQuery =
113114
TPreprocessor6PackageQuery(Preprocessor6Query q) or
114115
TSideEffects1PackageQuery(SideEffects1Query q) or
115116
TSideEffects2PackageQuery(SideEffects2Query q) or
117+
TSideEffects3PackageQuery(SideEffects3Query q) or
116118
TSignalHandlersPackageQuery(SignalHandlersQuery q) or
117119
TStandardLibraryFunctionTypesPackageQuery(StandardLibraryFunctionTypesQuery q) or
118120
TStatements1PackageQuery(Statements1Query q) or
@@ -176,6 +178,7 @@ predicate isQueryMetadata(Query query, string queryId, string ruleId, string cat
176178
isPreprocessor6QueryMetadata(query, queryId, ruleId, category) or
177179
isSideEffects1QueryMetadata(query, queryId, ruleId, category) or
178180
isSideEffects2QueryMetadata(query, queryId, ruleId, category) or
181+
isSideEffects3QueryMetadata(query, queryId, ruleId, category) or
179182
isSignalHandlersQueryMetadata(query, queryId, ruleId, category) or
180183
isStandardLibraryFunctionTypesQueryMetadata(query, queryId, ruleId, category) or
181184
isStatements1QueryMetadata(query, queryId, ruleId, category) or
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//** THIS FILE IS AUTOGENERATED, DO NOT MODIFY DIRECTLY. **/
2+
import cpp
3+
import RuleMetadata
4+
import codingstandards.cpp.exclusions.RuleMetadata
5+
6+
newtype SideEffects3Query =
7+
TSideEffectsInArgumentsToUnsafeMacrosQuery() or
8+
TUnsequencedSideEffectsQuery() or
9+
TMultipleObjectModificationsQuery()
10+
11+
predicate isSideEffects3QueryMetadata(Query query, string queryId, string ruleId, string category) {
12+
query =
13+
// `Query` instance for the `sideEffectsInArgumentsToUnsafeMacros` query
14+
SideEffects3Package::sideEffectsInArgumentsToUnsafeMacrosQuery() and
15+
queryId =
16+
// `@id` for the `sideEffectsInArgumentsToUnsafeMacros` query
17+
"c/cert/side-effects-in-arguments-to-unsafe-macros" and
18+
ruleId = "PRE31-C" and
19+
category = "rule"
20+
or
21+
query =
22+
// `Query` instance for the `unsequencedSideEffects` query
23+
SideEffects3Package::unsequencedSideEffectsQuery() and
24+
queryId =
25+
// `@id` for the `unsequencedSideEffects` query
26+
"c/misra/unsequenced-side-effects" and
27+
ruleId = "RULE-13-2" and
28+
category = "required"
29+
or
30+
query =
31+
// `Query` instance for the `multipleObjectModifications` query
32+
SideEffects3Package::multipleObjectModificationsQuery() and
33+
queryId =
34+
// `@id` for the `multipleObjectModifications` query
35+
"c/misra/multiple-object-modifications" and
36+
ruleId = "RULE-13-2" and
37+
category = "required"
38+
}
39+
40+
module SideEffects3Package {
41+
Query sideEffectsInArgumentsToUnsafeMacrosQuery() {
42+
//autogenerate `Query` type
43+
result =
44+
// `Query` type for `sideEffectsInArgumentsToUnsafeMacros` query
45+
TQueryC(TSideEffects3PackageQuery(TSideEffectsInArgumentsToUnsafeMacrosQuery()))
46+
}
47+
48+
Query unsequencedSideEffectsQuery() {
49+
//autogenerate `Query` type
50+
result =
51+
// `Query` type for `unsequencedSideEffects` query
52+
TQueryC(TSideEffects3PackageQuery(TUnsequencedSideEffectsQuery()))
53+
}
54+
55+
Query multipleObjectModificationsQuery() {
56+
//autogenerate `Query` type
57+
result =
58+
// `Query` type for `multipleObjectModifications` query
59+
TQueryC(TSideEffects3PackageQuery(TMultipleObjectModificationsQuery()))
60+
}
61+
}

rule_packages/c/SideEffects3.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"CERT-C": {
3+
"PRE31-C": {
4+
"properties": {
5+
"obligation": "rule"
6+
},
7+
"queries": [
8+
{
9+
"description": "",
10+
"kind": "problem",
11+
"name": "Avoid side effects in arguments to unsafe macros",
12+
"precision": "very-high",
13+
"severity": "error",
14+
"short_name": "SideEffectsInArgumentsToUnsafeMacros",
15+
"tags": [
16+
"correctness"
17+
]
18+
}
19+
],
20+
"title": "Avoid side effects in arguments to unsafe macros"
21+
}
22+
},
23+
"MISRA-C-2012": {
24+
"RULE-13-2": {
25+
"properties": {
26+
"obligation": "required"
27+
},
28+
"queries": [
29+
{
30+
"description": "The value of an expression and its persistent side effects are depending on the evaluation order resulting in unpredictable behavior.",
31+
"kind": "problem",
32+
"name": "The value of an expression and its persistent side effects depend on its evaluation order",
33+
"precision": "very-high",
34+
"severity": "error",
35+
"short_name": "UnsequencedSideEffects",
36+
"tags": [
37+
"correctness"
38+
]
39+
},
40+
{
41+
"description": "An object shall not be modified more than once between two adjacent sequence points or within any full expression.",
42+
"kind": "problem",
43+
"name": "No object shall be modified more than once",
44+
"precision": "very-high",
45+
"severity": "warning",
46+
"short_name": "MultipleObjectModifications",
47+
"tags": [
48+
"correctness"
49+
]
50+
}
51+
],
52+
"title": "The value of an expression and its persistent side effects shall be the same under all permitted evaluation orders"
53+
}
54+
}
55+
}

rules.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ c,CERT-C,POS52-C,OutOfScope,Rule,,,Do not perform operations that can block whil
586586
c,CERT-C,POS53-C,OutOfScope,Rule,,,Do not use more than one mutex for concurrent waiting operations on a condition variable,,,,
587587
c,CERT-C,POS54-C,OutOfScope,Rule,,,Detect and handle POSIX library errors,,,,
588588
c,CERT-C,PRE30-C,No,Rule,,,Do not create a universal character name through concatenation,,,Medium,
589-
c,CERT-C,PRE31-C,Yes,Rule,,,Avoid side effects in arguments to unsafe macros,RULE-13-2,SideEffects,Medium,
589+
c,CERT-C,PRE31-C,Yes,Rule,,,Avoid side effects in arguments to unsafe macros,RULE-13-2,SideEffects3,Medium,
590590
c,CERT-C,PRE32-C,Yes,Rule,,,Do not use preprocessor directives in invocations of function-like macros,,Preprocessor5,Hard,
591591
c,CERT-C,SIG30-C,Yes,Rule,,,Call only asynchronous-safe functions within signal handlers,,SignalHandlers,Medium,
592592
c,CERT-C,SIG31-C,Yes,Rule,,,Do not access shared objects in signal handlers,,SignalHandlers,Medium,
@@ -688,7 +688,7 @@ c,MISRA-C-2012,RULE-12-3,Yes,Advisory,,,The comma operator should not be used,M5
688688
c,MISRA-C-2012,RULE-12-4,Yes,Advisory,,,Evaluation of constant expressions should not lead to unsigned integer wrap-around,INT30-C,IntegerOverflow,Easy,
689689
c,MISRA-C-2012,RULE-12-5,Yes,Mandatory,,,The sizeof operator shall not have an operand which is a function parameter declared as �array of type�,,Types,Medium,
690690
c,MISRA-C-2012,RULE-13-1,Yes,Required,,,Initializer lists shall not contain persistent side effects,,SideEffects1,Medium,
691-
c,MISRA-C-2012,RULE-13-2,Yes,Required,,,The value of an expression and its persistent side effects shall be the same under all permitted evaluation orders,PRE31-C,SideEffects,Medium,
691+
c,MISRA-C-2012,RULE-13-2,Yes,Required,,,The value of an expression and its persistent side effects shall be the same under all permitted evaluation orders,PRE31-C,SideEffects3,Medium,
692692
c,MISRA-C-2012,RULE-13-3,Yes,Advisory,,,A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator,,SideEffects2,Medium,
693693
c,MISRA-C-2012,RULE-13-4,Yes,Advisory,,,The result of an assignment operator should not be used,M6-2-1,SideEffects1,Easy,
694694
c,MISRA-C-2012,RULE-13-5,Yes,Required,,,The right hand operand of a logical && or || operator shall not contain persistent side effects,M5-14-1,SideEffects1,Import,

0 commit comments

Comments
 (0)