r219119 - clang-format: If in doubt, assume '+' is a binary operator.
Daniel Jasper
djasper at google.com
Mon Oct 6 12:47:18 PDT 2014
Not sure what you are getting at.. It is obviously wrong, but this is about
probabilities..
On Oct 6, 2014 9:32 PM, "Justin Bogner" <mail at justinbogner.com> wrote:
> Daniel Jasper <djasper at google.com> writes:
> > Author: djasper
> > Date: Mon Oct 6 08:16:43 2014
> > New Revision: 219119
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=219119&view=rev
> > Log:
> > clang-format: If in doubt, assume '+' is a binary operator.
> >
> > Before:
> > #define LENGTH(x, y) (x) - (y)+1
> >
> > After:
> > #define LENGTH(x, y) (x) - (y) + 1
>
> What about this one?
>
> #define LENGTH(x, y) (x) - (y) - 1
>
> > Modified:
> > cfe/trunk/lib/Format/TokenAnnotator.cpp
> > cfe/trunk/unittests/Format/FormatTest.cpp
> >
> > Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=219119&r1=219118&r2=219119&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
> > +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Oct 6 08:16:43 2014
> > @@ -902,8 +902,9 @@ private:
> > if (Prev && Tok.Next && Tok.Next->Next) {
> > bool NextIsUnary = Tok.Next->isUnaryOperator() ||
> > Tok.Next->isOneOf(tok::amp, tok::star);
> > - IsCast = NextIsUnary && Tok.Next->Next->isOneOf(
> > - tok::identifier,
> tok::numeric_constant);
> > + IsCast =
> > + NextIsUnary && !Tok.Next->is(tok::plus) &&
> > + Tok.Next->Next->isOneOf(tok::identifier,
> tok::numeric_constant);
> > }
> >
> > for (; Prev != Tok.MatchingParen; Prev = Prev->Previous) {
> >
> > Modified: cfe/trunk/unittests/Format/FormatTest.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=219119&r1=219118&r2=219119&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/unittests/Format/FormatTest.cpp (original)
> > +++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Oct 6 08:16:43 2014
> > @@ -5116,6 +5116,7 @@ TEST_F(FormatTest, FormatsCasts) {
> > verifyFormat("my_int a = (my_int)sizeof(int);");
> > verifyFormat("return (my_int)aaa;");
> > verifyFormat("#define x ((int)-1)");
> > + verifyFormat("#define LENGTH(x, y) (x) - (y) + 1");
> > verifyFormat("#define p(q) ((int *)&q)");
> > verifyFormat("fn(a)(b) + 1;");
> >
> > @@ -5123,7 +5124,7 @@ TEST_F(FormatTest, FormatsCasts) {
> > verifyFormat("void f() { return P ? (my_int)*P : (my_int)0; }");
> > verifyFormat("my_int a = (my_int)~0;");
> > verifyFormat("my_int a = (my_int)++a;");
> > - verifyFormat("my_int a = (my_int)+2;");
> > + verifyFormat("my_int a = (my_int)-2;");
> > verifyFormat("my_int a = (my_int)1;");
> > verifyFormat("my_int a = (my_int *)1;");
> > verifyFormat("my_int a = (const my_int)-1;");
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141006/7b294b84/attachment.html>
More information about the cfe-commits
mailing list