Skip to content
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

Added missing EOG changes for variable declaration #1330

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions docs/docs/CPG/specs/eog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The Evaluation Order Graph (EOG) is built as edges between AST nodes after the initial translation of the code to the CPG.
Its purpose is to follow the order in which code is executed, similar to a CFG, and additionally differentiate on a finer level of granularity in which order expressions and subexpressions are evaluated.
Every node points to a set of previously evaluated nodes (`prevEOG`) and nodes that are evaluated after (`nextEOG`).
The EOG edges are intraprocedural and thus differentiate from INVOKES edges.
The EOG edges are intra-procedural and thus differentiate from INVOKES edges.
In the following, we summarize in which order the root node representing a language construct and its descendants in the AST tree are connected.

An EOG always starts at root node representing a method/function or record that holds executable code and ends in the node representing the corresponding code or multiple return statements.
Expand Down Expand Up @@ -48,7 +48,7 @@ Note that, in the following graphics we will often draw an EOG edge to an abstra
The EOG path through that subtree will depend on the node types of that tree and mostly start connecting one of the AST leaf nodes.

## FunctionDeclaration
A function declaration is the start of an intraprocedural EOG and contains its end. Therefore there is no incoming or outgoing edge to `previous` or `next` eog nodes that are not in its AST subtree. The EOG connects the code body, as well as the default values of parameters if they exist.
A function declaration is the start of an intra-procedural EOG and contains its end. Therefore there is no incoming or outgoing edge to `previous` or `next` eog nodes that are not in its AST subtree. The EOG connects the code body, as well as the default values of parameters if they exist.

Interesting fields:

Expand Down Expand Up @@ -112,7 +112,7 @@ flowchart LR
```

## VariableDeclaration
Represents the declaration of a local variable.
Represents the declaration of a local or global variable.

Interesting fields:

Expand All @@ -122,13 +122,14 @@ Scheme:
```mermaid
flowchart LR
classDef outer fill:#fff,stroke:#ddd,stroke-dasharray:5 5;
prev:::outer --EOG--> child
parent(["VariableDeclaration"]) --EOG--> next:::outer
prev:::outer --EOG--> parent(["VariableDeclaration"])
child --EOG--> next:::outer
parent -.-> child["initializer"]
child --EOG--> parent

parent --EOG--> child
```

In case the variable is a global variable (e.g., a top-level variable in a `RecordDeclaration`), it does not have a `prevEOG` and the initializer does not have a `nextEOG`.

## CallExpression
Represents any type of call in a program.

Expand Down