summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-01-04 20:46:38 +0000
committerDaniel Jasper <djasper@google.com>2013-01-04 20:46:38 +0000
commit3c2557d0dd195652c5488636e214a32203b73a6e (patch)
tree30e2972fb37e2a569f02b306419680b36fc33287 /clang
parent66748e93e2cc7b5799b81188126d088ce7c22f74 (diff)
downloadbcm5719-llvm-3c2557d0dd195652c5488636e214a32203b73a6e.tar.gz
bcm5719-llvm-3c2557d0dd195652c5488636e214a32203b73a6e.zip
Correctly format dereference and address of in array parameters.
Before: InvalidRegions[ &R] = 0; After: InvalidRegions[&R] = 0; This fixes llvm.org/PR14793 llvm-svn: 171522
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/Format.cpp5
-rw-r--r--clang/unittests/Format/FormatTest.cpp2
2 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 69020c65750..7f40e35e1d6 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -878,8 +878,9 @@ private:
const FormatToken &PrevToken = Line.Tokens[Index - 1];
const FormatToken &NextToken = Line.Tokens[Index + 1];
- if (PrevToken.Tok.is(tok::l_paren) || PrevToken.Tok.is(tok::comma) ||
- PrevToken.Tok.is(tok::kw_return) || PrevToken.Tok.is(tok::colon) ||
+ if (PrevToken.Tok.is(tok::l_paren) || PrevToken.Tok.is(tok::l_square) ||
+ PrevToken.Tok.is(tok::comma) || PrevToken.Tok.is(tok::kw_return) ||
+ PrevToken.Tok.is(tok::colon) ||
Annotations[Index - 1].Type == TokenAnnotation::TT_BinaryOperator)
return TokenAnnotation::TT_UnaryOperator;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 8eadb545f77..c17bc0d76b3 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -768,6 +768,8 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
verifyFormat("a * ++b;");
verifyFormat("a * --b;");
+ verifyFormat("InvalidRegions[*R] = 0;");
+
// FIXME: Is this desired for LLVM? Fix if not.
verifyFormat("A<int *> a;");
verifyFormat("A<int **> a;");
OpenPOWER on IntegriCloud