[all-commits] [llvm/llvm-project] 8a3de1: [clang-format] Disallow templates to be followed b...

Emilia Dreamer via All-commits all-commits at lists.llvm.org
Thu Jan 26 17:57:37 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8a3de13573bdeaee13ec959fa2af0d11f21f5f00
      https://github.com/llvm/llvm-project/commit/8a3de13573bdeaee13ec959fa2af0d11f21f5f00
  Author: Emilia Dreamer <emilia at rymiel.space>
  Date:   2023-01-27 (Fri, 27 Jan 2023)

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

  Log Message:
  -----------
  [clang-format] Disallow templates to be followed by literal

There should not be any cases where the angle brackets of template
parameters are directly followed by a literal. It is more likely that a
comparison is taking place instead.

This patch makes the TokenAnnotator prefer to annotate < and > as
operators when directly followed by a literal. A similar check already
exists for literals directly *before* potential template args.

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

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay

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




More information about the All-commits mailing list