This is an archive of the discontinued LLVM Phabricator instance.

[clang-format]AlignConsecutiveAssignments
AbandonedPublic

Authored by owenpan on Aug 7 2018, 12:20 PM.

Details

Summary

Expanding AlignConsecutiveAssignments to compound assignments.

Diff Detail

Repository
rC Clang

Event Timeline

PDoakORNL created this revision.Aug 7 2018, 12:20 PM
PDoakORNL retitled this revision from AlignConsecutiveAssignments to [clang-format]AlignConsecutiveAssignments.Aug 8 2018, 12:28 PM
PDoakORNL added a reviewer: Restricted Project.Aug 8 2018, 1:42 PM

So it's been a week, is there an owner for clang/lib/Format?

Please upload your diffs with full context (use -U99999 when doing the diff) and update them. I don't think there is a code owner for this part but @klimek and @djasper do most reviews to do with clang-format, so you may consider adding them as reviewers.

JonasToth added a subscriber: owenpan.
owenpan requested changes to this revision.Sep 29 2018, 9:46 AM
owenpan added inline comments.
include/clang/Format/Format.h
91–93

These are invalid C++ examples.

lib/Format/WhitespaceManager.cpp
435–451

It would be simpler to just use isOneOf(tok::equal, tok::pipeequal, ...) here.

This revision now requires changes to proceed.Sep 29 2018, 9:46 AM
krasimir added inline comments.Oct 17 2018, 7:17 PM
include/clang/Format/Format.h
85

Please add tests for these. Also it's not clear from these examples how would a block of lines using assigments spanning different number of columns would be alined, as in:

aaa = 1;
bb += 2;
c <<= 3;

vs.

aaa = 1;
bb  += 2;
c   <<= 3;

I think this might deserve discussion by itself before this patch can get in (personally, I'm in favor of the first version where the right hand sides are alined).

kristina resigned from this revision.Oct 17 2018, 7:35 PM

Is anyone still working on this or is a new author needed?

For what's it worth it, I'm in favor of the first version (right hand aligned) for different sized operators.

A matching bug exists at: https://bugs.llvm.org/show_bug.cgi?id=31681

owenpan commandeered this revision.Oct 27 2023, 12:52 PM
owenpan edited reviewers, added: PDoakORNL; removed: owenpan.
This revision now requires review to proceed.Oct 27 2023, 12:52 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 27 2023, 12:52 PM
owenpan abandoned this revision.Oct 27 2023, 12:53 PM

We habe AlignCompound now.

NOTE: Clang-Format Team Automated Review Comment

Your review contains a change to clang/include/clang/Format/Format.h but does not contain an update to ClangFormatStyleOptions.rst

ClangFormatStyleOptions.rst is generated via clang/docs/tools/dump_format_style.py, please run this to regenerate the .rst

You can validate that the rst is valid by running.

./docs/tools/dump_format_style.py
mkdir -p html
/usr/bin/sphinx-build -n ./docs ./html
NOTE: Clang-Format Team Automated Review Comment

It looks like your clang-format review does not contain any unit tests, please try to ensure all code changes have a unit test (unless this is an NFC or refactoring, adding documentation etc..)

Add your unit tests in clang/unittests/Format and you can build with ninja FormatTests. We recommend using the verifyFormat(xxx) format of unit tests rather than EXPECT_EQ as this will ensure you change is tolerant to random whitespace changes (see FormatTest.cpp as an example)

For situations where your change is altering the TokenAnnotator.cpp which can happen if you are trying to improve the annotation phase to ensure we are correctly identifying the type of a token, please add a token annotator test in TokenAnnotatorTest.cpp