[all-commits] [llvm/llvm-project] e864ac: [clang-format] Treats &/&& as reference when follo...

Micah Weston via All-commits all-commits at lists.llvm.org
Sat Nov 12 01:00:28 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e864ac694540342d5e59f59c525c5082f2594fb8
      https://github.com/llvm/llvm-project/commit/e864ac694540342d5e59f59c525c5082f2594fb8
  Author: Micah Weston <micahsweston at gmail.com>
  Date:   2022-11-12 (Sat, 12 Nov 2022)

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

  Log Message:
  -----------
  [clang-format] Treats &/&& as reference when followed by ',' or ')'

Ran into an issue where function declarations inside function
scopes or uses of sizeof inside a function would treat the && in
'sizeof(Type &&)' as a binary operator.

Attempt to fix this by assuming reference when followed by ',' or
')'. Also adds tests for these.

Also hit an edge case in another test that treated "and" the same
as "&&" since it parses as C++. Changed the "and" to "also" so it
is no longer a keyword.

Fixes #58923.

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




More information about the All-commits mailing list