This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Add run-clang-format.py script.
Needs ReviewPublic

Authored by curdeius on Apr 24 2023, 12:45 PM.

Diff Detail

Event Timeline

curdeius created this revision.Apr 24 2023, 12:45 PM
Herald added projects: Restricted Project, Restricted Project, Restricted Project. · View Herald TranscriptApr 24 2023, 12:45 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
curdeius requested review of this revision.Apr 24 2023, 12:45 PM
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

I guess I need to add a test in a similar that run-clang-tidy is tested, but I'd like to gather some initial review still.

Eugene.Zelenko added inline comments.
clang/tools/run-clang-format.py
1

Looks like Windows en of lines were mixed with UNIX ones.

26

Is it really necessary since Python 3 is specified explicitly?

30

Should be before os.

is it possible to pass other arguments like -n if not running in place is there any protection from prevent stdout/stderr from overlapping..?

MyDeveloperDay added inline comments.Apr 25 2023, 5:16 AM
clang/tools/run-clang-format.py
63

what about

run-clang-format `<run-clang-format-arg> --  <clang-format-args>