[PATCH] D93986: [clang-format] Add the possibility to align assignments spanning empty lines or comments

Lukas Barth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 10 15:05:45 PST 2021


tinloaf added a comment.

In D93986#2489140 <https://reviews.llvm.org/D93986#2489140>, @HazardyKnusperkeks wrote:

> Apart from my inline comment and the pre merge check this is superb. (I will not accept it, until we have reached a conclusion for the documentation.)

Regarding the pre-merge check: it is `clang-format` which failed. My local `clang-format` claims that the code is formatted according to the project's `.clang-format` (`git-clang-format` tells me that there are no modifications), but the `clang-format` on the server seems to disagree. I can of course just apply the supplied patch, but I would like to fix this so that it won't take me two tries in the future. Which version of `clang-format` is running on the build server? I'm running 12.0.0.



================
Comment at: clang/docs/ClangFormatStyleOptions.rst:338
+
+      int aaaa = 12;
+      int b    = 23;
----------------
HazardyKnusperkeks wrote:
> This are now the examples from aligning the assignment. We now know that the rules for the alignments are the same, but someone new to it, just reading the documentation may be puzzled.
> 
> As @MyDeveloperDay said, most likely the script for generation has to be adapted?
> 
> The question here is now doing it now, or in a different change? It should happen before LLVM 12 will be released.
I agree that this is not a good solution. I can probably adapt the doc generation script (have not yet looked at it in depth), but I currently have no good idea how to put the information into the source - i.e., where the dump script should get the info from. Here is an idea, which doesn't strike me as very elegant:

As far as I can tell, the script first takes the documentation block of the defined symbol (e.g., `AlignConsecutiveDeclarations`), and if the type of that symbol is an `enum`, then appends a list of possible enum values together with the documentation block of the respective enum value.

My suggestion would be to introduce some kind of tag into the documentation block of the defined symbol ( `DOC_IGNORE_ENUM` or something?), that, if present, deactivates this behavior and only takes the documentation of the defined symbol. I would then have to hand-code the different possible values and the respective examples into the documentation blocks of `AlignConsecutiveAssignments`, `AlignConsecutiveMacros`, `AlignConsecutiveBitFields` and `AlignConsecutiveDeclarations`. The documentation for `AlignConsecutiveStyle` would be ignored.

Would that be a feasible solution?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93986



More information about the cfe-commits mailing list