All Projects → cs-au-dk → Tip

cs-au-dk / Tip

Static program analysis for TIP

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to Tip

Dg
[LLVM Static Slicer] Various program analyses, construction of dependence graphs and program slicing of LLVM bitcode.
Stars: ✭ 242 (+72.86%)
Mutual labels:  program-analysis, static-code-analysis, static-analyzer
Tajs
Type Analyzer for JavaScript
Stars: ✭ 150 (+7.14%)
Mutual labels:  program-analysis, static-code-analysis, static-analyzer
Cwe checker
cwe_checker finds vulnerable patterns in binary executables
Stars: ✭ 372 (+165.71%)
Mutual labels:  program-analysis, static-analyzer
Wala
T.J. Watson Libraries for Analysis
Stars: ✭ 395 (+182.14%)
Mutual labels:  program-analysis, static-code-analysis
Sonar Pmd
☕️ PMD Plugin for SonarQube
Stars: ✭ 139 (-0.71%)
Mutual labels:  static-code-analysis, static-analyzer
nakedret
nakedret is a Go static analysis tool to find naked returns in functions greater than a specified function length.
Stars: ✭ 82 (-41.43%)
Mutual labels:  static-code-analysis, static-analyzer
eba
EBA is a static bug finder for C.
Stars: ✭ 14 (-90%)
Mutual labels:  static-code-analysis, static-analyzer
Sonar Dotnet
Code analyzer for C# and VB.NET projects https://redirect.sonarsource.com/plugins/vbnet.html
Stars: ✭ 466 (+232.86%)
Mutual labels:  static-code-analysis, static-analyzer
phpstan-nette
Nette Framework class reflection extension for PHPStan & framework-specific rules
Stars: ✭ 87 (-37.86%)
Mutual labels:  static-code-analysis, static-analyzer
Sonar Java
☕️ SonarSource Static Analyzer for Java Code Quality and Security
Stars: ✭ 745 (+432.14%)
Mutual labels:  static-code-analysis, static-analyzer
Sonarjs
SonarSource Static Analyzer for JavaScript and TypeScript
Stars: ✭ 696 (+397.14%)
Mutual labels:  static-code-analysis, static-analyzer
Cfmt
cfmt is a tool to wrap Go comments over a certain length to a new line.
Stars: ✭ 28 (-80%)
Mutual labels:  static-code-analysis, static-analyzer
identypo
identypo is a Go static analysis tool to find typos in identifiers (functions, function calls, variables, constants, type declarations, packages, labels).
Stars: ✭ 26 (-81.43%)
Mutual labels:  static-code-analysis, static-analyzer
unimport
unimport is a Go static analysis tool to find unnecessary import aliases.
Stars: ✭ 64 (-54.29%)
Mutual labels:  static-code-analysis, static-analyzer
Phpstan Doctrine
Doctrine extensions for PHPStan
Stars: ✭ 338 (+141.43%)
Mutual labels:  static-code-analysis, static-analyzer
sonarlint4netbeans
SonarLint integration for Apache Netbeans
Stars: ✭ 23 (-83.57%)
Mutual labels:  static-code-analysis, static-analyzer
Prealloc
prealloc is a Go static analysis tool to find slice declarations that could potentially be preallocated.
Stars: ✭ 419 (+199.29%)
Mutual labels:  static-code-analysis, static-analyzer
Phpstan
PHP Static Analysis Tool - discover bugs in your code without running it!
Stars: ✭ 10,534 (+7424.29%)
Mutual labels:  static-code-analysis, static-analyzer
lints
Lint all your JavaScript, CSS, HTML, Markdown and Dockerfiles with a single command
Stars: ✭ 14 (-90%)
Mutual labels:  static-code-analysis, static-analyzer
Phpdoc Parser
Next-gen phpDoc parser with support for intersection types and generics
Stars: ✭ 569 (+306.43%)
Mutual labels:  static-code-analysis, static-analyzer

TIP

TIP is a tiny imperative programming language aimed at teaching the fundamental concepts of static program analysis. This code accompanies the lecture notes on Static Program Analysis.

Getting started

Prerequisites:

We suggest you to use IntelliJ for working on TIP, but all the following options are viable.

IntelliJ IDEA

  • Install the Scala plugin in IntelliJ. (Follow the instructions on how to install IntelliJ plugins, search for "Scala" in the plugins menu.)
  • Open a terminal, navigate to the directory where you want to store the TIP project.
  • Run git clone https://github.com/cs-au-dk/TIP.git tip
  • In IntelliJ, click File -> New -> Project from Existing Sources..., choose your new 'tip' directory, click OK, choose 'Import project from external model', then 'sbt' and 'Next'.
  • Select a 'Project JDK' (1.8 or newer), and make sure 'builds' is enabled under 'sbt shell", 'use for' before clicking 'Finish'.
  • In the IntelliJ Project overview, move the contents of 'ideafiles' into '.idea', overwriting the existing files.
  • Now reload the project by clicking File -> Invalidate Caches / Restart... -> Just Restart. (Yes, this step is necessary, because of a bug in IntelliJ.)
  • Right-click on Tip.scala in src/tip, then select "Run 'Tip'". To supply arguments, use Run... -> Edit Configurations in the Run menu.

IntelliJ Scala bugs

Important: if you experience spurious type errors reported by IntelliJ for code involving Scala implicits, try disabling type-aware highlighting by clicking on the small [T] icon on the bottom right corner of the window.

IntelliJ performance

If your IntelliJ has high-CPU and high-memory peaks while editing, the following tweaks might be useful:

  • Disable type-aware highlighting by clicking on the small [T] icon on the bottom right corner of the window.
  • Go to Help -> Edit Custom VM Options and increase the JVM memory at least with the following values:
-Xms500m -Xmx1500m
  • If still nothing works, try File -> Power Save Mode.

IntelliJ Import optimization

IntelliJ offers an option to optimize imports upon commit. We suggest not to use that feature, as it may remove needed imports thereby breaking compilation.

Eclipse

  • Check that you have installed the scala-plugin for Eclipse.
  • To run TIP from within Eclipse, feed the arguments into the Run Arguments dialog.

Working from the command-line

A wrapper command tip (tip.bat for Windows) is provided to compile and run TIP with the given arguments.

Example:

./tip -run examples/fib.tip

To build:

sbt compile

Command-line arguments

Usage:

tip <options> <source> [out]

where <source> can be a file or a directory containing .tip files and [out] is an output directory (default: ./out).

To see the possible options, run tip without options. Option -verbose is recommended when developing and testing analyses.

Visualizing control flow graphs and analysis results

The main function Tip.scala emits control flow graphs and analysis results as ".dot" files that can be processed by Graphviz to produce images, for example using the Graphviz dot command-line tool:

dot -O -Tpng out/example.tip__sign.dot

Program normalization

Some analyses require the programs use restricted subsets of TIP. The following kinds of normalization can be performed automatically:

  • -normalizecalls: normalizes function calls to be top-level only and such that arguments are identifiers (e.g. id1 = id2(id3,id4))
  • -normalizereturns: normalizes return expressions to be identifiers (e.g. return id)
  • -normalizepointers: normalizes pointer operations to primitive statements (id = alloc P where P is null or an integer constant, id1 = &id2, id1 = id2, id1 = *id2, *id1 = id2, orid = null)

If one or more of these options are enabled, the normalized program is printed to e.g. out/example.tip__normalized.tip.

Help to Scala novices

This implementation takes advantage of many cool Scala language features that allow the code to be concise and flexible. Many of these language features are quite intuitive and easy to understand for anyone familiar with object oriented and functional programming, even without prior knowledge of Scala. Still, the following language features deserve some extra attention:

Tutorials and extensive documentation for Scala are available at http://docs.scala-lang.org/.

Useful tips:

  • You can see what type Scala has inferred for an expression by selecting the expression and pressing Alt+Equals (depending on keyboard settings in Settings -> Keymap -> Scala -> Type Info).
  • You can see what implicit conversion Scala is applying by enabling View -> Show Implicit Hints (and View -> Expand Implicit Hints, for full information).

Code style

To avoid using inconsistent code styles and meaningless diffs caused by IDE reformatting we use scalafmt.

The code is automatically formatted upon compilation by SBT.

Before committing, please double-check that all the code is in the right format by executing sbt scalafmt. To automatically format when the file is saved, go to File -> Settings..., under 'Editor', 'Code Style', 'Scala', make sure 'Scalafmt' is selected under 'Formatter'. (Unfortunately the formatting is only triggered when the file is explicitly saved with Ctrl-S.)

Authors

with contributions from

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].