Difference between revisions of "Clang"

From ArchWiki
Jump to: navigation, search
(Tidy up usage)
(Using the Static Analyzer: added tip: how to force recompilation&analysis when project is already built)
Line 10: Line 10:
 
First install the {{Pkg|clang-analyzer}} package. To analyze a project, simply place the word {{ic|scan-build}} in front of your build command. For example:
 
First install the {{Pkg|clang-analyzer}} package. To analyze a project, simply place the word {{ic|scan-build}} in front of your build command. For example:
 
  $ scan-build make
 
  $ scan-build make
 +
 +
{{tip|If your project is already compiled, {{ic|scan-build}} won't rebuild and won't analyse it. To force recompilation and analysis, use {{ic|-B}} switch:
 +
{{bc|$ scan-build make -B}}
 +
}}
  
 
It is also possible to analyze specific files:
 
It is also possible to analyze specific files:

Revision as of 18:40, 16 April 2014

Clang is a C/C++/Objective C compiler based on LLVM. It is distributed under the BSD Licence.

Installation

Install clang from the Official repositories.

Build packages with Clang

Add export CC=clang and (for C++) export CXX=clang++ to your /etc/makepkg.conf.

Using the Static Analyzer

First install the clang-analyzer package. To analyze a project, simply place the word scan-build in front of your build command. For example:

$ scan-build make
Tip: If your project is already compiled, scan-build won't rebuild and won't analyse it. To force recompilation and analysis, use -B switch:
$ scan-build make -B

It is also possible to analyze specific files:

$ scan-build gcc -c t1.c t2.c

References