]> granicus.if.org Git - clang/commit
clang-format: better handle statement macros
authorFrancois Ferrand <thetypz@gmail.com>
Tue, 2 Oct 2018 16:37:51 +0000 (16:37 +0000)
committerFrancois Ferrand <thetypz@gmail.com>
Tue, 2 Oct 2018 16:37:51 +0000 (16:37 +0000)
commitc59e1fef138b0ad6abda3b6b3160429b288ddae1
treef5db3ad624f9706ee04a412bfa29a7c2e85faf5e
parent4b113a837e49832df9559d5d032d4cc3903d69a9
clang-format: better handle statement macros

Summary:
Some macros are used in the body of function, and actually contain the trailing semicolon: they should thus be automatically followed by a new line, and not get merged with the next line. This is for example the case with Qt's Q_UNUSED macro:

  void foo(int a, int b) {
    Q_UNUSED(a)
    return b;
  }

This patch deals with these cases by introducing a new option to specify list of statement macros. This re-uses the system already in place for foreach macros, to ensure there is no impact on performance.

Reviewers: krasimir, djasper, klimek

Reviewed By: krasimir

Subscribers: acoomans, mgrang, alexfh, klimek, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343602 91177308-0d34-0410-b5e6-96231b3b80d8
docs/ClangFormatStyleOptions.rst
include/clang/Format/Format.h
lib/Format/Format.cpp
lib/Format/FormatToken.h
lib/Format/FormatTokenLexer.cpp
lib/Format/FormatTokenLexer.h
lib/Format/UnwrappedLineParser.cpp
lib/Format/UnwrappedLineParser.h
unittests/Format/FormatTest.cpp