Questions tagged [static-analysis]

For questions about approaches for determining properties of a program from the code without evaluating it

Filter by
Sorted by
Tagged with
8 votes
1 answer

How can I account for expressions when building control-flow graphs?

How do statically typed programming languages build CFGs for programs containing expression-level control flow (e.g. ternary expressions, match expressions) which require transformation or extra ...
WZoG's user avatar
  • 83
5 votes
1 answer

How is "Ignore next line" implemented in linters?

Most every linter has an option to "ignore" some parts of the code: /* @eslint-ignore-next-line semi */ // @phpstan-ignore // @ts-ignore # noqa: E731 etc. ...
mousetail's user avatar
  • 8,111
0 votes
1 answer

How to minimize total size of static data?

I am implementing a WASM backend and I hope to optimize the size. I have collected a series of static data. After erasing the type, it can be simply considered as ...
Aster's user avatar
  • 2,688
9 votes
1 answer

What are the tradeoffs between using sea of nodes, CFG of basic blocks, and egraphs for compiler optimizations?

I've heard of "sea of nodes" intermediate representations mostly in the context of just-in-time compilation (JVM, V8, Graal) whereas intermediate representations such as LLVM IR are used in ...
Troy Sargent's user avatar
11 votes
4 answers

How can type systems be a useful formal framework for modeling things other than type-checking?

Quoting one of Alexis King's answers: Many programming language researchers would call many things “type systems” that programmers probably don’t think of as type systems. Many forms of static ...
kaya3's user avatar
  • 17.3k
11 votes
3 answers

How can a language statically ensure a required index exists in a list?

Suppose a language has a conventional list data structure that contains some dynamic number of values indexed sequentially. Some operations to access a value from the list require that a certain index ...
Michael Homer's user avatar
  • 11.7k
4 votes
2 answers

How to estimate which parts of a program will be slow?

Many modern compilers are sophisticated enough to determine that some functions or expressions can be computed lazily, memoised, or parallelised. For example, pure functions can be computed at any ...
kaya3's user avatar
  • 17.3k
7 votes
2 answers

How to verify function purity in an imperative language?

A pure function in an imperative language means one with no observable side-effects, which when called multiple times with identical arguments will always return identical results, and which doesn't ...
kaya3's user avatar
  • 17.3k
5 votes
2 answers

How can I implement a control flow graph?

A Control-Flow-Graph is: 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 ...
FireTheLost's user avatar
  • 1,583
3 votes
3 answers

Why do some languages not have an 'unreachable' function?

Several languages have a function or macro to indicate that a certain point in control flow cannot be reached, even though the compiler cannot statically prove it, such as ...
Bbrk24's user avatar
  • 8,857