Merge remote-tracking branch 'origin/main' into call_ast

This commit is contained in:
Nick Rolfe
2021-01-22 11:48:32 +00:00
3 changed files with 1068 additions and 1057 deletions

View File

@@ -13,6 +13,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;

View File

@@ -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. */