Skip to content

Commit f1588b2

Browse files
Max Schaeferjames
authored andcommitted
JavaScript: Fix description of call graphs.
(cherry picked from commit 2817cf0)
1 parent ffa370a commit f1588b2

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

docs/language/learn-ql/javascript/introduce-libraries-js.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -682,28 +682,28 @@ You can add custom type inference rules by defining new subclasses of ``DataFlow
682682
Call graph
683683
~~~~~~~~~~
684684

685-
The library ``semmle.javascript.dataflow.CallGraph`` implements a simple `call graph <http://en.wikipedia.org/wiki/Call_graph>`__ construction algorithm to statically approximate the possible call targets of function calls and ``new`` expressions. Due to the dynamically typed nature of JavaScript and its support for higher-order functions and reflective language features, building static call graphs is quite difficult. Simple call graph algorithms tend to be incomplete, that is, they often fail to resolve all possible call targets. More sophisticated algorithms can suffer from the opposite problem of imprecision, that is, they may infer many spurious call targets.
685+
The JavaScript library implements a simple `call graph <http://en.wikipedia.org/wiki/Call_graph>`__ construction algorithm to statically approximate the possible call targets of function calls and ``new`` expressions. Due to the dynamically typed nature of JavaScript and its support for higher-order functions and reflective language features, building static call graphs is quite difficult. Simple call graph algorithms tend to be incomplete, that is, they often fail to resolve all possible call targets. More sophisticated algorithms can suffer from the opposite problem of imprecision, that is, they may infer many spurious call targets.
686686

687-
The library provides a QL class `CallSite <https://help.semmle.com/qldoc/javascript/semmle/javascript/dataflow/CallGraph.qll/type.CallGraph$CallSite.html>`__, which extends `InvokeExpr <https://help.semmle.com/qldoc/javascript/semmle/javascript/Expr.qll/type.Expr$InvokeExpr.html>`__ with a member predicate ``getACallee()`` that computes possible callees of the given call site, that is, functions that may at runtime be invoked by this expression.
687+
The call graph is represented by the member predicate ``getACallee()`` of class `DataFlow::InvokeNode <https://help.semmle.com/qldoc/javascript/semmle/javascript/dataflow/Nodes.qll/type.Nodes$InvokeNode.html>`__, which computes possible callees of the given invocation, that is, functions that may at runtime be invoked by this expression.
688688

689-
Furthermore, there are three member predicates that indicate the quality of the callee information for this call site:
689+
Furthermore, there are three member predicates that indicate the quality of the callee information for this invocation:
690690

691-
- ``CallSite.isImprecise()``: holds for call sites where the call graph builder might infer spurious call targets.
692-
- ``CallSite.isIncomplete()``: holds for call sites where the call graph builder might fail to infer possible call targets.
693-
- ``CallSite.isUncertain()``: holds if either ``isImprecise()`` or ``isUncertain()`` holds.
691+
- ``DataFlow::InvokeNode.isImprecise()``: holds for invocations where the call graph builder might infer spurious call targets.
692+
- ``DataFlow::InvokeNode.isIncomplete()``: holds for invocations where the call graph builder might fail to infer possible call targets.
693+
- ``DataFlow::InvokeNode.isUncertain()``: holds if either ``isImprecise()`` or ``isUncertain()`` holds.
694694

695-
As an example of a call-graph-based query, here is a query to find call sites for which the call graph builder could not find any callees, despite the analysis being complete for this call site:
695+
As an example of a call-graph-based query, here is a query to find invocations for which the call graph builder could not find any callees, despite the analysis being complete for this invocation:
696696

697697
.. code-block:: ql
698698
699699
import javascript
700700
701-
from CallSite cs
702-
where not cs.isIncomplete() and
703-
not exists(cs.getACallee())
704-
select cs, "Unable to find a callee for this call site."
701+
from DataFlow::InvokeNode invk
702+
where not invk.isIncomplete() and
703+
not exists(invk.getACallee())
704+
select invk, "Unable to find a callee for this invocation."
705705
706-
➤ `See this in the query console <https://lgtm.com/query/1506065666123/>`__
706+
➤ `See this in the query console <https://lgtm.com/query/3260345690335671362/>`__
707707

708708
Inter-procedural data flow
709709
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1031,4 +1031,4 @@ What next?
10311031

10321032
- Learn about the QL standard libraries used to write queries for TypeScript in :doc:`Introducing the TypeScript libraries <introduce-libraries-ts>`.
10331033
- Find out more about QL in the `QL language handbook <https://help.semmle.com/QL/ql-handbook/index.html>`__ and `QL language specification <https://help.semmle.com/QL/ql-spec/language.html>`__.
1034-
- Learn more about the query console in `Using the query console <https://lgtm.com/help/lgtm/using-query-console>`__.
1034+
- Learn more about the query console in `Using the query console <https://lgtm.com/help/lgtm/using-query-console>`__.

0 commit comments

Comments
 (0)