Skip to content

Commit

Permalink
Document all nodes using the default EOG
Browse files Browse the repository at this point in the history
  • Loading branch information
KuechA committed Nov 5, 2024
1 parent aac9006 commit c0baa57
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,11 @@ open class EvaluationOrderGraphPass(ctx: TranslationContext) : TranslationUnitPa
map[ConstructExpression::class.java] = {
handleConstructExpression(it as ConstructExpression)
}
map[EmptyStatement::class.java] = {
handleDefault(it as EmptyStatement)
} // TODO: Documentation missing
map[Literal::class.java] = { handleDefault(it) } // TODO: Documentation missing
map[DefaultStatement::class.java] = { handleDefault(it) } // TODO: Documentation missing
map[TypeIdExpression::class.java] = { handleDefault(it) } // TODO: Documentation missing
map[Reference::class.java] = { handleDefault(it) } // TODO: Documentation missing
map[EmptyStatement::class.java] = { handleEmptyStatement(it as EmptyStatement) }
map[Literal::class.java] = { handleLiteral(it as Literal<*>) }
map[DefaultStatement::class.java] = { handleDefaultStatement(it as DefaultStatement) }
map[TypeIdExpression::class.java] = { handleTypeIdExpression(it as TypeIdExpression) }
map[Reference::class.java] = { handleReference(it as Reference) }
map[CollectionComprehension::class.java] = {
handleCollectionComprehension(it as CollectionComprehension)
}
Expand All @@ -198,13 +196,6 @@ open class EvaluationOrderGraphPass(ctx: TranslationContext) : TranslationUnitPa
map[ThrowStatement::class.java] = { handleThrowStatement(it as ThrowStatement) }
}

/**
* See [Specification](https://fraunhofer-aisec.github.io/cpg/CPG/specs/eog/#includedeclaration)
*/
protected fun handleIncludeDeclaration() {
doNothing()
}

protected fun doNothing() {
// Nothing to do for this node type
}
Expand Down Expand Up @@ -448,6 +439,43 @@ open class EvaluationOrderGraphPass(ctx: TranslationContext) : TranslationUnitPa
attachToEOG(node)
}

/** See [Specification](https://fraunhofer-aisec.github.io/cpg/CPG/specs/eog/#emptystatement) */
private fun handleEmptyStatement(node: EmptyStatement) {
attachToEOG(node)
}

/** See [Specification](https://fraunhofer-aisec.github.io/cpg/CPG/specs/eog/#emptystatement) */
private fun handleLiteral(node: Literal<*>) {
attachToEOG(node)
}

/**
* See [Specification](https://fraunhofer-aisec.github.io/cpg/CPG/specs/eog/#defaultstatement)
*/
private fun handleDefaultStatement(node: DefaultStatement) {
attachToEOG(node)
}

/**
* See
* [Specification](https://fraunhofer-aisec.github.io/cpg/CPG/specs/eog/#handletypeidexpression)
*/
private fun handleTypeIdExpression(node: TypeIdExpression) {
attachToEOG(node)
}

/** See [Specification](https://fraunhofer-aisec.github.io/cpg/CPG/specs/eog/#reference) */
private fun handleReference(node: Reference) {
attachToEOG(node)
}

/**
* See [Specification](https://fraunhofer-aisec.github.io/cpg/CPG/specs/eog/#includedeclaration)
*/
protected fun handleIncludeDeclaration() {
doNothing()
}

/** See [Specification](https://fraunhofer-aisec.github.io/cpg/CPG/specs/eog/#callexpression) */
protected fun handleCallExpression(node: CallExpression) {
// Todo add call as throwexpression to outer scope of call can throw (which is trivial to
Expand Down
65 changes: 65 additions & 0 deletions docs/docs/CPG/specs/eog.md
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,71 @@ flowchart LR
parent --EOG--> next:::outer
```

## EmptyStatement
The statement itself is connected to the outer EOG.

Interesting fields: /

Scheme:
```mermaid
flowchart LR
classDef outer fill:#fff,stroke:#ddd,stroke-dasharray:5 5;
prev:::outer --EOG--> parent["EmptyStatement"]
parent --EOG--> next:::outer
```

## Literal
The statement itself is connected to the outer EOG.

Interesting fields: /

Scheme:
```mermaid
flowchart LR
classDef outer fill:#fff,stroke:#ddd,stroke-dasharray:5 5;
prev:::outer --EOG--> parent["Literal"]
parent --EOG--> next:::outer
```

## DefaultStatement
The statement itself is connected to the outer EOG.

Interesting fields: /

Scheme:
```mermaid
flowchart LR
classDef outer fill:#fff,stroke:#ddd,stroke-dasharray:5 5;
prev:::outer --EOG--> parent["DefaultStatement"]
parent --EOG--> next:::outer
```

## TypeIdExpression
The statement itself is connected to the outer EOG.

Interesting fields: /

Scheme:
```mermaid
flowchart LR
classDef outer fill:#fff,stroke:#ddd,stroke-dasharray:5 5;
prev:::outer --EOG--> parent["TypeIdExpression"]
parent --EOG--> next:::outer
```

## Reference
The statement itself is connected to the outer EOG.

Interesting fields: /

Scheme:
```mermaid
flowchart LR
classDef outer fill:#fff,stroke:#ddd,stroke-dasharray:5 5;
prev:::outer --EOG--> parent["Reference"]
parent --EOG--> next:::outer
```

## IncludeDeclaration
The `IncludeDeclaration` is not connected to the EOG.
We continue with the next statement.

0 comments on commit c0baa57

Please sign in to comment.