Fantastic blog post demonstrating how to write your own clang analysis: https://ehsanakhgari.org/blog/2015-12-07/c-static-analysis-using-clang#comment-3494 (compilers are great for nonlocal reasoning)