|
13 | 13 | //===----------------------------------------------------------------------===//
|
14 | 14 |
|
15 | 15 | #include "TokenAnnotator.h"
|
| 16 | +#include "FormatToken.h" |
16 | 17 | #include "clang/Basic/SourceManager.h"
|
17 | 18 | #include "llvm/ADT/SmallPtrSet.h"
|
18 | 19 | #include "llvm/Support/Debug.h"
|
@@ -440,25 +441,24 @@ class AnnotatingParser {
|
440 | 441 | Contexts.back().InCSharpAttributeSpecifier;
|
441 | 442 |
|
442 | 443 | bool InsideInlineASM = Line.startsWith(tok::kw_asm);
|
| 444 | + bool IsCppStructuredBinding = Left->isCppStructuredBinding(Style); |
443 | 445 | bool StartsObjCMethodExpr =
|
444 |
| - !InsideInlineASM && !CppArrayTemplates && Style.isCpp() && |
445 |
| - !IsCpp11AttributeSpecifier && Contexts.back().CanBeExpression && |
446 |
| - Left->isNot(TT_LambdaLSquare) && |
| 446 | + !IsCppStructuredBinding && !InsideInlineASM && !CppArrayTemplates && |
| 447 | + Style.isCpp() && !IsCpp11AttributeSpecifier && |
| 448 | + Contexts.back().CanBeExpression && Left->isNot(TT_LambdaLSquare) && |
447 | 449 | !CurrentToken->isOneOf(tok::l_brace, tok::r_square) &&
|
448 | 450 | (!Parent ||
|
449 | 451 | Parent->isOneOf(tok::colon, tok::l_square, tok::l_paren,
|
450 | 452 | tok::kw_return, tok::kw_throw) ||
|
451 | 453 | Parent->isUnaryOperator() ||
|
452 | 454 | // FIXME(bug 36976): ObjC return types shouldn't use TT_CastRParen.
|
453 | 455 | Parent->isOneOf(TT_ObjCForIn, TT_CastRParen) ||
|
454 |
| - // for (auto && [A,B] : C) && structure binding seen as ObjCMethodExpr |
455 |
| - (Parent->isNot(tok::ampamp) && |
456 |
| - getBinOpPrecedence(Parent->Tok.getKind(), true, true) > |
457 |
| - prec::Unknown)); |
| 456 | + (getBinOpPrecedence(Parent->Tok.getKind(), true, true) > |
| 457 | + prec::Unknown)); |
458 | 458 | bool ColonFound = false;
|
459 | 459 |
|
460 | 460 | unsigned BindingIncrease = 1;
|
461 |
| - if (Left->isCppStructuredBinding(Style)) { |
| 461 | + if (IsCppStructuredBinding) { |
462 | 462 | Left->Type = TT_StructuredBindingLSquare;
|
463 | 463 | } else if (Left->is(TT_Unknown)) {
|
464 | 464 | if (StartsObjCMethodExpr) {
|
|
0 commit comments