This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] extern with new line brace without indentation
ClosedPublic

Authored by MyDeveloperDay on Dec 16 2021, 7:27 AM.

Details

Summary

https://github.com/llvm/llvm-project/issues/49804

Interaction between IndentExternBlock and AfterExternBlock means you cannot have AfterExternBlock = true and IndentExternBlock = NoIndent/Indent

This patch resolves that

BraceWrapping:
  AfterExternBlock: true
IndentExternBlock: AfterExternBlock

Fixes: #49804

Diff Detail

Event Timeline

MyDeveloperDay requested review of this revision.Dec 16 2021, 7:27 AM
MyDeveloperDay created this revision.
This revision is now accepted and ready to land.Dec 16 2021, 1:24 PM
curdeius requested changes to this revision.Dec 16 2021, 1:31 PM
curdeius added inline comments.
clang/unittests/Format/FormatTest.cpp
3877

This line is unnecessary and misleading (copied from above?), as IndentExternBlock is overridden at line 3818. Please delete.

3881

I'd prefer that you split strings after \n. I find it easier to read that way.
The same below.

3887

Ditto. Remove.

This revision now requires changes to proceed.Dec 16 2021, 1:31 PM
owenpan added inline comments.Dec 16 2021, 7:13 PM
clang/unittests/Format/FormatTest.cpp
3881

It's everywhere in this function. We should fix them either now or in a separate patch.

owenpan added inline comments.Dec 16 2021, 7:26 PM
clang/lib/Format/UnwrappedLineParser.cpp
1279–1298

This case is kind of messy and some cleanup may be in order. A related question: why do we make IEBS_AfterExternBlock depend on BraceWrapping.AfterExternBlock? Can't we only have true/false for IndentExternBlock and let the user set it independent of BraceWrapping.AfterExternBlock?

owenpan added inline comments.Dec 17 2021, 12:31 AM
clang/unittests/Format/FormatTest.cpp
3878

This line is unnecessary too.

3888–3889

I would remove these too.

curdeius added inline comments.Dec 17 2021, 3:19 AM
clang/unittests/Format/FormatTest.cpp
3881

Ok, let's do it in another patch.

As always you are both correct

  • tidy up the unit tests to follow our pattern
  • reduce unnecessary style setting
  • try and tidy up the indent selection a little
MyDeveloperDay marked 7 inline comments as done.Dec 17 2021, 3:24 AM
MyDeveloperDay added inline comments.
clang/lib/Format/UnwrappedLineParser.cpp
1279–1298

This a a backwards compatibility thing, (its needed for the google style by the looks of things)

MyDeveloperDay marked an inline comment as done.Dec 17 2021, 3:24 AM
curdeius accepted this revision.Dec 17 2021, 6:16 AM

LGTM!

clang/lib/Format/UnwrappedLineParser.cpp
1281–1293

Nit.

This revision is now accepted and ready to land.Dec 17 2021, 6:16 AM
owenpan accepted this revision.Dec 17 2021, 9:22 AM
owenpan added inline comments.
clang/lib/Format/UnwrappedLineParser.cpp
1286–1288

Nit: the outer parens are unnecessary?

clang/unittests/Format/FormatTest.cpp
3857–3861

I would remove either line 3801 or 3804.

3878

Nit: you can remove this line.

MyDeveloperDay marked 4 inline comments as done.

Address nits and review comments (remove unnecessary lines)

owenpan accepted this revision.Dec 17 2021, 11:02 AM

LGTM!

This revision was landed with ongoing or failed builds.Dec 18 2021, 6:10 AM
This revision was automatically updated to reflect the committed changes.