[cfe-dev] Adding a rewrite class to Clang

Jan Bierbaum s3306700 at inf.tu-dresden.de
Mon Sep 13 02:10:36 PDT 2010


Hi Jacob!

Jacob Carlborg meinte am 12.09.2010 22:30:

> <FlagClass Name:"-rewrite-objc">
> <FlagClass Name:"-rewrite-objc-to-d">
> Assertion failed: (0 && "Options are not in order!"), function OptTable, 
> file OptTable.cpp, line 119.
[...]
> So how do I correctly add a new command line option to Clang

You just have to order them correctly [1]:

| Options are stored in sorted order, with '\0' at the end of the
| alphabet.o

So '-rewrite-objc-to-d' has to come *before* '-rewrite-objc'. The
ordering is necessary due to the way Clang parses its options.


> or is there a better way to quickly get up and running with a new
> rewrite class?

You could implement it as a plugin. There's an example in
'example/PrintFunctionNames'. Unfortunately the plugin infrastructure is
somewhat buggy/incomplete/?, so you have to add a minor change to llvm
before they work [2].


[1] http://clang.llvm.org/doxygen/OptTable_8cpp_source.html#l00201
[2] http://permalink.gmane.org/gmane.comp.compilers.clang.devel/8277


Regards, Jan.



More information about the cfe-dev mailing list