[PATCH] D133954: [clang-format] Fix template arguments in macros

sstwcw via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 15 09:39:51 PDT 2022


sstwcw created this revision.
sstwcw added reviewers: HazardyKnusperkeks, MyDeveloperDay, curdeius, owenpan.
Herald added a project: All.
sstwcw requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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

old

  #define FOO(typeName, realClass)                               \
    {                                                            \
  #typeName, foo < FooType>(new foo <realClass>(#typeName))  \
    }

new

  #define FOO(typeName, realClass)                                \
    { #typeName, foo<FooType>(new foo<realClass>(#typeName)) }

Previously, when an UnwrappedLine began with a hash in a macro
definition, the program incorrectly assumed the line was a preprocessor
directive.  It should be stringification.

The rule in spaceRequiredBefore was added in 8b5297117b.  Its purpose is
to add a space in an include directive.  It also added a space to a
template opener when the line began with a stringification hash.  So we
changed it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133954

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/TokenAnnotator.h
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133954.460446.patch
Type: text/x-patch
Size: 5346 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220915/c97e5f16/attachment.bin>


More information about the cfe-commits mailing list