[PATCH] D35847: clang-format: Fix left pointer alignment after delctype/typeof

Krasimir Georgiev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 5 08:14:18 PDT 2017


krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

Looks good! Please reformat the newly added code blocks with `clang-format` before submitting.



================
Comment at: lib/Format/TokenAnnotator.cpp:1402
+      FormatToken *TokenBeforeMatchingParen =
+        PrevToken->MatchingParen->getPreviousNonComment();
+      if (TokenBeforeMatchingParen &&
----------------
Please reformat this block with `clang-format`: `PrevToken` gets indented by two more columns to the right.


================
Comment at: lib/Format/TokenAnnotator.cpp:2212
+    if (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) {
+      if (!Left.MatchingParen)
+        return true;
----------------
Pleasereformat this block with `clang-format`: when I run it, it produces:
```
  if (Right.is(TT_PointerOrReference)) {
    if (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) {
      if (!Left.MatchingParen)
        return true;
      FormatToken *TokenBeforeMatchingParen =
          Left.MatchingParen->getPreviousNonComment();
      if (!TokenBeforeMatchingParen ||
          !TokenBeforeMatchingParen->isOneOf(tok::kw_typeof, tok::kw_decltype))
        return true;
    }
    return (Left.Tok.isLiteral() ||
            (Left.is(tok::kw_const) && Left.Previous &&
             Left.Previous->is(tok::r_paren)) ||
            (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&
             (Style.PointerAlignment != FormatStyle::PAS_Left ||
              (Line.IsMultiVariableDeclStmt &&
               (Left.NestingLevel == 0 ||
                (Left.NestingLevel == 1 && Line.First->is(tok::kw_for)))))));
  }
```


https://reviews.llvm.org/D35847





More information about the cfe-commits mailing list