This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Allow configuring list of function-like macros that resolve to a type
ClosedPublic

Authored by dextero on Jan 24 2019, 1:21 PM.

Details

Summary

Adds a TypenameMacros configuration option that causes certain identifiers to be handled in a way similar to typeof().

This is enough to:

  • Prevent misinterpreting declarations of pointers to such types as expressions (STACK_OF(int) * foo -> STACK_OF(int) *foo),
  • Avoid surprising line breaks in variable/struct field declarations (STACK_OF(int)\nfoo; -> STACK_OF(int) foo;, see https://bugs.llvm.org/show_bug.cgi?id=30353).

Diff Detail

Repository
rC Clang

Event Timeline

dextero created this revision.Jan 24 2019, 1:21 PM
Typz added a comment.May 22 2019, 1:31 PM

Regarding variable/setting names, one issue I see is that these macros are not really type names IMO : the macro name is just part of the type (like a template), and its invocation is a type declaration. So maybe renaming to Typedecl or something like this would be slightly more representative.

Other than this, LGTM.

docs/ClangFormatStyleOptions.rst
1371

"type declarations" may be clearer?

Herald added a project: Restricted Project. · View Herald TranscriptMay 22 2019, 1:31 PM
Typz accepted this revision.May 22 2019, 1:34 PM

Actually, looking at all the other options, the same is true for all other macro kind of macros (NamespaceMacros...).

This revision is now accepted and ready to land.May 22 2019, 1:34 PM
dextero updated this revision to Diff 201393.May 24 2019, 11:26 PM
dextero marked an inline comment as done.
  • [clang-format] Make documentation a bit clearer
  • Rebased onto recent master

@Typz: thank you for the review! I don't have push access to the repository though. Could you commit this diff, or point me to someone I should ask instead?

dextero updated this revision to Diff 201395.May 25 2019, 12:22 AM
  • [clang-format] Change "types" -> "type declarations" in Format.h
This revision was automatically updated to reflect the committed changes.