Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 See the [official clang static analyzer page](http://clang-analyzer.llvm.org/) f or background. | 1 # The Clang Static Analyzer |
| 2 | 2 |
| 3 We don't run this regularly (because the analyzer's [support for C++ isn't great yet](http://clang-analyzer.llvm.org/dev_cxx.html)), so everything on this page is likely broken. The last time I checked, the analyzer reported mostly unintere sting things. This assumes you're [building chromium with clang](Clang.md). | 3 See the [official clang static analyzer page](http://clang-analyzer.llvm.org/) |
| 4 for background. | |
| 4 | 5 |
| 5 You need an llvm checkout to get `scan-build` and `scan-view`; the easiest way t o get that is to run | 6 We don't run this regularly (because the analyzer's |
| 6 ``` | 7 [support for C++ isn't great yet](http://clang-analyzer.llvm.org/dev_cxx.html)), |
| 8 so everything on this page is likely broken. The last time I checked, the | |
| 9 analyzer reported mostly uninteresting things. This assumes you're | |
| 10 [building chromium with clang](clang.md). | |
| 11 | |
| 12 You need an llvm checkout to get `scan-build` and `scan-view`; the easiest way | |
| 13 to get that is to run | |
| 14 | |
| 15 ```shell | |
| 7 tools/clang/scripts/update.sh --force-local-build --without-android | 16 tools/clang/scripts/update.sh --force-local-build --without-android |
| 8 ``` | 17 ``` |
| 9 | 18 |
| 10 ## With make | 19 ## With make |
| 11 | 20 |
| 12 To build base, if you use the make build: | 21 To build base, if you use the make build: |
| 13 | 22 |
| 14 ``` | 23 ``` |
| 15 builddir_name=out_analyze \ | 24 builddir_name=out_analyze \ |
| 16 PATH=$PWD/third_party/llvm-build/Release+Asserts/bin:$PATH \ | 25 PATH=$PWD/third_party/llvm-build/Release+Asserts/bin:$PATH \ |
| 17 third_party/llvm/tools/clang/tools/scan-build/scan-build \ | 26 third_party/llvm/tools/clang/tools/scan-build/scan-build \ |
| 18 --keep-going --use-cc clang --use-c++ clang++ \ | 27 --keep-going --use-cc clang --use-c++ clang++ \ |
| 19 make -j8 base | 28 make -j8 base |
| 20 ``` | 29 ``` |
| 21 | 30 |
| 22 (`builddir_name` is set to force a clobber build.) | 31 (`builddir_name` is set to force a clobber build.) |
| 23 | 32 |
| 24 Once that's done, run `third_party/llvm/tools/clang/tools/scan-view/scan-view` t o see the results; pass in the pass that `scan-build` outputs. | 33 Once that's done, run `third_party/llvm/tools/clang/tools/scan-view/scan-view` |
| 34 to see the results; pass in the pass that `scan-build` outputs. | |
| 25 | 35 |
| 26 ## With ninja | 36 ## With ninja |
| 27 | 37 |
| 28 scan-build does its stuff by mucking with $CC/$CXX, which ninja ignores. gyp doe s look at $CC/$CXX however, so you need to first run gyp\_chromium under scan-bu ild: | 38 scan-build does its stuff by mucking with $CC/$CXX, which ninja ignores. gyp |
| 29 ``` | 39 does look at $CC/$CXX however, so you need to first run gyp\_chromium under |
| 40 scan-build: | |
| 41 | |
| 42 ```shell | |
| 30 time GYP_GENERATORS=ninja \ | 43 time GYP_GENERATORS=ninja \ |
| 31 GYP_DEFINES='component=shared_library clang_use_chrome_plugins=0 mac_strip_relea se=0 dcheck_always_on=1' \ | 44 GYP_DEFINES='component=shared_library clang_use_chrome_plugins=0 \ |
| 45 mac_strip_release=0 dcheck_always_on=1' \ | |
| 32 third_party/llvm/tools/clang/tools/scan-build/scan-build \ | 46 third_party/llvm/tools/clang/tools/scan-build/scan-build \ |
| 33 --use-analyzer $PWD/third_party/llvm-build/Release+Asserts/bin/clang \ | 47 --use-analyzer $PWD/third_party/llvm-build/Release+Asserts/bin/clang \ |
| 34 build/gyp_chromium -Goutput_dir=out_analyze | 48 build/gyp_chromium -Goutput_dir=out_analyze |
| 35 ``` | 49 ``` |
| 50 | |
| 36 You then need to run the build under scan-build too, to get a HTML report: | 51 You then need to run the build under scan-build too, to get a HTML report: |
| 37 ``` | 52 |
| 38 time third_party/llvm/tools/clang/tools/scan-build/scan-build \ | 53 ```shell |
| 54 time third_party/llvm/tools/clang/tools/scan-build/scan-build \ | |
| 39 --use-analyzer $PWD/third_party/llvm-build/Release+Asserts/bin/clang \ | 55 --use-analyzer $PWD/third_party/llvm-build/Release+Asserts/bin/clang \ |
| 40 ninja -C out_analyze/Release/ base | 56 ninja -C out_analyze/Release/ base |
| 41 ``` | 57 ``` |
| 58 | |
| 42 Then run `scan-view` as described above. | 59 Then run `scan-view` as described above. |
| 43 | 60 |
| 44 ## Known False Positives | 61 ## Known False Positives |
| 45 | 62 |
| 46 * http://llvm.org/bugs/show_bug.cgi?id=11425 | 63 * http://llvm.org/bugs/show_bug.cgi?id=11425 |
| 47 | 64 |
| 48 ## Stuff found by the static analyzer | 65 ## Stuff found by the static analyzer |
| 49 | 66 |
| 50 * http://code.google.com/p/skia/issues/detail?id=399 | 67 * http://code.google.com/p/skia/issues/detail?id=399 |
| 51 * http://code.google.com/p/skia/issues/detail?id=400 | 68 * http://code.google.com/p/skia/issues/detail?id=400 |
| 52 * http://codereview.chromium.org/8308008/ | 69 * http://codereview.chromium.org/8308008/ |
| 53 * http://codereview.chromium.org/8313008/ | 70 * http://codereview.chromium.org/8313008/ |
| 54 * http://codereview.chromium.org/8308009/ | 71 * http://codereview.chromium.org/8308009/ |
| 55 * http://codereview.chromium.org/10031018/ | 72 * http://codereview.chromium.org/10031018/ |
|
nodir
2015/08/25 14:39:48
use https everywhere
Bons
2015/08/25 16:41:00
Done.
| |
| 56 * https://codereview.chromium.org/12390058/ | 73 * https://codereview.chromium.org/12390058/ |
| OLD | NEW |