In
computer science
Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
, control-flow analysis (CFA) is a
static-code-analysis technique for determining the
control flow
In computer science, control flow (or flow of control) is the order in which individual statements, instructions or function calls of an imperative program are executed or evaluated. The emphasis on explicit control flow distinguishes an '' ...
of a program. The control flow is expressed as a
control-flow graph
In computer science, a control-flow graph (CFG) is a representation, using graph notation, of all paths that might be traversed through a program during its execution. The control-flow graph was conceived by Frances E. Allen, who noted that ...
(CFG). For both
functional programming language
In computer science, functional programming is a programming paradigm where programs are constructed by applying and composing functions. It is a declarative programming paradigm in which function definitions are trees of expressions that map ...
s and
object-oriented programming language
Object-oriented programming (OOP) is a programming paradigm based on the concept of '' objects''. Objects can contain data (called fields, attributes or properties) and have actions they can perform (called procedures or methods and impleme ...
s, the term CFA, and elaborations such as ''k''-CFA, refer to specific algorithms that compute control flow.
For many
imperative programming language
In computer science, imperative programming is a programming paradigm of software that uses statements that change a program's state. In much the same way that the imperative mood in natural languages expresses commands, an imperative program con ...
s, the control flow of a program is explicit in a program's source code. As a result,
interprocedural control-flow analysis implicitly usually refers to a
static analysis
Static analysis, static projection, or static scoring is a simplified analysis wherein the effect of an immediate change to a system is calculated without regard to the longer-term response of the system to that change. If the short-term effect i ...
technique for determining the receivers of function or method calls in computer programs written in a
higher-order programming language. For example, in a programming language with
higher-order function In mathematics and computer science, a higher-order function (HOF) is a function that does at least one of the following:
* takes one or more functions as arguments (i.e. a procedural parameter, which is a parameter of a procedure that is itself ...
s like
Scheme
Scheme or schemer may refer to:
Arts and entertainment
* ''The Scheme'', a BBC Scotland documentary TV series
* The Scheme (band), an English pop band
* ''The Scheme'', an action role-playing video game for the PC-8801, made by Quest Corporation
* ...
, the target of a function call may not be explicit: in the isolated expression
(lambda (f) (f x))
it is unclear to which procedure
f
may refer. A control-flow analysis must consider where this expression could be invoked and what argument it may receive to determine the possible targets.
Techniques such as
abstract interpretation
In computer science, abstract interpretation is a theory of sound approximation of the semantics of computer programs, based on monotonic functions over ordered sets, especially lattices. It can be viewed as a partial execution of a computer pro ...
,
constraint solving
Constraint satisfaction problems (CSPs) are mathematical questions defined as a set of objects whose state must satisfy a number of constraints or limitations. CSPs represent the entities in a problem as a homogeneous collection of finite const ...
, and
type system
In computer programming, a type system is a logical system comprising a set of rules that assigns a property called a ''type'' (for example, integer, floating point, string) to every '' term'' (a word, phrase, or other set of symbols). Usu ...
s may be used for control-flow analysis.
See also
*
Control-flow diagram
A control-flow diagram (CFD) is a diagram to describe the control flow of a business process, process or review.
Control-flow diagrams were developed in the 1950s, and are widely used in multiple engineering disciplines. They are one of the clas ...
(CFD)
*
Data-flow analysis
Data-flow analysis is a technique for gathering information about the possible set of values calculated at various points in a computer program. It forms the foundation for a wide variety of compiler optimizations and program verification techn ...
*
Cartesian product algorithm
In mathematics, specifically set theory, the Cartesian product of two sets and , denoted , is the set of all ordered pairs where is an element of and is an element of . In terms of set-builder notation, that is
A\times B = \.
A table can ...
*
Pointer analysis
In computer science, pointer analysis, or points-to analysis, is a static code analysis technique that establishes which pointer (computer programming), pointers, or Heap (data structure), heap references, can point to which Variable (computer sci ...
References
External links
for textbook intraprocedural CFA in imperative languagesCFA in functional programs (survey)for the relationship between CFA analysis in functional languages and points-to analysis in imperative/OOP languages
{{Compiler optimizations