[cfe-commits] clang formatter patch to move and rename RewriterTestContext.h

jahanian fjahanian at apple.com
Tue Dec 18 09:52:02 PST 2012


On Dec 18, 2012, at 9:41 AM, Douglas Gregor <dgregor at apple.com> wrote:

> 
> On Dec 18, 2012, at 1:09 AM, Daniel Jasper <djasper at google.com> wrote:
> 
>> 
>> 
>> 
>> On Mon, Dec 17, 2012 at 11:04 PM, Douglas Gregor <dgregor at apple.com> wrote:
>> 
>> On Dec 17, 2012, at 9:55 AM, Daniel Jasper <djasper at google.com> wrote:
>> 
>>> Hi Fariborz,
>>> 
>>> I am taking a look at your patch, but please bear with me for another day or two. I am not yet convinced that mingling C++ and ObjC formatting that closely is a wise decision. I think we might need something that clearly separates the different modes. And you touch a lot of code that I intended to refactor into something halfway sane this week. I will take your patch into consideration when doing so, but it might need some changes afterwards.
>> 
>> If we're going to distinguish the modes, we need to do so syntactically. Objective-C++ is a very popular dialect; we can't simply rely on extrinsic knowledge of whether we're dealing with Objective-C or C++ to make these decisions.
>> 
>> I am not sure I fully understand this. We are currently relying on a Lexer which in turn requires LangOptions to create the correct tokens. Same for the identifier table we use to split raw_identifiers into identifiers and keywords. Are you saying the formatter should not capitalize on this knowledge of the input token stream?
> 
> Oh, it should certainly capitalize on this knowledge. My concern is that, when you mentioned that we might need something that "clearly separates the different modes", you were thinking of Objective-C and C++ as independent languages that aren't used together. Fortunately, we can tell syntactically whether we're in an Objective-C method declaration fairly easily: they start with + or -, almost always in the first column, so if it would be better to go down a different code-formatting path where the rules for spacing around (/)/: are different, we could do that instead.

Right. My original formatter  patch was made to distinguish an objc method declaration this way. We can do for other decls easily as all objc specific decls start with @somename if we have to.

- Fariborz

> 
> 	- Doug
> 

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


More information about the cfe-commits mailing list