[PATCH] D28462: clang-format: Add new style option AlignConsecutiveMacros

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 29 07:28:07 PST 2019


MyDeveloperDay added a comment.

I checked this out and built this and it works really well. The thing I really like is that it helps to format Windows resource include files e.g. 'Resource.h'   better than before.

Which changes the current clang-formatted version

  #define IDD_AAAAAAAAAAAAAAAAAAAA 101
  #define IDS_BBBBBBBBBBBBBBB 101
  #define IDR_CCCCCCCCCCCCCCC 102
  #define IDB_DDDDDDDDDDDDDDDDDDDDDDDDDDDD 103
  #define IDS_EEEEEEEEEEEEEEEEEE 104
  #define IDR_FFFFFFFFFFFFFFFFFFFFFFFFFFFF 106
  #define IDD_GGGGGGGGGGGGGGGGGGGGGGGGGGGGGG 107
  #define IDD_HHHHHHHHHHHHHHHHHHHHHHHHHHHHH 108
  #define IDS_IIIIIIIIIIIIIIIIIIIII 111
  #define IDS_JJJJJJJJJJJJJJJJJJJJJJJJ 112
  #define IDS_KKKKKKKKKKKKKKKKKKK 114
  #define IDD_LLLLLLLLLLLLLLLL 115

to

  #define IDD_AAAAAAAAAAAAAAAAAAAA           101
  #define IDS_BBBBBBBBBBBBBBB                101
  #define IDR_CCCCCCCCCCCCCCC                102
  #define IDB_DDDDDDDDDDDDDDDDDDDDDDDDDDDD   103
  #define IDS_EEEEEEEEEEEEEEEEEE             104
  #define IDR_FFFFFFFFFFFFFFFFFFFFFFFFFFFF   106
  #define IDD_GGGGGGGGGGGGGGGGGGGGGGGGGGGGGG 107
  #define IDD_HHHHHHHHHHHHHHHHHHHHHHHHHHHHH  108
  #define IDS_IIIIIIIIIIIIIIIIIIIII          111
  #define IDS_JJJJJJJJJJJJJJJJJJJJJJJJ       112
  #define IDS_KKKKKKKKKKKKKKKKKKK            114
  #define IDD_LLLLLLLLLLLLLLLL               115

But alas it will still fight with Visual Studio which wants to align them with its 40 characters or 1+ more than the #define length strategy (e.g.)

  #define IDD_AAAAAAAAAAAAAAAAAAAA        101
  #define IDS_BBBBBBBBBBBBBBB             101
  #define IDR_CCCCCCCCCCCCCCC             102
  #define IDB_DDDDDDDDDDDDDDDDDDDDDDDDDDDD 103
  #define IDS_EEEEEEEEEEEEEEEEEE          104
  #define IDR_FFFFFFFFFFFFFFFFFFFFFFFFFFFF 106
  #define IDD_GGGGGGGGGGGGGGGGGGGGGGGGGGGGGG 107
  #define IDD_HHHHHHHHHHHHHHHHHHHHHHHHHHHHH 108
  #define IDS_IIIIIIIIIIIIIIIIIIIII       111
  #define IDS_JJJJJJJJJJJJJJJJJJJJJJJJ    112
  #define IDS_KKKKKKKKKKKKKKKKKKK         114
  #define IDD_LLLLLLLLLLLLLLLL            115

I don't want to suggest anything that would block this patch going in, ( because I know people have been waiting for it for a long time) , but ultimately I wonder if people may suggest having different macro alignment strategies and options later on.

Maybe if AlignConsecutiveMacros was an enumeration rather than just a Boolean (even if its only had None,Aligned for now)  it might allow someone to more easily add a new strategy later on without breaking compatibility.

Apart form that I think its great, and thank you for taking the mantle.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D28462/new/

https://reviews.llvm.org/D28462





More information about the cfe-commits mailing list