Monday, March 19, 2012

Making ant work with antlr3 and cpptasks

When one uses antlr3 or cpptasks with ant, it might happen, that the following error occurs during build:
$ ant jar
...
.../build.xml:89: Problem: failed to create task or type
        antlib:org/apache/tools/ant/antlr:antlr3
.../build.xml:92: Problem: failed to create task or type
        antlib:net.sf.antcontrib.cpptasks:cc
The cure is (and always was) simple on openSUSE. One just needs to define OPT_JAR_LIST environment variable with appropriate jar names of packages where those classes are defined:
OPT_JAR_LIST='ant-antlr3.jar cpptasks.jar' ant jar

Tuesday, March 13, 2012

Adding a New Clang Checker

Create a file with checker, e.g. by making a copy of some other. Make sure you leave ClangSACheckers.h include in your checker.

Next, you need to add an entry to CMakeLists.txt and Checkers.td. Without that, you will not have your checker built or listed in clang checkers list respectively.

You may hit this build error:
error: 'void clang::ento::register...Checker(clang::ento::CheckerManager&)' should have been declared inside 'clang::ento'

In that case, check that you have ClangSACheckers.h included and that you did not misspelled filename in the two files above.

If the compilation is successful, you should see your checker in the clang checker list generated by:
clang -cc1 -analyzer-checker-help