[cfe-dev] A plugin proposal for clang

Douglas Gregor dgregor at apple.com
Thu Oct 20 07:53:05 PDT 2011

On Oct 20, 2011, at 2:59 AM, Konstantin Tokarev wrote:

> 20.10.2011, 11:44, "Erik Verbruggen" <erik.verbruggen at me.com>:
>> On 19-10-11 20:03, Joshua Cranmer wrote:
>>>  On 10/17/2011 1:12 PM, Douglas Gregor wrote:
>>>>  On Oct 14, 2011, at 5:31 PM, Joshua Cranmer wrote:
>>>  Effectively, an example of how to do LLVM optimization passes via a
>>>  clang plugin.
>>>>  One useful example would be to add an "annotate" attribute to various
>>>>  declarations, and verify that the attribute made it through to the IR.
>>>>  I think it's useful to categorize the various existing and intended
>>>>  extension points for a plugin interface. ASTConsumer and PPCallbacks
>>>>  come to mind immediately, but what else?
>>>  Diagnostics (so plugins can add warnings/errors) come to mind quickly as
>>>  well. I can imagine that some clever people might need to know about
>>>  some specific codegen details if they are using plugins to generate
>>>  reflective metadata; everything else I can think of is more or less
>>>  covered by LLVM.
>> Being able to generate new chunks of AST would also be helpful. That
>> would make it possible to turn source-code generators into plug-ins that
>> generate AST on the fly, without needing to generate code.
> ..and rewrite chunks of old AST before it gets into CodeGen.

IMO, both of these should be left for "later", and certainly not part of the set of requirements for a plugin system. Modifying or adding to the AST looks easy to do, but it is hard to do *well*. It's going to require a number of specific hooks in Sema. 

	- Doug

More information about the cfe-dev mailing list