[PATCH] D116290: [clang-format] Add enforcement of consistent `class`/typename` keyword for template arguments

Adrian Vogelsgesang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 26 13:19:11 PST 2021


avogelsgesang created this revision.
Herald added a subscriber: mgorny.
avogelsgesang requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Template argument types can be introduced using either the `class` or
the `typename` argument. While there are good arguments for both styles,
usually one wants to use one style consistently across a project.

This commit adds a `TemplateArgumentKeyword` option which can be used
to format all template arguments consistently using either the `class`
or the `typename` argument.

Implementationwise, it closely follows in the footsteps of D69764 <https://reviews.llvm.org/D69764>, i.e.
it adds a new `TemplateArgumentKeywordFixer` pass which creates the
appropriate replacements.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116290

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/CMakeLists.txt
  clang/lib/Format/Format.cpp
  clang/lib/Format/TemplateArgumentKeywordFixer.cpp
  clang/lib/Format/TemplateArgumentKeywordFixer.h
  clang/unittests/Format/CMakeLists.txt
  clang/unittests/Format/TemplateArgumentKeywordFixerTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116290.396236.patch
Type: text/x-patch
Size: 21508 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211226/1e731e45/attachment-0001.bin>


More information about the cfe-commits mailing list