klimek added inline comments.

================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2467-2470
+  if (Line.InPPDirective && Right.is(tok::l_paren) &&
+      !Left.is(tok::identifier) && Left.Previous &&
+      Left.Previous->is(tok::identifier) && Left.Previous->Previous &&
+      Left.Previous->Previous->is(tok::hash))
----------------
MyDeveloperDay wrote:
> klimek wrote:
> > MyDeveloperDay wrote:
> > > klimek wrote:
> > > > owenpan wrote:
> > > > > I think it can be more precise and simplified to something like this:
> > > > > ```
> > > > >   if (Left.Previous && Left.Previous->is(tok::pp_define) &&
> > > > >       Left.isNot(tok::identifier) && Right.is(tok::l_paren))
> > > > > ```
> > > > Why don't we have the same problem for identifier? Is that already 
> > > > solved and the problem is that this is a keyword redefinition?
> > > > 
> > > Yes the identifier seems to work ok, but when its a keyword redfinition 
> > > the identifier is replaced with the token for the keyword i.e. 
> > > tok::kw_true or tok::kw_false
> > And the idea is that for non-ID
> > #define true(x) x
> > won't work anyway? (otherwise this patch would be incorrect, right?)
> > 
> > Have you looked at where we detect the diff between
> > #define a(x) x
> > and
> > #define a (x)
> > in the identifier case and looked we could add common keyword macro cases 
> > there?
> I see what you mean, this path will reformat the false #define incorrectly
> 
> ```
> #define true ((foo)1)
> #define false(x) x
> 
> ```
> will be transformed to
> 
> ```
> #define true ((foo)1)
> #define false (x) x
> ```
> 
> 
> 
> 
Exactly.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60362/new/

https://reviews.llvm.org/D60362



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to