-
Notifications
You must be signed in to change notification settings - Fork 77
Add Memory2 and Memory3 package
#1023
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
df95b6c
Check in rule description files
jeongsoolee09 e0362b7
Add Memory3
jeongsoolee09 f0a7764
Add "shared_implementation_short_name" and check in all files
jeongsoolee09 a3525b8
Re-add package files
jeongsoolee09 a30e93c
Fix @kind metadata property
jeongsoolee09 ad8864f
Fix the path in PointerComparedBetweenDifferentArrays.testref
jeongsoolee09 c8840db
Remove unneeded qlref and ql code
jeongsoolee09 017f019
Add 'correctness' tags to rule metadata of both queries
jeongsoolee09 dfe986f
Merge branch 'main' into jeongsoolee09/MISRA-C++-Memory2-Memory3
jeongsoolee09 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
cpp/common/src/codingstandards/cpp/exclusions/cpp/Memory2.qll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| //** THIS FILE IS AUTOGENERATED, DO NOT MODIFY DIRECTLY. **/ | ||
| import cpp | ||
| import RuleMetadata | ||
| import codingstandards.cpp.exclusions.RuleMetadata | ||
|
|
||
| newtype Memory2Query = TPointerDifferenceTakenBetweenDifferentArraysQuery() | ||
|
|
||
| predicate isMemory2QueryMetadata(Query query, string queryId, string ruleId, string category) { | ||
| query = | ||
| // `Query` instance for the `pointerDifferenceTakenBetweenDifferentArrays` query | ||
| Memory2Package::pointerDifferenceTakenBetweenDifferentArraysQuery() and | ||
| queryId = | ||
| // `@id` for the `pointerDifferenceTakenBetweenDifferentArrays` query | ||
| "cpp/misra/pointer-difference-taken-between-different-arrays" and | ||
| ruleId = "RULE-8-7-2" and | ||
| category = "required" | ||
| } | ||
|
|
||
| module Memory2Package { | ||
| Query pointerDifferenceTakenBetweenDifferentArraysQuery() { | ||
| //autogenerate `Query` type | ||
| result = | ||
| // `Query` type for `pointerDifferenceTakenBetweenDifferentArrays` query | ||
| TQueryCPP(TMemory2PackageQuery(TPointerDifferenceTakenBetweenDifferentArraysQuery())) | ||
| } | ||
| } |
26 changes: 26 additions & 0 deletions
26
cpp/common/src/codingstandards/cpp/exclusions/cpp/Memory3.qll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| //** THIS FILE IS AUTOGENERATED, DO NOT MODIFY DIRECTLY. **/ | ||
| import cpp | ||
| import RuleMetadata | ||
| import codingstandards.cpp.exclusions.RuleMetadata | ||
|
|
||
| newtype Memory3Query = TPointerComparedBetweenDifferentArraysQuery() | ||
|
|
||
| predicate isMemory3QueryMetadata(Query query, string queryId, string ruleId, string category) { | ||
| query = | ||
| // `Query` instance for the `pointerComparedBetweenDifferentArrays` query | ||
| Memory3Package::pointerComparedBetweenDifferentArraysQuery() and | ||
| queryId = | ||
| // `@id` for the `pointerComparedBetweenDifferentArrays` query | ||
| "cpp/misra/pointer-compared-between-different-arrays" and | ||
| ruleId = "RULE-8-9-1" and | ||
| category = "required" | ||
| } | ||
|
|
||
| module Memory3Package { | ||
| Query pointerComparedBetweenDifferentArraysQuery() { | ||
| //autogenerate `Query` type | ||
| result = | ||
| // `Query` type for `pointerComparedBetweenDifferentArrays` query | ||
| TQueryCPP(TMemory3PackageQuery(TPointerComparedBetweenDifferentArraysQuery())) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
cpp/misra/src/rules/RULE-8-7-2/PointerDifferenceTakenBetweenDifferentArrays.ql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /** | ||
| * @id cpp/misra/pointer-difference-taken-between-different-arrays | ||
| * @name RULE-8-7-2: Subtraction between pointers shall only be applied to ones that address elements of the same array | ||
| * @description Pointer difference should be taken from pointers that belong to a same array. | ||
| * @kind path-problem | ||
| * @precision high | ||
| * @problem.severity error | ||
| * @tags external/misra/id/rule-8-7-2 | ||
| * scope/system | ||
| * external/misra/enforcement/undecidable | ||
| * external/misra/obligation/required | ||
| */ | ||
|
|
||
| import cpp | ||
| import codingstandards.cpp.misra | ||
| import codingstandards.cpp.rules.donotsubtractpointersaddressingdifferentarrays.DoNotSubtractPointersAddressingDifferentArrays | ||
|
|
||
| class PointerDifferenceTakenBetweenDifferentArraysQuery extends DoNotSubtractPointersAddressingDifferentArraysSharedQuery | ||
| { | ||
| PointerDifferenceTakenBetweenDifferentArraysQuery() { | ||
| this = Memory2Package::pointerDifferenceTakenBetweenDifferentArraysQuery() | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
cpp/misra/src/rules/RULE-8-9-1/PointerComparedBetweenDifferentArrays.ql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /** | ||
| * @id cpp/misra/pointer-compared-between-different-arrays | ||
| * @name RULE-8-9-1: The built-in relational operators >, >=, < and <= shall not be applied to objects of pointer type | ||
| * @description Pointer comparison should be done between ones that belong to a same array. | ||
| * @kind path-problem | ||
| * @precision high | ||
| * @problem.severity error | ||
| * @tags external/misra/id/rule-8-9-1 | ||
| * scope/system | ||
| * external/misra/enforcement/undecidable | ||
| * external/misra/obligation/required | ||
| */ | ||
|
|
||
| import cpp | ||
| import codingstandards.cpp.misra | ||
| import codingstandards.cpp.rules.donotuserelationaloperatorswithdifferingarrays.DoNotUseRelationalOperatorsWithDifferingArrays | ||
|
|
||
| class PointerComparedBetweenDifferentArraysQuery extends DoNotUseRelationalOperatorsWithDifferingArraysSharedQuery | ||
| { | ||
| PointerComparedBetweenDifferentArraysQuery() { | ||
| this = Memory3Package::pointerComparedBetweenDifferentArraysQuery() | ||
| } | ||
| } |
1 change: 1 addition & 0 deletions
1
cpp/misra/test/rules/RULE-8-7-2/PointerDifferenceTakenBetweenDifferentArrays.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| No expected results have yet been specified |
1 change: 1 addition & 0 deletions
1
cpp/misra/test/rules/RULE-8-7-2/PointerDifferenceTakenBetweenDifferentArrays.qlref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| rules/RULE-8-7-2/PointerDifferenceTakenBetweenDifferentArrays.ql |
1 change: 1 addition & 0 deletions
1
cpp/misra/test/rules/RULE-8-7-2/PointerDifferenceTakenBetweenDifferentArrays.testref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| cpp/common/test/rules/donotsubtractpointersaddressingdifferentarrays/DoNotSubtractPointersAddressingDifferentArrays.ql |
1 change: 1 addition & 0 deletions
1
cpp/misra/test/rules/RULE-8-9-1/PointerComparedBetweenDifferentArrays.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| No expected results have yet been specified |
1 change: 1 addition & 0 deletions
1
cpp/misra/test/rules/RULE-8-9-1/PointerComparedBetweenDifferentArrays.qlref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| rules/RULE-8-9-1/PointerComparedBetweenDifferentArrays.ql |
1 change: 1 addition & 0 deletions
1
cpp/misra/test/rules/RULE-8-9-1/PointerComparedBetweenDifferentArrays.testref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| cpp/common/test/rules/.ql | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| "MISRA-C++-2023": { | ||
| "RULE-8-7-2": { | ||
| "properties": { | ||
| "enforcement": "undecidable", | ||
| "obligation": "required" | ||
| }, | ||
| "queries": [ | ||
| { | ||
| "description": "Pointer difference should be taken from pointers that belong to a same array.", | ||
| "kind": "path-problem", | ||
| "name": "Subtraction between pointers shall only be applied to ones that address elements of the same array", | ||
| "precision": "high", | ||
| "severity": "error", | ||
| "short_name": "PointerDifferenceTakenBetweenDifferentArrays", | ||
| "shared_implementation_short_name": "DoNotSubtractPointersAddressingDifferentArrays", | ||
| "tags": [ | ||
| "scope/system" | ||
jeongsoolee09 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ] | ||
| } | ||
| ], | ||
| "title": "Pointer difference should be taken from pointers that belong to a same array." | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| "MISRA-C++-2023": { | ||
| "RULE-8-9-1": { | ||
| "properties": { | ||
| "enforcement": "undecidable", | ||
| "obligation": "required" | ||
| }, | ||
| "queries": [ | ||
| { | ||
| "description": "Pointer comparison should be done between ones that belong to a same array.", | ||
| "kind": "path-problem", | ||
| "name": "The built-in relational operators >, >=, < and <= shall not be applied to objects of pointer type", | ||
| "precision": "high", | ||
| "severity": "error", | ||
| "short_name": "PointerComparedBetweenDifferentArrays", | ||
| "shared_implementation_short_name": "DoNotUseRelationalOperatorsWithDifferingArrays", | ||
| "tags": [ | ||
| "scope/system" | ||
| ] | ||
| } | ||
| ], | ||
| "title": "Pointer comparison should be done between ones that belong to a same array." | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.