[PATCH] D93776: [clang-format] Add StatementAttributeLikeMacros option

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 23 13:16:47 PST 2020


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

This allows to ignore for example Qts emit when
AlignConsecutiveDeclarations is set, otherwise it is parsed as a type
and it results in some misformating:

  unsigned char MyChar = 'x';
  emit          signal(MyChar);

For those who don't know what emit (or Q_EMIT) is in Qt: A macro which is defined as nothing. But it is often used to display that a function call is a signal which is then "emitted". Technically emit could stand anywhere in the code, but if used right it is only before a signal emission.

I added `Q_EMIT` unconditionally because this is also done with `Q_UNUSED` and `QT_REQUIRE_VERSION`. I did not add `emit` because it's all lower case and could be used as actual identifier in non Qt code, or even in Qt code when the Qt keywords are deactivated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93776

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93776.313606.patch
Type: text/x-patch
Size: 8942 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201223/1285301c/attachment-0001.bin>


More information about the cfe-commits mailing list