what's the best way to writing a code analyzer with clang?

I’m writing a c/c++ code analyzer recently. I read some clang documents/tutorials. It seems there’re several ways to accomplish this. And i’m using this tutorial http://eli.thegreenplace.net/2012/06/08/basic-source-to-source-transformation-with-clang, because it’s a real sample which can be get worked.

So my question is, is there any other better ways to do this ?

What kind of analysis are you trying to do? Static? (if so,
source-to-source transformation isn't really relevant - check out the
Clang Static Analyzer and Anna's talk from the 2012 dev meeting)
Dynamic? (again, source to source transformation probably isn't what
you want - see how Address Sanitizer is implemented - as an LLVM IR
pass adding in the instrumentation/checking at that level)