From a0e9d766225efe45cbb00d1f87042f4015bdb9c5 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 28 Jul 2014 12:08:16 +0000 Subject: [PATCH] clang-format: Fix unary operator recognition. Before: int x = ~ * p; After: int x = ~*p; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214070 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 2 +- unittests/Format/FormatTest.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 5f8ce79746..1ef9d1f6fe 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/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/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 1fdbe4d092..6711447c8f 100644 --- a/unittests/Format/FormatTest.cpp +++ b/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;"); -- 2.50.1