summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp5
-rw-r--r--clang/unittests/Format/FormatTest.cpp1
2 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 017a8404ba4..4c6be9f98c1 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -853,8 +853,9 @@ private:
FormatToken *LeftOfParens = nullptr;
if (Tok.MatchingParen)
LeftOfParens = Tok.MatchingParen->getPreviousNonComment();
- if (LeftOfParens && LeftOfParens->is(tok::r_paren))
- return false;
+ if (LeftOfParens && LeftOfParens->is(tok::r_paren) &&
+ LeftOfParens->MatchingParen)
+ LeftOfParens = LeftOfParens->MatchingParen->Previous;
if (LeftOfParens && LeftOfParens->is(tok::r_square) &&
LeftOfParens->MatchingParen &&
LeftOfParens->MatchingParen->Type == TT_LambdaLSquare)
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 70b02ebc801..14c221bad95 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -5057,6 +5057,7 @@ TEST_F(FormatTest, FormatsCasts) {
verifyFormat("my_int a = (my_int *)1;");
verifyFormat("my_int a = (const my_int)-1;");
verifyFormat("my_int a = (const my_int *)-1;");
+ verifyFormat("my_int a = (my_int)(my_int)-1;");
// FIXME: single value wrapped with paren will be treated as cast.
verifyFormat("void f(int i = (kValue)*kMask) {}");
OpenPOWER on IntegriCloud