-
Notifications
You must be signed in to change notification settings - Fork 76
Add lifetime package #1024
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
base: main
Are you sure you want to change the base?
Add lifetime package #1024
Changes from all commits
c29ca80
6956667
9651122
d0f2ede
1c610ee
a903b40
1704bb8
dd5ebd3
ac21481
b2e8f3a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -259,6 +259,7 @@ | |
| "Language1", | ||
| "Language2", | ||
| "Language3", | ||
| "Lifetime", | ||
| "Linkage1", | ||
| "Linkage2", | ||
| "Literals", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| - `A8-5-0`, `EXP53-CPP`, `EXP33-C`, `RULE-9-1` - `MemoryNotInitializedBeforeItIsRead.ql`, `DoNotReadUninitializedMemory.ql`, `DoNotReadUninitializedMemory.ql`, `ObjectWithAutoStorageDurationReadBeforeInit.ql`: | ||
| - The queries listed now find uses of the operator 'new' where there is no value initialization provided. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| //** THIS FILE IS AUTOGENERATED, DO NOT MODIFY DIRECTLY. **/ | ||
| import cpp | ||
| import RuleMetadata | ||
| import codingstandards.cpp.exclusions.RuleMetadata | ||
|
|
||
| newtype LifetimeQuery = | ||
| TValueOfAnObjectMustNotBeReadBeforeItHasBeenSetQuery() or | ||
| TAutomaticStorageAssignedToObjectGreaterLifetimeQuery() | ||
|
|
||
| predicate isLifetimeQueryMetadata(Query query, string queryId, string ruleId, string category) { | ||
| query = | ||
| // `Query` instance for the `valueOfAnObjectMustNotBeReadBeforeItHasBeenSet` query | ||
| LifetimePackage::valueOfAnObjectMustNotBeReadBeforeItHasBeenSetQuery() and | ||
| queryId = | ||
| // `@id` for the `valueOfAnObjectMustNotBeReadBeforeItHasBeenSet` query | ||
| "cpp/misra/value-of-an-object-must-not-be-read-before-it-has-been-set" and | ||
| ruleId = "RULE-11-6-2" and | ||
| category = "mandatory" | ||
| or | ||
| query = | ||
| // `Query` instance for the `automaticStorageAssignedToObjectGreaterLifetime` query | ||
| LifetimePackage::automaticStorageAssignedToObjectGreaterLifetimeQuery() and | ||
| queryId = | ||
| // `@id` for the `automaticStorageAssignedToObjectGreaterLifetime` query | ||
| "cpp/misra/automatic-storage-assigned-to-object-greater-lifetime" and | ||
| ruleId = "RULE-6-8-3" and | ||
| category = "required" | ||
| } | ||
|
|
||
| module LifetimePackage { | ||
| Query valueOfAnObjectMustNotBeReadBeforeItHasBeenSetQuery() { | ||
| //autogenerate `Query` type | ||
| result = | ||
| // `Query` type for `valueOfAnObjectMustNotBeReadBeforeItHasBeenSet` query | ||
| TQueryCPP(TLifetimePackageQuery(TValueOfAnObjectMustNotBeReadBeforeItHasBeenSetQuery())) | ||
| } | ||
|
|
||
| Query automaticStorageAssignedToObjectGreaterLifetimeQuery() { | ||
| //autogenerate `Query` type | ||
| result = | ||
| // `Query` type for `automaticStorageAssignedToObjectGreaterLifetime` query | ||
| TQueryCPP(TLifetimePackageQuery(TAutomaticStorageAssignedToObjectGreaterLifetimeQuery())) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -262,6 +262,8 @@ class AggregateLiteralObjectIdentity extends AggregateLiteral, ObjectIdentityBas | |
| class AllocatedObjectIdentity extends AllocationExpr, ObjectIdentityBase { | ||
| AllocatedObjectIdentity() { | ||
| this.(FunctionCall).getTarget().(AllocationFunction).requiresDealloc() | ||
| or | ||
| this = any(NewOrNewArrayExpr new | not exists(new.getPlacementPointer())) | ||
|
Comment on lines
+265
to
+266
|
||
| } | ||
|
|
||
| override StorageDuration getStorageDuration() { result.isAllocated() } | ||
|
|
||
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.
borrowed this from here