r214070 - clang-format: Fix unary operator recognition.
Daniel Jasper
djasper at google.com
Mon Jul 28 05:08:16 PDT 2014
Author: djasper
Date: Mon Jul 28 07:08:16 2014
New Revision: 214070
URL: http://llvm.org/viewvc/llvm-project?rev=214070&view=rev
Log:
clang-format: Fix unary operator recognition.
Before:
int x = ~ * p;
After:
int x = ~*p;
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=214070&r1=214069&r2=214070&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jul 28 07:08:16 2014
@@ -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;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=214070&r1=214069&r2=214070&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jul 28 07:08:16 2014
@@ -4766,6 +4766,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
verifyIndependentOfContext("typedef void (*f)(int *a);");
verifyIndependentOfContext("int i{a * b};");
verifyIndependentOfContext("aaa && aaa->f();");
+ verifyIndependentOfContext("int x = ~*p;");
verifyIndependentOfContext("InvalidRegions[*R] = 0;");
More information about the cfe-commits
mailing list