[all-commits] [llvm/llvm-project] 791637: [clang-format] Don't allow casts in front of ampam...

Emilia Kond via All-commits all-commits at lists.llvm.org
Thu Jan 11 17:47:49 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 791637e78236541a871f9474e0c8918354ca310f
      https://github.com/llvm/llvm-project/commit/791637e78236541a871f9474e0c8918354ca310f
  Author: Emilia Kond <emilia at rymiel.space>
  Date:   2024-01-12 (Fri, 12 Jan 2024)

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

  Log Message:
  -----------
  [clang-format] Don't allow casts in front of ampamp (#77704)

clang-format performs a heuristic to see if a right parenthesis is the
parenthesis of a cast expression. This check never looked ahead to see
if the next token is an ampamp && token. This resulted in the paren
being set as an CastRParen, and the following ampamp got annotated as an
UnaryOperator!

Since && can never be a unary operator is standard C++, this patch
forbids the right paren from ever becoming a cast.

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




More information about the All-commits mailing list