[cfe-commits] [PATCH] Interface proposal for clang formatting tools

Douglas Gregor dgregor at apple.com
Wed Jun 6 14:46:26 PDT 2012


On Jun 6, 2012, at 8:15 AM, Manuel Klimek <klimek at google.com> wrote:

> On Wed, Jun 6, 2012 at 5:04 PM, Douglas Gregor <dgregor at apple.com> wrote:
> On Jun 6, 2012, at 3:23 AM, Chandler Carruth wrote:
> 
>> On Wed, Jun 6, 2012 at 3:08 AM, Manuel Klimek <klimek at google.com> wrote:
>> On Wed, Jun 6, 2012 at 12:04 PM, Chandler Carruth <chandlerc at google.com> wrote:
>> On Wed, Jun 6, 2012 at 2:57 AM, Manuel Klimek <klimek at google.com> wrote:
>> Daniel & me have worked on a first proposal to provide an interface for clang formatting as part of the Tooling library.
>> 
>> Please re-send the patch as an attachment? Email plays havoc w/ 80-columns. 
>> 
>> Done.
>> 
>> Thanks!
>> 
>> I think it would help a lot to have a bit more code & context when evaluating this, even as a very early step.
>> 
>> My concrete suggestion would be this: implement a bozo-formatter. A completely trivial to implement, BS set of rules that only requires lexing. Then we can see the interface, a trivial implementation, and some test cases that use it. I think that'll make this much easier to review and really analyze. It also makes it much closer to something that could get checked in as a stepping stone
> 
> Yes, please! In fact, I don't think we should even try to design the AnalyzableSource interface now, because we're not likely to know what we need until we have at least some basic formatting. 
> 
> The problem with doing no design on the AnalyzableSource interface yet is that we'll then need to pass in all kinds of stuff, like the SourceManager, FileManager etc (as we already have use cases where they're owned by a layer above it) and we need to control when to trigger parsing, and we also already have some known requirements on where we don't want to do it because it falls out of another step anyway.
> 
> Thus, if with "not trying to design" you mean "it's fine as proposed, but it might turn out very differently later", then I'm in full agreement. If you mean "we should just hand in everything we need", then I disagree.
> 
> Which is it? :)

Either the first one or neither ;)

I don't think the AnalyzableSource abstraction belongs here at all, because the question of when to trigger parsing isn't the responsibility of the code formatting tool. The code formatting tool should do its formatting, and as it's doing so it should ask questions (through some abstract interface) about the semantics of particular tokens it encounters. If there happens to be, on the other side of that interface, something that does parsing to answer those questions, fine: that something can handle reparsing, and we can build up some separate infrastructure to do that.

	- Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120606/0d2a7e48/attachment.html>


More information about the cfe-commits mailing list