summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-01-07 12:19:53 +0000
committerDaniel Jasper <djasper@google.com>2015-01-07 12:19:53 +0000
commit6a9682038f2c155520453973b15f3088f7757331 (patch)
treefee072ba708b7856abc3cf384641cd292846a333
parent06f22f46781cdc42557ae2b67073660f3839b8b6 (diff)
downloadbcm5719-llvm-6a9682038f2c155520453973b15f3088f7757331.tar.gz
bcm5719-llvm-6a9682038f2c155520453973b15f3088f7757331.zip
clang-format: Fix unary operator detection.
Before: ** outparam = 1; After: **outparam = 1; llvm-svn: 225349
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp8
-rw-r--r--clang/unittests/Format/FormatTest.cpp1
2 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 331776c59aa..8966ab2484b 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -741,7 +741,8 @@ private:
void modifyContext(const FormatToken &Current) {
if (Current.getPrecedence() == prec::Assignment &&
- !Line.First->isOneOf(tok::kw_template, tok::kw_using) &&
+ !Line.First->isOneOf(tok::kw_template, tok::kw_using,
+ TT_UnaryOperator) &&
(!Current.Previous || Current.Previous->isNot(tok::kw_operator))) {
Contexts.back().IsExpression = true;
for (FormatToken *Previous = Current.Previous;
@@ -752,11 +753,10 @@ private:
if (!Previous)
break;
}
- if ((Previous->isOneOf(TT_BinaryOperator, TT_UnaryOperator)) &&
+ if (Previous->isOneOf(TT_BinaryOperator, TT_UnaryOperator) &&
Previous->isOneOf(tok::star, tok::amp) && Previous->Previous &&
- Previous->Previous->isNot(tok::equal)) {
+ Previous->Previous->isNot(tok::equal))
Previous->Type = TT_PointerOrReference;
- }
}
} else if (Current.isOneOf(tok::kw_return, tok::kw_throw)) {
Contexts.back().IsExpression = true;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 66835d74b3b..a0f450338b1 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -5164,6 +5164,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaa, *aaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
+ verifyGoogleFormat("**outparam = 1;");
verifyGoogleFormat("int main(int argc, char** argv) {}");
verifyGoogleFormat("A<int*> a;");
verifyGoogleFormat("A<int**> a;");
OpenPOWER on IntegriCloud