From: Daniel Jasper Date: Mon, 28 Jul 2014 12:08:16 +0000 (+0000) Subject: clang-format: Fix unary operator recognition. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2ac3fdfd4af9c3424afa917f0ef6086fbd1008af;p=platform%2Fupstream%2Fllvm.git clang-format: Fix unary operator recognition. Before: int x = ~ * p; After: int x = ~*p; llvm-svn: 214070 --- diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 5f8ce79..1ef9d1f 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -755,7 +755,7 @@ private: Contexts.back().CaretFound = true; } else if (Current.isOneOf(tok::minusminus, tok::plusplus)) { Current.Type = determineIncrementUsage(Current); - } else if (Current.is(tok::exclaim)) { + } else if (Current.isOneOf(tok::exclaim, tok::tilde)) { Current.Type = TT_UnaryOperator; } else if (Current.is(tok::question)) { Current.Type = TT_ConditionalExpr; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 1fdbe4d..6711447 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -4766,6 +4766,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyIndependentOfContext("typedef void (*f)(int *a);"); verifyIndependentOfContext("int i{a * b};"); verifyIndependentOfContext("aaa && aaa->f();"); + verifyIndependentOfContext("int x = ~*p;"); verifyIndependentOfContext("InvalidRegions[*R] = 0;");