[cfe-dev] [Cocci] Re: using with c++ codebase ?

Carl-Daniel Hailfinger c-d.hailfinger.devel.2006 at gmx.net
Sun Nov 28 09:24:06 PST 2010


Hi,

I added the llvm cfe-dev mailing list to CC so you can get answers
directly from the source.
The quoted mail is archived at
http://lists.diku.dk/pipermail/cocci/2010-November/001348.html and you
can go forward/backward in the archive if you want to see more context.

On 27.11.2010 22:49, Julia Lawall wrote:
> On Sat, 27 Nov 2010, Carl-Daniel Hailfinger wrote:
>   
>> On 27.11.2010 17:46, Julia Lawall wrote:
>>     
>>> On Sat, 27 Nov 2010, Jani Monoses wrote
>>>       
>>>> On 11/27/2010 02:44 PM, Julia Lawall wrote:
>>>>     
>>>>         
>>>>> I think it is possible, and indeed a C++ parser has been written that is
>>>>> compatible with Coccinelle.  Doing the simple case as you suggest is even
>>>>> probably not too hard.  But at the moment we do not have the resources to
>>>>> look into it.
>>>>>       
>>>>>           
>>>> thanks for the prompt reply.
>>>> Is the C++ parser code available along with some documentation on how it can
>>>> be used with Coccinelle?
>>>>     
>>>>         
>>> There is no documentation.  Furthermore, it is only a parser, it does not 
>>> construct an abstract syntax tree, so compatible with Coccinelle may not 
>>> mean much more than it is written in ocaml.  I think it is available, but 
>>> I am not sure where.  Perhaps Nicolas or Yoann can answer.
>>>   
>>>       
>> This may be a dumb question, but is there any reason the C++ parser in
>> llvm/clang can't be used? It is compatible with gcc, and AFAIK it is
>> rather easy to make it spit out an AST in the format you want.
>> The LLVM developers are very open to suggestions, and many people have
>> used LLVM in their own projects.
>> Apparently LLVM ships with OCaml bindings by default, so it may not be
>> too hard to use it.
>>     
>
> Perhaps it relies on CPP (ie expansion of macros) having been performed in 
> advance?  Coccinelle needs to parse the code as it is, not parse it into 
> some simplified internal representation, so that it can reconstruct the 
> code after transformation.  This includes keeping information about all 
> whitespace and comments.
>   


Regards,
Carl-Daniel



More information about the cfe-dev mailing list