This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Added new option to allow setting spaces before and after the operator
AbandonedPublic

Authored by owenpan on Dec 18 2019, 6:08 AM.

Details

Summary

The new option is called SpaceBeforeAndAfterArrows

True:
(pointer instance) -> (member)

False:
(pointer instance)->(member)

Diff Detail

Event Timeline

Luis created this revision.Dec 18 2019, 6:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 18 2019, 6:08 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Luis retitled this revision from Adde new option to allow setting spaces before and after the operator to Added new option to allow setting spaces before and after the operator.Dec 18 2019, 6:09 AM
lebedev.ri retitled this revision from Added new option to allow setting spaces before and after the operator to [clang-format] Added new option to allow setting spaces before and after the operator.Dec 18 2019, 6:10 AM
mitchell-stellar requested changes to this revision.Dec 18 2019, 6:16 AM

This feature is missing unit tests. Also, what is the reason for all the comment changes? I don't think the changed comment lines originally exceeded 80 characters.

This revision now requires changes to proceed.Dec 18 2019, 6:16 AM
Luis added a comment.Dec 18 2019, 7:38 AM

This feature is missing unit tests. Also, what is the reason for all the comment changes? I don't think the changed comment lines originally exceeded 80 characters.

Yup, I will add the unit-test when I have time, regarding the comments, it's really weird because I'm using clang-format to format the file on save, I'll double check and try to revert those comment changes!

Bouska added a subscriber: Bouska.Dec 27 2019, 3:44 PM

Is there a reason why this option adds space before and after the tok::arrow token but not the tok::arrowstar token? That seems inconsistent to me.

MyDeveloperDay requested changes to this revision.Jan 4 2020, 7:47 AM
MyDeveloperDay added a subscriber: MyDeveloperDay.
MyDeveloperDay added inline comments.
clang/lib/Format/TokenAnnotator.cpp
3359

these are all unrelated changes please remove them from patch

owenpan commandeered this revision.Oct 27 2023, 1:51 PM
owenpan edited reviewers, added: Luis; removed: owenpan.
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2023, 1:51 PM
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

owenpan abandoned this revision.Oct 27 2023, 1:52 PM