[all-commits] [llvm/llvm-project] 1e7cc7: [clang-format] Allow to set token types final

kuzkry via All-commits all-commits at lists.llvm.org
Tue Mar 1 12:55:48 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1e7cc72ac91d524da80ec6e144dce925a27090fc
      https://github.com/llvm/llvm-project/commit/1e7cc72ac91d524da80ec6e144dce925a27090fc
  Author: Björn Schäpers <bjoern at hazardy.de>
  Date:   2022-03-01 (Tue, 01 Mar 2022)

  Changed paths:
    M clang/lib/Format/FormatToken.h
    M clang/lib/Format/TokenAnnotator.cpp
    M clang/lib/Format/UnwrappedLineParser.cpp
    M clang/unittests/Format/TokenAnnotatorTest.cpp

  Log Message:
  -----------
  [clang-format] Allow to set token types final

We have a little problem. TokenAnnotator::resetTokenMetadata() resets
the type, except for a (growing) whitelist. This is because the
TokenAnnotator visits some tokens multiple times. E.g. trying to
identify if a < is an operator less or a template opener. And in some
runs, which are bascially "reverted" the types are reset.

On the other hand, if the parser does already know the type, it should
be able to set it, without it being reset. So we introduce the ability
to set a type and make that final.

Differential Revision: https://reviews.llvm.org/D120511


  Commit: 78ac86701801663d700919e543f4e1129982993d
      https://github.com/llvm/llvm-project/commit/78ac86701801663d700919e543f4e1129982993d
  Author: Björn Schäpers <bjoern at hazardy.de>
  Date:   2022-03-01 (Tue, 01 Mar 2022)

  Changed paths:
    M clang/lib/Format/UnwrappedLineParser.cpp
    M clang/unittests/Format/FormatTest.cpp

  Log Message:
  -----------
  [clang-format] Fix requires related crash

In the presence of pp branches we parse the token stream multiple times.
Thus the token already has the type set. It's best just not to assert on
any type in the parser.

Fixes https://github.com/llvm/llvm-project/issues/54019

Differential Revision: https://reviews.llvm.org/D120512


  Commit: d6daca21738aed64837b825c32d4f1b4f54cec04
      https://github.com/llvm/llvm-project/commit/d6daca21738aed64837b825c32d4f1b4f54cec04
  Author: Björn Schäpers <bjoern at hazardy.de>
  Date:   2022-03-01 (Tue, 01 Mar 2022)

  Changed paths:
    M clang/lib/Format/TokenAnnotator.cpp
    M clang/unittests/Format/FormatTest.cpp

  Log Message:
  -----------
  [clang-format] Fix BreakBeforeBinaryOperators with TemplateCloser on the lhs

In the presence of pp branches we parse the token stream multiple times.
Thus the token already has the type set. It's best just not to assert on
any type in the parser.

Fixes https://github.com/llvm/llvm-project/issues/54019

Differential Revision: https://reviews.llvm.org/D120621


  Commit: 5e51ace4e86ddaec34b5641f28a0ecbb17c8b1f3
      https://github.com/llvm/llvm-project/commit/5e51ace4e86ddaec34b5641f28a0ecbb17c8b1f3
  Author: Krystian Kuzniarek <krystian.kuzniarek at gmail.com>
  Date:   2022-03-01 (Tue, 01 Mar 2022)

  Changed paths:
    M clang/docs/ClangFormatStyleOptions.rst
    M clang/include/clang/Format/Format.h

  Log Message:
  -----------
  [clang-format][docs] Fix a bad comment

Follow up to 8f310d1967c20d348c617af3a30999031c71fee0.

Differential Revision: https://reviews.llvm.org/D120618


Compare: https://github.com/llvm/llvm-project/compare/f642436cc213...5e51ace4e86d


More information about the All-commits mailing list