diff options
author | Nico Weber <nicolasweber@gmx.de> | 2019-08-23 14:04:09 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2019-08-23 14:04:09 +0000 |
commit | b55dea4e8a1e5502ed1ce4adbae2a50563d63f71 (patch) | |
tree | a729cb8bbc252fb4d8a3373d25e0587d93abec75 /clang/lib/Format/Format.cpp | |
parent | 01d7fe760581e7a1a9b77a8f944caff7bb21f456 (diff) | |
download | bcm5719-llvm-b55dea4e8a1e5502ed1ce4adbae2a50563d63f71.tar.gz bcm5719-llvm-b55dea4e8a1e5502ed1ce4adbae2a50563d63f71.zip |
clang-format: Disable across-block include reordering.
Differential Revision: https://reviews.llvm.org/D66650
llvm-svn: 369759
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r-- | clang/lib/Format/Format.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 175807edfb4..90745b6e0a6 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -910,6 +910,27 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) { FormatStyle getChromiumStyle(FormatStyle::LanguageKind Language) { FormatStyle ChromiumStyle = getGoogleStyle(Language); + + // Disable include reordering across blocks in Chromium code. + // - clang-format tries to detect that foo.h is the "main" header for + // foo.cc and foo_unittest.cc via IncludeIsMainRegex. However, Chromium + // uses many other suffices (_win.cc, _mac.mm, _posix.cc, _browsertest.cc, + // _private.cc, _impl.cc etc) in different permutations + // (_win_browsertest.cc) so disable this until IncludeIsMainRegex has a + // better default for Chromium code. + // - The default for .cc and .mm files is different (r357695) for Google style + // for the same reason. The plan is to unify this again once the main + // header detection works for Google's ObjC code, but this hasn't happened + // yet. Since Chromium has some ObjC code, switching Chromium is blocked + // on that. + // - Finally, "If include reordering is harmful, put things in different + // blocks to prevent it" has been a recommendation for a long time that + // people are used to. We'll need a dev education push to change this to + // "If include reordering is harmful, put things in a different block and + // _prepend that with a comment_ to prevent it" before changing behavior. + ChromiumStyle.IncludeStyle.IncludeBlocks = + tooling::IncludeStyle::IBS_Preserve; + if (Language == FormatStyle::LK_Java) { ChromiumStyle.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_WithoutElse; |