Monday, December 21, 2009

Static analysis For The Win!


I caught on about clang, which is both a compiler and static analyzer, after it was mentioned on the xorg-devel list. Since then I've been running it on my own code and gradually fixing up errors.

Now, usually such tools are less than impressive (excluding extremely expensive proprietary tools such as Coverity.) However, clang has been really useful in eliminating a lot of dead code, unused variables (and the overhead of calling expensive functions to calculate those variables.)

I even discovered one major bug in the expression evaluator in my game engine which had gone overlooked for some time, which would result in two opcodes giving incorrect results and ultimately effecting the rendering of the shaders.

Clang is currently lacking Inter-Procedural Analysis but it seems like it's on the to-do shortlist, which will be a very nice feature. Hopefully it won't be long before Coverity's eating it's heart out.

1 comment:

  1. Nice blog... static analyzer is very important tool. I really appreciate your efforts on writing this helpful blog. Thanks for sharing.

    ReplyDelete