diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/Format/TokenAnnotator.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/contrib/llvm-project/clang/lib/Format/TokenAnnotator.cpp b/contrib/llvm-project/clang/lib/Format/TokenAnnotator.cpp index 98c012994f45..5991cf23d5dc 100644 --- a/contrib/llvm-project/clang/lib/Format/TokenAnnotator.cpp +++ b/contrib/llvm-project/clang/lib/Format/TokenAnnotator.cpp @@ -999,7 +999,8 @@ private: FormatToken *Prev = Tok->getPreviousNonComment(); if (!Prev) break; - if (Prev->isOneOf(tok::r_paren, tok::kw_noexcept)) { + if (Prev->isOneOf(tok::r_paren, tok::kw_noexcept) || + Prev->ClosesRequiresClause) { Tok->setType(TT_CtorInitializerColon); } else if (Prev->is(tok::kw_try)) { // Member initializer list within function try block. @@ -2317,7 +2318,15 @@ private: // After right braces, star tokens are likely to be pointers to struct, // union, or class. // struct {} *ptr; - if (PrevToken->is(tok::r_brace) && Tok.is(tok::star)) + // This by itself is not sufficient to distinguish from multiplication + // following a brace-initialized expression, as in: + // int i = int{42} * 2; + // In the struct case, the part of the struct declaration until the `{` and + // the `}` are put on separate unwrapped lines; in the brace-initialized + // case, the matching `{` is on the same unwrapped line, so check for the + // presence of the matching brace to distinguish between those. + if (PrevToken->is(tok::r_brace) && Tok.is(tok::star) && + !PrevToken->MatchingParen) return TT_PointerOrReference; // For "} &&" |