[cfe-dev] Adding a rewrite class to Clang

Daniel Dunbar daniel at zuster.org
Sun Sep 26 21:37:33 PDT 2010


On Sat, Sep 18, 2010 at 5:37 AM, Jacob Carlborg <doob at me.com> wrote:
> On 2010-09-13 11:10, Jan Bierbaum wrote:
>> 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.
>
> Thanks that helped, but how could "-rewrite-objc-to-d" come before
> "-rewrite-objc" ?

That is just the particular definition of the ordering we use. We
always match the first option in the list which is a prefix (more or
less), and we want "-rewrite-objc-to-d" to be matched instead of
"-rewrite-objc" (if it accepts suffixes).

 - Daniel

>
>>> 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.
>
>
> --
> /Jacob Carlborg
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>




More information about the cfe-dev mailing list