0

Reland ".clang-format: add sort #includes config"

This reverts commit bcf9378f46.

Reason for revert:
Handle some windows headers separately for dependency from other Windows header files.

This updates windows headers like https://crrev.com/c/5367127.


Original change's description:
> Revert ".clang-format: add sort #includes config"
>
> This reverts commit 9b51287b10.
>
> Reason for revert:
> windows.h has some more include order restriction.
> e.g.
> https://ci.chromium.org/ui/p/chromium/builders/try/win-rel/460796/overview
>
> Original change's description:
> > .clang-format: add sort #includes config
> >
> > This prevents CL like
> > https://crrev.com/c/5009410/7/android_webview/browser/aw_http_auth_handler.cc
> > if CL author uses `git cl format --full`.
> >
> > This generates diff like
> > * https://crrev.com/c/5148613 for base
> >
> > Change-Id: Idd538674d2c4efb978991001ae89f07762ffe858
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5094313
> > Reviewed-by: Nico Weber <thakis@chromium.org>
> > Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
> > Cr-Commit-Position: refs/heads/main@{#1243254}
>
> Change-Id: Iae5d5932a785fe6fbddc734fbeba7b9b427e1015
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5177771
> Commit-Queue: Nico Weber <thakis@chromium.org>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Reviewed-by: Nico Weber <thakis@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1245805}

Bug: 329138753
Change-Id: I22be58a25ee3328f97daf32c11a3e5fc659a1dfe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5197064
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1278903}
This commit is contained in:
Takuto Ikuta
2024-03-27 13:08:34 +00:00
committed by Chromium LUCI CQ
parent bcd357a28f
commit 4ecc218a3f
15 changed files with 68 additions and 36 deletions

@ -12,6 +12,43 @@ Standard: Cpp11
InsertBraces: true
InsertNewlineAtEOF: true
# Sort #includes by following
# https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes
#
# ref: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#includeblocks
IncludeBlocks: Regroup
# ref: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#includecategories
IncludeCategories:
# The win32 api has all sorts of implicit include order dependencies :-/
# Give a few headers special priorities that make sure they appear before
# all other headers.
# Sync this with SerializeIncludes in tools/add_header.py.
# TODO(crbug.com/329138753): remove include sorting from tools/add_header.py
# after confirming clang-format sort works well.
# LINT.IfChange(winheader)
- Regex: '^<objbase\.h>' # This has to be before initguid.h.
Priority: 1
- Regex: '^<(initguid|mmdeviceapi|windows|winsock2|ws2tcpip|shobjidl|atlbase|ole2|unknwn|tchar)\.h>'
Priority: 2
# LINT.ThenChange(/tools/add_header.py:winheader)
# UIAutomation*.h need to be after base/win/atl.h.
# Note the low priority number.
- Regex: '^<UIAutomation.*\.h>'
Priority: 6
# Other C system headers.
- Regex: '^<.*\.h>'
Priority: 3
# C++ standard library headers.
- Regex: '^<.*'
Priority: 4
# Other libraries.
- Regex: '.*'
Priority: 5
# ref: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#includeismainregex
IncludeIsMainRegex: "\
(_(android|apple|chromeos|freebsd|fuchsia|fuzzer|ios|linux|mac|nacl|openbsd|posix|stubs?|win))?\
(_(unit|browser|perf)?tests?)?$"
# Make sure code like:
# IPC_BEGIN_MESSAGE_MAP()
# IPC_MESSAGE_HANDLER(WidgetHostViewHost_Update, OnUpdate)

@ -10,14 +10,20 @@
// Undefine before windows header will make the poisonous defines
#include "base/win/windows_undefines.inc"
// clang-format off
// Declare our own exception thrower (atl_throw.h includes atldef.h).
#include "base/win/atl_throw.h"
// clang-format on
// Now include the real ATL headers.
#include <atlbase.h> // NOLINT(build/include_order)
#include <atlbase.h> // NOLINT(build/include_order)
#include <atlcom.h> // NOLINT(build/include_order)
#include <atlcomcli.h> // NOLINT(build/include_order)
#include <atlctl.h> // NOLINT(build/include_order)
#include <atlhost.h> // NOLINT(build/include_order)
#include <atlsecurity.h> // NOLINT(build/include_order)
#include <atltypes.h> // NOLINT(build/include_order)
#include <atlwin.h> // NOLINT(build/include_order)
// Undefine the poisonous defines

@ -6,9 +6,7 @@
#include "base/win/sid.h"
// clang-format off
#include <windows.h> // Must be in front of other Windows header files.
// clang-format on
#include <windows.h>
#include <sddl.h>

@ -2,15 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/win/atl.h"
#include <atlcomcli.h>
#include <wrl/client.h>
#include "base/json/json_writer.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/win/atl.h"
#include "chrome/browser/ui/startup/credential_provider_signin_dialog_win_test_data.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/credential_provider/common/gcp_strings.h"

@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/win/atl.h"
#include "chrome/credential_provider/gaiacp/gaia_credential_provider.h"
#include <atlcomcli.h>
#include <credentialprovider.h>
#include <wrl/client.h>
@ -13,10 +12,10 @@
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/waitable_event.h"
#include "base/win/atl.h"
#include "base/win/win_util.h"
#include "chrome/credential_provider/common/gcp_strings.h"
#include "chrome/credential_provider/gaiacp/auth_utils.h"
#include "chrome/credential_provider/gaiacp/gaia_credential_provider.h"
#include "chrome/credential_provider/gaiacp/gaia_credential_provider_i.h"
#include "chrome/credential_provider/gaiacp/gcpw_strings.h"
#include "chrome/credential_provider/gaiacp/mdm_utils.h"

@ -2,19 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/win/atl.h"
#include "chrome/credential_provider/gaiacp/gaia_credential.h"
#include <atlcomcli.h>
#include <wrl/client.h>
#include "base/json/json_writer.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/win/atl.h"
#include "chrome/browser/ui/startup/credential_provider_signin_dialog_win_test_data.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/credential_provider/common/gcp_strings.h"
#include "chrome/credential_provider/gaiacp/gaia_credential.h"
#include "chrome/credential_provider/gaiacp/gaia_credential_provider_i.h"
#include "chrome/credential_provider/gaiacp/gaia_resources.h"
#include "chrome/credential_provider/gaiacp/gcp_utils.h"

@ -4,7 +4,6 @@
#include "base/win/atl.h"
#include <atlcomcli.h>
#include <wrl/client.h>
#include "base/command_line.h"

@ -5,9 +5,7 @@
#ifndef CHROME_CREDENTIAL_PROVIDER_TEST_COM_FAKES_H_
#define CHROME_CREDENTIAL_PROVIDER_TEST_COM_FAKES_H_
#include "base/win/atl.h"
#include <atlcomcli.h>
#include <credentialprovider.h>
#include <propkey.h>
@ -15,6 +13,7 @@
#include <unordered_map>
#include <vector>
#include "base/win/atl.h"
#include "chrome/credential_provider/gaiacp/gaia_credential_provider.h"
#include "chrome/credential_provider/gaiacp/gaia_credential_provider_i.h"
#include "chrome/credential_provider/test/test_credential_provider.h"

@ -2,12 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/win/atl.h"
#include <unknwn.h>
#include <atlcomcli.h>
#include <datetimeapi.h>
#include <lmerr.h>
#include <unknwn.h>
#include <wrl/client.h>
#include <memory>
@ -29,6 +27,7 @@
#include "base/syslog_logging.h"
#include "base/test/scoped_path_override.h"
#include "base/test/test_reg_util_win.h"
#include "base/win/atl.h"
#include "base/win/registry.h"
#include "base/win/scoped_com_initializer.h"
#include "base/win/win_util.h"

@ -5,9 +5,6 @@
#ifndef CHROME_CREDENTIAL_PROVIDER_TEST_TEST_CREDENTIAL_H_
#define CHROME_CREDENTIAL_PROVIDER_TEST_TEST_CREDENTIAL_H_
#include "base/win/atl.h"
#include <atlcomcli.h>
#include <credentialprovider.h>
#include <memory>
@ -16,6 +13,7 @@
#include "base/command_line.h"
#include "base/strings/string_util.h"
#include "base/synchronization/waitable_event.h"
#include "base/win/atl.h"
#include "chrome/credential_provider/common/gcp_strings.h"
#include "chrome/credential_provider/gaiacp/gaia_credential_base.h"
#include "chrome/credential_provider/test/gls_runner_test_base.h"

@ -7,8 +7,6 @@
#include "base/win/atl.h"
#include <atlcomcli.h>
namespace credential_provider {
namespace testing {

@ -8,9 +8,6 @@
#include <windows.h>
#include "base/win/atl.h"
#include <atltypes.h>
#include "chrome/updater/win/ui/ui_constants.h"
#include "third_party/wtl/include/atlapp.h"
#pragma clang diagnostic push

@ -342,6 +342,7 @@ def SerializeIncludes(includes):
"""
source = []
# LINT.IfChange(winheader)
special_headers = [
# Must be included before ws2tcpip.h.
# Doesn't need to be included before <windows.h> with
@ -364,8 +365,14 @@ def SerializeIncludes(includes):
'<objbase.h>',
# Must be before tpcshrd.h.
'<tchar.h>',
# Must be before functiondiscoverykeys_devpkey.h.
'<mmdeviceapi.h>',
# Must be before emi.h.
'<initguid.h>',
]
# LINT.ThenChange(/.clang-format:winheader)
# Ensure that headers are sorted as follows:
#
# 1. The primary header, if any, appears first.

@ -2,11 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/win/atl.h" // Must be before UIAutomationCore.h
#include <UIAutomationClient.h>
#include <UIAutomationCore.h>
#include <UIAutomationCoreApi.h>
#include "ui/accessibility/platform/ax_platform_node_textrangeprovider_win.h"
#include <memory>
#include <tuple>
@ -32,9 +28,12 @@
#include "ui/accessibility/ax_tree_update.h"
#include "ui/accessibility/platform/ax_fragment_root_delegate_win.h"
#include "ui/accessibility/platform/ax_fragment_root_win.h"
#include "ui/accessibility/platform/ax_platform_node_textrangeprovider_win.h"
#include "ui/accessibility/platform/test_ax_node_wrapper.h"
#include <UIAutomationClient.h>
#include <UIAutomationCore.h>
#include <UIAutomationCoreApi.h>
using Microsoft::WRL::ComPtr;
// We generate positions using fuzz data, this constant should be aligned

@ -5,15 +5,14 @@
#ifndef UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_WIN_UNITTEST_H_
#define UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_WIN_UNITTEST_H_
#include "ui/accessibility/platform/ax_platform_node_unittest.h"
#include <memory>
#include <unordered_set>
#include "base/test/scoped_feature_list.h"
#include "base/win/atl.h" // Must be before UIAutomationCore.h
#include "base/win/atl.h"
#include "ui/accessibility/ax_position.h"
#include "ui/accessibility/platform/ax_fragment_root_delegate_win.h"
#include "ui/accessibility/platform/ax_platform_node_unittest.h"
#include "ui/accessibility/platform/sequence_affine_com_object_root_win.h"
#include <UIAutomationCore.h>