mirror of
https://github.com/github/codeql.git
synced 2025-12-26 13:46:31 +01:00
Merge pull request #99 from github/hvitved/cfg/to-string
CFG: Use manual `toString()`s for `AstCfgNode` when available
This commit is contained in:
@@ -12,6 +12,7 @@ private import ast.internal.TreeSitter
|
||||
* A node in the abstract syntax tree. This class is the base class for all Ruby
|
||||
* program elements.
|
||||
*/
|
||||
// TODO: Replace base class with an abstract range class once we have full coverage
|
||||
class AstNode extends @ast_node {
|
||||
Generated::AstNode generated;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/** Provides classes representing the control flow graph. */
|
||||
|
||||
private import codeql.Locations
|
||||
private import codeql_ruby.AST as AST
|
||||
private import codeql_ruby.ast.internal.TreeSitter::Generated
|
||||
private import codeql_ruby.controlflow.BasicBlocks
|
||||
private import SuccessorTypes
|
||||
@@ -133,9 +134,18 @@ module CfgNodes {
|
||||
final override AstNode getNode() { result = n }
|
||||
|
||||
final override string toString() {
|
||||
result = "[" + this.getSplitsString() + "] " + n.toString()
|
||||
or
|
||||
not exists(this.getSplitsString()) and result = n.toString()
|
||||
exists(string s |
|
||||
// TODO: Remove once the SSA implementation is based on the AST layer
|
||||
s = n.(AST::AstNode).toString() and
|
||||
s != "AstNode"
|
||||
or
|
||||
n.(AST::AstNode).toString() = "AstNode" and
|
||||
s = n.toString()
|
||||
|
|
||||
result = "[" + this.getSplitsString() + "] " + s
|
||||
or
|
||||
not exists(this.getSplitsString()) and result = s
|
||||
)
|
||||
}
|
||||
|
||||
/** Gets a comma-separated list of strings for each split in this node, if any. */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user