Tool-infer, Static code detection

Source: Internet
Author: User
Tags ocaml

1. Introduction of tools

Infer is a static program analysis tool that can be used to analyze Java, C, and objective-c programs, which are written in OCaml.
Infer was first deployed on Facebook to analyze each line of code before it was released for mobile apps, and now Facebook uses this tool to analyze the Android, IOS apps that are being developed, including Facebook Messenger, Instagram and some other applications. Infer not only for mobile application analysis, but also for the analysis of C, Java and other not Android system code. At present, infer focuses on discovering problems such as access to null pointers, leaks of resources and memory, and the crash of mobile phone programs or severe performance degradation.

2. Download Unzip

2.1 https://github.com/facebook/infer/releases

2.2 Tar XF infer-0.2.0. Tar

3. Setting up the environment (you can see the install.md inside the unpacking package)

3.1 Download Install Opam (https://opam.ocaml.org/doc/Install.html)

3.2 Installing Clang

Xcode-select--install

3.3 Installing OCaml

Opam Init--comp=4.01.0 # (answer ' y ' to the question)

Eval ' opam config env '

Opam Install sawja.1.5 atdgen.1.5.0 javalib.2.3a extlib.1.5.4

4. Installing infer

CD Infer

./update-fcp.sh &&. /facebook-clang-plugin/clang/setup.sh &&./compile-fcp.sh

Make-c Infer

Export path= ' pwd '/infer/bin: $PATH

5. Engineering Static Analysis

Analytics App:

Infer--Xcodebuild-target <target name>-configuration <build configuration>-sdk <SDK>

Sample Detection Helloworldapp Engineering:

Infer--Xcodebuild-target helloworldapp-configuration debug-sdk iphonesos8.3

You need to use --incremental (or -i ) to make the result output of an incremental compilation:

Infer--incremental--xcodebuild-target helloworldapp-configuration debug-sdk iphonesos8.3

or clean up before compiling:

Xcodebuild-target helloworldapp-configuration debug-sdk iphonesos8.3 Clean

OK, here you will see the results you want to see.

Reference Document: Http://infer.liaohuqiu.net/docs/getting-started.html

Tool-infer, Static code detection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.