| 1 | = Using clang for static analysis = |
| 2 | |
| 3 | LLVM/Clang comes with a static analyzer that can be used to generate web-based analysis reports for many bug categories. |
| 4 | |
| 5 | == Prerequistities == |
| 6 | |
| 7 | Make sure the analyzer is installed on your system. On Fedora 24 the package is called clang-analyzer. Also make sure you have web browser installed. |
| 8 | |
| 9 | == Running the analysis == |
| 10 | |
| 11 | Configure HelenOS for e.g. amd64 and in the HelenOS source root directory run the following command: |
| 12 | |
| 13 | {{{ |
| 14 | $ scan-build make PROFILE=amd64 |
| 15 | }}} |
| 16 | |
| 17 | This should kick off the static analysis process and result in a message like the following: |
| 18 | |
| 19 | {{{ |
| 20 | scan-build: 121 bugs found. |
| 21 | scan-build: Run 'scan-view /tmp/scan-build-2016-07-18-210821-13060-1' to examine bug reports. |
| 22 | }}} |
| 23 | |
| 24 | == Inspecting the results == |
| 25 | |
| 26 | When the analysis run is finished, one can inspect the result by the following command (assuming the output above): |
| 27 | |
| 28 | {{{ |
| 29 | $ scan-view /tmp/scan-build-2016-07-18-210821-13060-1 |
| 30 | Starting scan-view at: http://127.0.0.1:8181 |
| 31 | Use Ctrl-C to exit. |
| 32 | Created new window in existing browser session. |
| 33 | }}} |
| 34 | |
| 35 | Now you should be able to inspect the results in your web browser: |
| 36 | |