[PATCH] D33440: clang-format: better handle statement macros

Francois Ferrand via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 9 05:00:47 PST 2017

Typz added a comment.

In https://reviews.llvm.org/D33440#920205, @djasper wrote:

> Out of curiosity, will this be able to fix the two situations that you get for python extension?
>  There, you usually have a PyObject_HEAD with out semicolon in a struct and than a PyObject_HEAD_INIT(..) in a braced init list. More info:
>  http://starship.python.net/crew/mwh/toext/node20.html

`PyObject_HEAD` is defined (by defaut) as:

  Py_ssize_t ob_refcnt;
  PyTypeObject *ob_type;

so declaring it as a statement macro should allow clang-format to process it correctly. (though this is a variable-like macro, so I need to check if this case is supported)

`PyObject_HEAD_INIT` ends with a comma, which is not supported yet. We would need to add another kind of macro to support that case.


More information about the cfe-commits mailing list