andybons | 222c4ee | 2015-08-25 16:51:03 | [diff] [blame] | 1 | # The Clang Static Analyzer |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 2 | |
andybons | 222c4ee | 2015-08-25 16:51:03 | [diff] [blame] | 3 | See the [official clang static analyzer page](http://clang-analyzer.llvm.org/) |
| 4 | for background. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 5 | |
kmarshall | 520f951 | 2017-01-24 23:25:01 | [diff] [blame^] | 6 | As of early 2017, we have experimental support for the Clang static analysis |
| 7 | tool in the Chrome build. Warnings generated by the analysis tool are logged |
| 8 | to stderr along with other compiler errors at build time. |
andybons | 222c4ee | 2015-08-25 16:51:03 | [diff] [blame] | 9 | |
kmarshall | 520f951 | 2017-01-24 23:25:01 | [diff] [blame^] | 10 | To enable static analysis for your build, add the following line to your |
| 11 | output directory's `args.gn`: |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 12 | |
| 13 | ``` |
kmarshall | 520f951 | 2017-01-24 23:25:01 | [diff] [blame^] | 14 | use_clang_static_analyzer = true |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 15 | ``` |
| 16 | |
kmarshall | 520f951 | 2017-01-24 23:25:01 | [diff] [blame^] | 17 | The next time you rebuild, you should see static analysis warnings appear inline |
| 18 | with the usual Clang build warnings and errors. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 19 | |
kmarshall | 520f951 | 2017-01-24 23:25:01 | [diff] [blame^] | 20 | ## Future plans/potential issues |
| 21 | * Support for running under GOMA is untested, but will be added shortly if |
| 22 | feasible. |