diff options
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 4 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index ff0af5a08c5..14d164e2ae7 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -992,6 +992,10 @@ private: (InTemplateArgument && NextToken->Tok.isAnyIdentifier())) return TT_BinaryOperator; + // "&&(" is quite unlikely to be two successive unary "&". + if (Tok.is(tok::ampamp) && NextToken && NextToken->is(tok::l_paren)) + return TT_BinaryOperator; + // This catches some cases where evaluation order is used as control flow: // aaa && aaa->f(); const FormatToken *NextNextToken = NextToken->getNextNonComment(); diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 37bd5178674..163f0838c9e 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -5030,6 +5030,11 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyFormat("foo<b && false>();"); verifyFormat("foo<b & 1>();"); verifyFormat("decltype(*::std::declval<const T &>()) void F();"); + verifyFormat( + "template <class T, class = typename std::enable_if<\n" + " std::is_integral<T>::value &&\n" + " (sizeof(T) > 1 || sizeof(T) < 8)>::type>\n" + "void F();"); verifyIndependentOfContext("MACRO(int *i);"); verifyIndependentOfContext("MACRO(auto *a);"); |

