aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp5
-rw-r--r--clang/unittests/Format/TokenAnnotatorTest.cpp7
2 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index ea81141..3e0599e 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2535,8 +2535,9 @@ private:
return TT_BinaryOperator;
if (!NextToken ||
- NextToken->isOneOf(tok::arrow, tok::equal, tok::kw_noexcept, tok::comma,
- tok::r_paren, TT_RequiresClause) ||
+ NextToken->isOneOf(tok::arrow, tok::equal, tok::comma, tok::r_paren,
+ TT_RequiresClause) ||
+ (NextToken->is(tok::kw_noexcept) && !IsExpression) ||
NextToken->canBePointerOrReferenceQualifier() ||
(NextToken->is(tok::l_brace) && !NextToken->getNextNonComment())) {
return TT_PointerOrReference;
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 467ade9..66bfd7f 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -273,6 +273,13 @@ TEST_F(TokenAnnotatorTest, UnderstandsUsesOfStarAndAmp) {
ASSERT_EQ(Tokens.size(), 19u) << Tokens;
EXPECT_TOKEN(Tokens[5], tok::ampamp, TT_BinaryOperator);
+ Tokens =
+ annotate("auto foo() noexcept(noexcept(bar()) && "
+ "trait<std::decay_t<decltype(bar())>> && noexcept(baz())) {}");
+ EXPECT_EQ(Tokens.size(), 38u) << Tokens;
+ EXPECT_TOKEN(Tokens[12], tok::ampamp, TT_BinaryOperator);
+ EXPECT_TOKEN(Tokens[27], tok::ampamp, TT_BinaryOperator);
+
FormatStyle Style = getLLVMStyle();
Style.TypeNames.push_back("MYI");
Tokens = annotate("if (MYI *p{nullptr})", Style);