[cfe-commits] [PATCH] Implement a better plugin API for clang

Jordan Rose jordan_rose at apple.com
Tue Jun 26 09:26:09 PDT 2012


On Jun 22, 2012, at 13:31 , Joshua Cranmer <pidgeot18 at gmail.com> wrote:

>>> +  for (std::vector<Plugin>::iterator it = plugins.begin(); it != plugins.end();
>>> +      ++it) {
>>> +    // Retrieve the callbacks, and clear all of the values to NULL
>>> +    clang::plugin::PluginFileCallbacks *callbacks = it->getCallbacks();
>>> +    memset(callbacks, 0, sizeof(clang::plugin::PluginFileCallbacks));
>> This is silly. Plugin should just default-initialize the struct when it's created. (Empty parens will do the right thing.)
> 
> Some notes:
> 1. This works even if a plugin doesn't define the method (e.g., a plugin just wants to do some LLVM hooking)
> 2. This has some footgun-prevention effects for plugin writers
> 

Sorry, I meant "the Plugin object", i.e. *it (the class that owns the callback struck). Users' plugins shouldn't have to do anything. Manuel mentioned this too.

All your other responses make sense to me. :-) I'd like to see one more iteration of the patch before this goes in, but I think it's looking pretty good already.

Jordan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120626/96fc8887/attachment.html>


More information about the cfe-commits mailing list