On the January 16 2008, Dr. Dobb’s Journal published my article “Static testing C++ Code” ( http://drdobbs.com/cpp/205801074 ). In that paper, after a tutorial on testing issues for C++ programs, I presented a technique and related utility to implement static testing automation of a C++ library. By “static testing” I mean to run a program that examines the source code of the library and detects non-conformities, i.e. where the library does not fulfills the requirements expressed as valid and invalid usage of that library.
To that end, C++ code must be parsed to detect if it is a valid C++ program. As I stated in the article, at that time I didn’t know of no free library to parse C++ code, and therefore I built a utility that executes one or more C++ compilers, and examines if the compilation is successful.
That approach works well, but it has the drawback of being quite slow. If a test suite contains one hundred of test cases, one hundred of different C++ programs must be generated and saved on as many files, and each of them must be compiled.
Now, I heard that the LLVM project contains the Clang subproject ( http://clang.llvm.org/index.html ), whose stated goal is “to create a new C, C++, Objective C and Objective C++ front-end for the LLVM compiler”. I have not tried it, but the authors claim their project is rather mature. As I understand it, it is a library that you may use just to parse C++ code, without necessarily generating an output. Therefore, it may be integrated in a static testing utility, with ease of deployment and configuration, and with possible performance advantages.
If anyone has done already something similar, or wants to, let me know, please!