What is Clang?
I’ve spent the last few months working with Clang, a frontend for the LLVM compiler project. Clang can parse and analyze any source code in the C language family (C, C++, ObjectiveC, etc…) and has a wonderful modular design that makes it easy to use.
If you’re looking to do static analysis on some C code, I highly recommend Clang — it’s vastly superior to other static analysis tools (like CIL … yuck!) and has decent documentation. Also, the Clang mailing list is very active and helpful if you ever find yourself stuck on something.
I personally used Clang to perform static analysis on I/O device drivers in the Linux kernel, including camera drivers and DRM drivers for graphics cards. Kernel code (especially drivers) can be very complex and difficult to analyze, but Clang allows you to handle it with ease. Let’s take a look at what you can do with Clang.
(more…)