-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add IndirectUninitializedNode and related helper predicates
#21458
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?
Changes from all commits
6c792e6
8c03136
d3066af
f8a3ce7
3f9ad14
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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -617,6 +617,25 @@ module Public { | |||||||||
| */ | ||||||||||
| LocalVariable asUninitialized() { result = this.(UninitializedNode).getLocalVariable() } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Gets the uninitialized local variable corresponding to this node behind | ||||||||||
| * the given levels of indirection, if any. | ||||||||||
| */ | ||||||||||
| LocalVariable asIndirectUninitialized(int indirectionIndex) { | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| exists(IndirectUninitializedNode indirectUninitializedNode | | ||||||||||
| this = indirectUninitializedNode and | ||||||||||
| indirectUninitializedNode.getIndirectionIndex() = indirectionIndex | ||||||||||
| | | ||||||||||
| result = indirectUninitializedNode.getLocalVariable() | ||||||||||
| ) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Gets the uninitialized local variable corresponding to this node behind | ||||||||||
| * any levels of indirection, if any. | ||||||||||
|
Comment on lines
+634
to
+635
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| */ | ||||||||||
| LocalVariable asIndirectUninitialized() { result = this.asIndirectUninitialized(_) } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Gets the positional parameter corresponding to the node that represents | ||||||||||
| * the value of the parameter after `index` number of loads, if any. For | ||||||||||
|
|
@@ -761,16 +780,13 @@ module Public { | |||||||||
| final override Type getType() { result = this.getPreUpdateNode().getType() } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * The value of an uninitialized local variable, viewed as a node in a data | ||||||||||
| * flow graph. | ||||||||||
| */ | ||||||||||
| class UninitializedNode extends Node { | ||||||||||
| abstract private class AbstractUninitializedNode extends Node { | ||||||||||
| LocalVariable v; | ||||||||||
| int indirectionIndex; | ||||||||||
|
|
||||||||||
| UninitializedNode() { | ||||||||||
| AbstractUninitializedNode() { | ||||||||||
| exists(SsaImpl::Definition def, SsaImpl::SourceVariable sv | | ||||||||||
| def.getIndirectionIndex() = 0 and | ||||||||||
| def.getIndirectionIndex() = indirectionIndex and | ||||||||||
| def.getValue().asInstruction() instanceof UninitializedInstruction and | ||||||||||
| SsaImpl::defToNode(this, def, sv) and | ||||||||||
| v = sv.getBaseVariable().(SsaImpl::BaseIRVariable).getIRVariable().getAst() | ||||||||||
|
|
@@ -781,6 +797,28 @@ module Public { | |||||||||
| LocalVariable getLocalVariable() { result = v } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * The value of an uninitialized local variable, viewed as a node in a data | ||||||||||
| * flow graph. | ||||||||||
| */ | ||||||||||
| class UninitializedNode extends AbstractUninitializedNode { | ||||||||||
| UninitializedNode() { indirectionIndex = 0 } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * The value of an uninitialized local variable behind one or more levels of | ||||||||||
| * indirection, viewed as a node in a data flow graph. | ||||||||||
| * | ||||||||||
| * NOTE: For the direct value of the uninitialized local variable, see | ||||||||||
| * `UninitializedNode`. | ||||||||||
|
Comment on lines
+812
to
+813
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not something we remark anywhere else, so maybe just leave it out. |
||||||||||
| */ | ||||||||||
| class IndirectUninitializedNode extends AbstractUninitializedNode { | ||||||||||
| IndirectUninitializedNode() { indirectionIndex > 0 } | ||||||||||
|
|
||||||||||
| /** Gets the level of indirection to get to this node. */ | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| int getIndirectionIndex() { result = indirectionIndex } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * The value of a parameter at function entry, viewed as a node in a data | ||||||||||
| * flow graph. This includes both explicit parameters such as `x` in `f(x)` | ||||||||||
|
|
||||||||||
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.