-
Notifications
You must be signed in to change notification settings - Fork 75
Add packages Memory5 and Memory6
#1048
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
Open
jeongsoolee09
wants to merge
38
commits into
main
Choose a base branch
from
jeongsoolee09/MISRA-C++-2023-Memory5-Memory6
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,689
−99
Open
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
b1b46a8
Number package names to Memory5 and Memory6
jeongsoolee09 0f5bb42
Add rule package description files
jeongsoolee09 ebd28d7
Add rule package files
jeongsoolee09 b416471
Add test case for Memory5 (RULE-21-6-2)
jeongsoolee09 fd0479d
Add missing stubs
jeongsoolee09 2c0f579
Prune unneeded stubs
jeongsoolee09 ad1ddf1
re-export calloc, realloc, aligned_alloc
jeongsoolee09 b454890
Forward-declare `tuple` in utility.h and define it in tuple.h
jeongsoolee09 c7e2e87
Format the stub code and add stdlib.h to test
jeongsoolee09 3e795fa
Checkpoint
jeongsoolee09 9d525db
Finalize first draft of Rule 21.6.2
jeongsoolee09 57e3019
Add cases where the addresses of the APIs in question are taken
jeongsoolee09 9075324
Address `auto` deduction errors because of overloads
jeongsoolee09 e33e379
Finalize first draft
jeongsoolee09 71055d3
Add test cases for RULE-21-6-3
jeongsoolee09 3c7b4c9
Fix error in stubs
jeongsoolee09 907f40b
Add missing stubs
jeongsoolee09 69765a6
Checkpoint
jeongsoolee09 3293d4f
Mark existing class-specific declarations as false-negative and add c…
jeongsoolee09 5ccc149
Remove false_negative cases
jeongsoolee09 e67b7af
Fix a bug in the shared library
jeongsoolee09 bfba947
Clean up code
jeongsoolee09 d13d596
Add more cases
jeongsoolee09 e13583f
Minor readability improvement
jeongsoolee09 ad387ef
Surround stubs in include guards
jeongsoolee09 ccd0945
Update expected results of AdvancedMemoryManagementUsed
jeongsoolee09 1a9f0a1
Fine-tune 21.6.2 to exclude placement-new allocation functions
jeongsoolee09 d25ef97
Merge branch 'main' into jeongsoolee09/MISRA-C++-2023-Memory5-Memory6
jeongsoolee09 77cb804
Fix formatting of test case
jeongsoolee09 daa4afd
Only forward-declare `std::allocator` in <string>
jeongsoolee09 b49899d
Update line numbers in ImplicitCapturesDisallowedInNonTransientLambda…
jeongsoolee09 79b679c
Update line numbers in NonTransientLambdaImplicitlyCapturesThis.expec…
jeongsoolee09 24b9f37
Exclude compiler-generated RAII destructor calls
jeongsoolee09 5262b89
Fix stubs
jeongsoolee09 466eb52
Update expected results of Rule 21.6.2
jeongsoolee09 304479c
Make a base class OperatorNewOrDelete and use that in 21-6-3
jeongsoolee09 14ecc2b
Rename file to cpp/standardlibrary/Memory.qll
jeongsoolee09 28d79b2
Change include guard name
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
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
26 changes: 26 additions & 0 deletions
26
cpp/common/src/codingstandards/cpp/exclusions/cpp/Memory5.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 Memory5Query = TDynamicMemoryManagedManuallyQuery() | ||
|
|
||
| predicate isMemory5QueryMetadata(Query query, string queryId, string ruleId, string category) { | ||
| query = | ||
| // `Query` instance for the `dynamicMemoryManagedManually` query | ||
| Memory5Package::dynamicMemoryManagedManuallyQuery() and | ||
| queryId = | ||
| // `@id` for the `dynamicMemoryManagedManually` query | ||
| "cpp/misra/dynamic-memory-managed-manually" and | ||
| ruleId = "RULE-21-6-2" and | ||
| category = "required" | ||
| } | ||
|
|
||
| module Memory5Package { | ||
| Query dynamicMemoryManagedManuallyQuery() { | ||
| //autogenerate `Query` type | ||
| result = | ||
| // `Query` type for `dynamicMemoryManagedManually` query | ||
| TQueryCPP(TMemory5PackageQuery(TDynamicMemoryManagedManuallyQuery())) | ||
| } | ||
| } |
26 changes: 26 additions & 0 deletions
26
cpp/common/src/codingstandards/cpp/exclusions/cpp/Memory6.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 Memory6Query = TAdvancedMemoryManagementUsedQuery() | ||
|
|
||
| predicate isMemory6QueryMetadata(Query query, string queryId, string ruleId, string category) { | ||
| query = | ||
| // `Query` instance for the `advancedMemoryManagementUsed` query | ||
| Memory6Package::advancedMemoryManagementUsedQuery() and | ||
| queryId = | ||
| // `@id` for the `advancedMemoryManagementUsed` query | ||
| "cpp/misra/advanced-memory-management-used" and | ||
| ruleId = "RULE-21-6-3" and | ||
| category = "required" | ||
| } | ||
|
|
||
| module Memory6Package { | ||
| Query advancedMemoryManagementUsedQuery() { | ||
| //autogenerate `Query` type | ||
| result = | ||
| // `Query` type for `advancedMemoryManagementUsed` query | ||
| TQueryCPP(TMemory6PackageQuery(TAdvancedMemoryManagementUsedQuery())) | ||
| } | ||
| } |
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
75 changes: 75 additions & 0 deletions
75
cpp/common/src/codingstandards/cpp/standardlibrary/Memory.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,75 @@ | ||
| /** | ||
| * Provides models of functions in <memory> that deals with uninitialized memory. | ||
| */ | ||
|
|
||
| import cpp | ||
|
Comment on lines
+1
to
+5
|
||
|
|
||
| abstract class UninitializedMemoryManagementFunction extends Function { | ||
| UninitializedMemoryManagementFunction() { | ||
| this.getADeclarationLocation().getFile().getShortName() = "memory" | ||
| } | ||
| } | ||
|
|
||
| class UninitializedCopyFunction extends UninitializedMemoryManagementFunction { | ||
| UninitializedCopyFunction() { this.hasQualifiedName("std", "uninitialized_copy") } | ||
| } | ||
|
|
||
| class UninitializedCopyNFunction extends UninitializedMemoryManagementFunction { | ||
| UninitializedCopyNFunction() { this.hasQualifiedName("std", "uninitialized_copy_n") } | ||
| } | ||
|
|
||
| class UninitializedDefaultConstructFunction extends UninitializedMemoryManagementFunction { | ||
| UninitializedDefaultConstructFunction() { | ||
| this.hasQualifiedName("std", "uninitialized_default_construct") | ||
| } | ||
| } | ||
|
|
||
| class UninitializedDefaultConstructNFunction extends UninitializedMemoryManagementFunction { | ||
| UninitializedDefaultConstructNFunction() { | ||
| this.hasQualifiedName("std", "uninitialized_default_construct_n") | ||
| } | ||
| } | ||
|
|
||
| class UninitializedValueConstructFunction extends UninitializedMemoryManagementFunction { | ||
| UninitializedValueConstructFunction() { | ||
| this.hasQualifiedName("std", "uninitialized_value_construct") | ||
| } | ||
| } | ||
|
|
||
| class UninitializedValueConstructNFunction extends UninitializedMemoryManagementFunction { | ||
| UninitializedValueConstructNFunction() { | ||
| this.hasQualifiedName("std", "uninitialized_value_construct_n") | ||
| } | ||
| } | ||
|
|
||
| class UninitializedMoveFunction extends UninitializedMemoryManagementFunction { | ||
| UninitializedMoveFunction() { this.hasQualifiedName("std", "uninitialized_move") } | ||
| } | ||
|
|
||
| class UninitializedMoveNFunction extends UninitializedMemoryManagementFunction { | ||
| UninitializedMoveNFunction() { this.hasQualifiedName("std", "uninitialized_move_n") } | ||
| } | ||
|
|
||
| class UninitializedFillFunction extends UninitializedMemoryManagementFunction { | ||
| UninitializedFillFunction() { this.hasQualifiedName("std", "uninitialized_fill") } | ||
| } | ||
|
|
||
| class UninitializedFillNFunction extends UninitializedMemoryManagementFunction { | ||
| UninitializedFillNFunction() { this.hasQualifiedName("std", "uninitialized_fill_n") } | ||
| } | ||
|
|
||
| class DestroyFunction extends UninitializedMemoryManagementFunction { | ||
| DestroyFunction() { this.hasQualifiedName("std", "destroy") } | ||
| } | ||
|
|
||
| class DestroyNFunction extends UninitializedMemoryManagementFunction { | ||
| DestroyNFunction() { this.hasQualifiedName("std", "destroy_n") } | ||
| } | ||
|
|
||
| class DestroyAtFunction extends UninitializedMemoryManagementFunction { | ||
| DestroyAtFunction() { this.hasQualifiedName("std", "destroy_at") } | ||
| } | ||
|
|
||
| class LaunderFunction extends UninitializedMemoryManagementFunction { | ||
| LaunderFunction() { this.hasQualifiedName("std", "launder") } | ||
| } | ||
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
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
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
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 @@ | ||
| #include <memory_resource.h> |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I don't want us to add new files to this directory, as its getting fairly disorganized.
Seems like this could live in
cpp/common/src/codingstandards/cpp/standardlibrary/Memory.qll?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 14ecc2b.