mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
Ruby: Avoid computing full fastTC for AstNode::getParent
DIL before
```
/* AST::AstNode */ AST#87953007::Cached::TAstNode result) =
fastTC(Module#fe82a56b::parent#1#ff/2)
.
Module#fe82a56b::enclosingModule#1#ff(/* AST::AstNode */ AST#87953007::Cached::TAstNode node,
/* Module::ModuleBase */ AST#87953007::Cached::TAstNode result)
:-
exists(/* AST::AstNode */ AST#87953007::Cached::TAstNode call_result#2 |
Module#2a43f566::ModuleBase#f(result),
project#AST#a6718388::AstNode::getAChild#1#dispred(result, call_result#2),
(
node = call_result#2;
#Module#fe82a56b::parent#1Plus#ff(node, call_result#2)
)
)
.
```
DIL after
```
incremental
Module#fe82a56b::enclosingModule#1#ff(/* AST::AstNode */ AST#87953007::Cached::TAstNode node,
/* Module::ModuleBase */ AST#87953007::Cached::TAstNode result)
:-
(
Module#2a43f566::ModuleBase#f(result),
exists(cached dontcare string _ |
AST#a6718388::AstNode::getAChild#1#dispred(result, _, node)
)
);
exists(/* AST::AstNode */ AST#87953007::Cached::TAstNode mid |
Module#2a43f566::ModuleBase#f(result),
rec Module#fe82a56b::enclosingModule#1#ff(mid, result),
not(Module#2a43f566::ModuleBase#f(mid)),
not(Method#8b49e67f::Block#f(mid)),
exists(cached dontcare string _ |
AST#a6718388::AstNode::getAChild#1#dispred(mid, _, node)
)
)
| [base_case]
Module#2a43f566::ModuleBase#f(result),
project#AST#a6718388::AstNode::getAChild#1#dispred(result, node)
| [delta_order]
exists(/* AST::AstNode */ AST#87953007::Cached::TAstNode mid |
Module#2a43f566::ModuleBase#f(result),
delta previous rec Module#fe82a56b::enclosingModule#1#ff(mid, result),
not(Module#2a43f566::ModuleBase#f(mid)),
not(Method#8b49e67f::Block#f(mid)),
project#AST#a6718388::AstNode::getAChild#1#dispred(mid, node)
),
not(previous rec Module#fe82a56b::enclosingModule#1#ff(node, result))
| [delta_order_up_to_500000]
exists(/* AST::AstNode */ AST#87953007::Cached::TAstNode mid |
delta previous rec Module#fe82a56b::enclosingModule#1#ff(mid, result),
Module#2a43f566::ModuleBase#f(result),
not(Module#2a43f566::ModuleBase#f(mid)),
not(Method#8b49e67f::Block#f(mid)),
project#AST#a6718388::AstNode::getAChild#1#dispred(mid, node)
),
not(previous rec Module#fe82a56b::enclosingModule#1#ff(node, result))
.
```
This commit is contained in:
@@ -486,12 +486,15 @@ private import ResolveImpl
|
||||
* methods evaluate the block in the context of some other module/class instead of
|
||||
* the enclosing one.
|
||||
*/
|
||||
private ModuleBase enclosingModule(AstNode node) { result = parent*(node).getParent() }
|
||||
|
||||
private AstNode parent(AstNode n) {
|
||||
result = n.getParent() and
|
||||
not result instanceof ModuleBase and
|
||||
not result instanceof Block
|
||||
private ModuleBase enclosingModule(AstNode node) {
|
||||
result = node.getParent()
|
||||
or
|
||||
exists(AstNode mid |
|
||||
result = enclosingModule(mid) and
|
||||
mid = node.getParent() and
|
||||
not mid instanceof ModuleBase and
|
||||
not mid instanceof Block
|
||||
)
|
||||
}
|
||||
|
||||
private Module getAncestors(Module m) {
|
||||
|
||||
Reference in New Issue
Block a user