[PATCH] clang-format: Add Block{Begin,End}Macros option

Birunthan Mohanathas birunthan at mohanathas.com
Tue Jun 30 08:33:39 PDT 2015


Hi djasper,

This adds the BlockBeginMacros and BlockEndMacros options that can be
used to make certain macros add indent levels similarly to '{' and '}',
respectively.

Mozilla code, for example, uses several macros that begin and end a scope.
Previously, Clang-Format removed the indentation resulting in:

MACRO_BEGIN(...)
MACRO_ENTRY(...)
MACRO_ENTRY(...)
MACRO_END

Now, using e.g. 'BlockBeginMacros: "^[A-Z_]+_BEGIN$"' and
'BlockEndMacros: "^[A-Z_]+_END$"', the result is as expected:

MACRO_BEGIN(...)
  MACRO_ENTRY(...)
  MACRO_ENTRY(...)
MACRO_END

http://reviews.llvm.org/D10840

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTest.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10840.28788.patch
Type: text/x-patch
Size: 7537 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150630/a41aa144/attachment.bin>


More information about the cfe-commits mailing list