2121 *
2222 * NOTE: This library should only be used for debugging and exploration, not in production code.
2323 */
24+
2425import javascript
2526private import DataFlow
2627
@@ -33,37 +34,35 @@ private import DataFlow
3334 * by being passed to another call.
3435 */
3536predicate callEdge ( Node pred , Node succ ) {
36- exists ( InvokeNode invoke , Function f |
37- invoke .getACallee ( ) = f and
38- pred = invoke and
39- succ = f .flow ( )
40- or
41- invoke .getContainer ( ) = f and
42- pred = f .flow ( ) and
43- succ = invoke
44- )
37+ exists ( InvokeNode invoke , Function f |
38+ invoke .getACallee ( ) = f and
39+ pred = invoke and
40+ succ = f .flow ( )
4541 or
46- exists ( Function inner , Function outer |
47- inner .getEnclosingContainer ( ) = outer and
48- not inner = outer .getAReturnedExpr ( ) and
49- pred = outer .flow ( ) and
50- succ = inner .flow ( )
51- )
42+ invoke .getContainer ( ) = f and
43+ pred = f .flow ( ) and
44+ succ = invoke
45+ )
46+ or
47+ exists ( Function inner , Function outer |
48+ inner .getEnclosingContainer ( ) = outer and
49+ not inner = outer .getAReturnedExpr ( ) and
50+ pred = outer .flow ( ) and
51+ succ = inner .flow ( )
52+ )
5253}
5354
5455/** Holds if `pred -> succ` is an edge in the call graph. */
5556query predicate edges = callEdge / 2 ;
5657
5758/** Holds if `node` is part of the call graph. */
5859query predicate nodes ( Node node ) {
59- node instanceof InvokeNode or
60- node instanceof FunctionNode
60+ node instanceof InvokeNode or
61+ node instanceof FunctionNode
6162}
6263
6364/** Gets a call in a function that has no known call sites. */
64- private InvokeNode rootCall ( ) {
65- not any ( InvokeNode i ) .getACallee ( ) = result .getContainer ( )
66- }
65+ private InvokeNode rootCall ( ) { not any ( InvokeNode i ) .getACallee ( ) = result .getContainer ( ) }
6766
6867/**
6968 * Holds if `invoke` should be used as the starting point of a call path.
@@ -75,9 +74,7 @@ predicate isStartOfCallPath(InvokeNode invoke) {
7574}
7675
7776/** Gets a function that contains no calls to other functions. */
78- private FunctionNode leafFunction ( ) {
79- not callEdge ( result , _)
80- }
77+ private FunctionNode leafFunction ( ) { not callEdge ( result , _) }
8178
8279/**
8380 * Holds if `fun` should be used as the end point of a call path.
0 commit comments