Giter VIP home page Giter VIP logo

clazy's Introduction

--------------------------------------------------------------------------------
BUILD INSTRUCTIONS

* Build and install clang >= 3.6 if your distro doesn't provide it
  $ git clone https://github.com/llvm-mirror/llvm.git <some_directory>
  $ mkdir <some_directory>/build && cd <some_directory>/build
  $ ../configure --enable-optimized --prefix=<prefix> && make && make install

* Build the clang-lazy plugin
  $ cmake -DCMAKE_INSTALL_PREFIX=<prefix> -DCMAKE_BUILD_TYPE=Release
  $ make && make install

--------------------------------------------------------------------------------
USAGE INSTRUCTIONS

You should now have the clazy command available to you, in <prefix>/bin/.
Compile your programs with it instead of clang++/g++.

Note that this command is just a convenience wrapper which calls:
clang++ -Xclang -load -Xclang ClangLazy.so -Xclang -add-plugin -Xclang clang-lazy

To make it the default compiler for cmake projects just:
export CXX="clazy"
Don't forget to clean and re-run cmake

To make it the default compiler for qmake projects hack the mkspec:
Edit mkspecs/common/clang.conf and change QMAKE_CXX to clazy instead of clang++
Then run qmake -spec linux-clang


Finally, you need to choose which checks to enable. This is done through CLAZY_CHECKS env variable.
For example:
export CLAZY_CHECKS="bogus-dynamic-cast,qmap-with-key-pointer,virtual-call-ctor"

Instead of using the env variable, you can also pass an argument to the compiler:
-Xclang -plugin-arg-clang-lazy -Xclang bogus-dynamic-cast,qmap-with-key-pointer,virtual-call-ctor

Available checks:

bogus-dynamic-cast
foreacher
global-const-char-pointer
inefficient-qlist
qstring-uneeded-heap-allocations    (fix-qlatin1string-allocations,fix-fromLatin1_fromUtf8-allocations,fix-fromCharPtrAllocations)
function-args-by-ref
qmap-with-key-pointer
non-pod-global-static
reserve-candidates
variant-sanitizer
virtual-call-ctor
--------------------------------------------------------------------------------
ENABLING FIXITS

Some checks support fixits, in which clazy will re-write your source files whenever it can fix something.
You can enable a fixit through the env variable, for example:
export CLAZY_FIXIT="fix-qlatin1string-allocations"

Only one fixit can be enabled each time.
WARNING: Backup your code, don't blame me if a fixit is not applied correctly.
For better results don't use parallel builds, otherwise a fixit being applied in an header file might be done twice.
--------------------------------------------------------------------------------

clazy's People

Contributors

iamsergio avatar syntheticpp avatar tsdgeos avatar vkrause avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.