[cfe-dev] Proposal: parsing Qt signals/slots with attributes

Chris Lattner clattner at apple.com
Tue Sep 27 10:18:43 PDT 2011


On Sep 26, 2011, at 11:27 PM, Konstantin Tokarev wrote:

> 
> 
> 27.09.2011, 00:52, "Chris Lattner" <clattner at apple.com>:
>> On Sep 26, 2011, at 7:02 AM, Konstantin Tokarev wrote:
>> 
>>>  26.09.2011, 15:04, "David Chisnall" <csdavec at swan.ac.uk>:
>>>>   It would help if you could explain what you want to use these attributes for (i.e. why would clang supporting them in the parser help you).  The IBAction / IBOutlet support is there to allow the various ad-hoc Objective-C parsers that understood these macros to continue to understand them when switching to libclang.  What tools does Qt use that need to understand these annotations?
>>>  "signals" and "slots" annotations are currently used by Meta-Object Compiler (code generating tool which is part of Qt).
>>> 
>>>  Attribute-based annotations will be used by Qt Creator to provide code completetion, and it can be used in other tools (e.g. code analysis tools) which need to inspect Qt code and use advanced Clang capabilities in the same time.
>> 
>> I haven't looked at the patch in question, but it seems reasonable to add some sort of qt_foobar attribute if it substantially improves QT development.
>> 
>> Random thought experiment: would it be possible to kill off MOC entirely (at least when building with Clang)?
> 
> And when compiling with other compilers, it would be possible to use Clang-based moc instead of original to generate code. Original MOC has a number of limitations because it actually does build AST [1]. Clang-based moc could overcome them while preserving compatibility with non-Clang compilers.
> 
> [1] http://doc.qt.nokia.com/latest/moc.html#limitations

Makes sense, a clang-based rewriter would be a straight-forward way to implement this.

We really need to split them out into plugins though :)

-Chris




More information about the cfe-dev mailing list