1scan-build 2========== 3 4A package designed to wrap a build so that all calls to gcc/clang are 5intercepted and logged into a [compilation database][1] and/or piped to 6the clang static analyzer. Includes intercept-build tool, which logs 7the build, as well as scan-build tool, which logs the build and runs 8the clang static analyzer on it. 9 10Portability 11----------- 12 13Should be working on UNIX operating systems. 14 15- It has been tested on FreeBSD, GNU/Linux and OS X. 16- Prepared to work on windows, but need help to make it. 17 18 19Prerequisites 20------------- 21 221. **python** interpreter (version 2.7, 3.2, 3.3, 3.4, 3.5). 23 24 25How to use 26---------- 27 28To run the Clang static analyzer against a project goes like this: 29 30 $ scan-build <your build command> 31 32To generate a compilation database file goes like this: 33 34 $ intercept-build <your build command> 35 36To run the Clang static analyzer against a project with compilation database 37goes like this: 38 39 $ analyze-build 40 41Use `--help` to know more about the commands. 42 43 44Limitations 45----------- 46 47Generally speaking, the `intercept-build` and `analyze-build` tools together 48does the same job as `scan-build` does. So, you can expect the same output 49from this line as simple `scan-build` would do: 50 51 $ intercept-build <your build command> && analyze-build 52 53The major difference is how and when the analyzer is run. The `scan-build` 54tool has three distinct model to run the analyzer: 55 561. Use compiler wrappers to make actions. 57 The compiler wrappers does run the real compiler and the analyzer. 58 This is the default behaviour, can be enforced with `--override-compiler` 59 flag. 60 612. Use special library to intercept compiler calls durring the build process. 62 The analyzer run against each modules after the build finished. 63 Use `--intercept-first` flag to get this model. 64 653. Use compiler wrappers to intercept compiler calls durring the build process. 66 The analyzer run against each modules after the build finished. 67 Use `--intercept-first` and `--override-compiler` flags together to get 68 this model. 69 70The 1. and 3. are using compiler wrappers, which works only if the build 71process respects the `CC` and `CXX` environment variables. (Some build 72process can override these variable as command line parameter only. This case 73you need to pass the compiler wrappers manually. eg.: `intercept-build 74--override-compiler make CC=intercept-cc CXX=intercept-c++ all` where the 75original build command would have been `make all` only.) 76 77The 1. runs the analyzer right after the real compilation. So, if the build 78process removes removes intermediate modules (generated sources) the analyzer 79output still kept. 80 81The 2. and 3. generate the compilation database first, and filters out those 82modules which are not exists. So, it's suitable for incremental analysis durring 83the development. 84 85The 2. mode is available only on FreeBSD and Linux. Where library preload 86is available from the dynamic loader. Not supported on OS X (unless System 87Integrity Protection feature is turned off). 88 89`intercept-build` command uses only the 2. and 3. mode to generate the 90compilation database. `analyze-build` does only run the analyzer against the 91captured compiler calls. 92 93 94Known problems 95-------------- 96 97Because it uses `LD_PRELOAD` or `DYLD_INSERT_LIBRARIES` environment variables, 98it does not append to it, but overrides it. So builds which are using these 99variables might not work. (I don't know any build tool which does that, but 100please let me know if you do.) 101 102 103Problem reports 104--------------- 105 106If you find a bug in this documentation or elsewhere in the program or would 107like to propose an improvement, please use the project's [issue tracker][3]. 108Please describing the bug and where you found it. If you have a suggestion 109how to fix it, include that as well. Patches are also welcome. 110 111 112License 113------- 114 115The project is licensed under University of Illinois/NCSA Open Source License. 116See LICENSE.TXT for details. 117 118 [1]: http://clang.llvm.org/docs/JSONCompilationDatabase.html 119 [2]: https://pypi.python.org/pypi/scan-build 120 [3]: https://llvm.org/bugs/enter_bug.cgi?product=clang 121