[all-commits] [llvm/llvm-project] eb85e9: clang-format: Fix pointer alignment for overloaded...

Hans via All-commits all-commits at lists.llvm.org
Fri Mar 27 02:54:14 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: eb85e90350e93a64279139e7eca9ca40c8fbf5eb
      https://github.com/llvm/llvm-project/commit/eb85e90350e93a64279139e7eca9ca40c8fbf5eb
  Author: Hans Wennborg <hans at chromium.org>
  Date:   2020-03-27 (Fri, 27 Mar 2020)

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

  Log Message:
  -----------
  clang-format: Fix pointer alignment for overloaded operators (PR45107)

This fixes a regression from D69573 which broke the following example:

  $ echo 'operator C<T>*();' | bin/clang-format --style=Chromium
  operator C<T> *();

(There should be no space before the asterisk.)

It seems the problem is in TokenAnnotator::spaceRequiredBetween(),
which only looked at the token to the left of the * to see if it was a
type or not. That code only handled simple types or identifiers, not
templates or qualified types. This patch addresses that.

Differential revision: https://reviews.llvm.org/D76850




More information about the All-commits mailing list