Commit 95ac37de authored by Robert Liao's avatar Robert Liao Committed by Commit Bot

Run clang-tidy modernize-use-using on //base/win

All changes were performed by clang-tidy except for the following:
  * Reverted windows_types.h as they need to appear exactly as they do
    in windows.h and there isn't anyway to exclude files from
    clang-tidy (https://reviews.llvm.org/D26418)
  * clang-tidy doesn't quite handle WINAPI and cdecl rewrites correctly.
    Those are manually fixed up in
      * scoped_handle_unittest.cc
      * win_util.cc
      * wrapped_window_proc.h

BUG=1034666

Change-Id: I20921cd09922072767caaed4a79de179e8bf4819
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1989979
Commit-Queue: Robert Liao <robliao@chromium.org>
Reviewed-by: default avatarWill Harris <wfh@chromium.org>
Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Auto-Submit: Robert Liao <robliao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732685}
parent effb01a5
......@@ -17,6 +17,7 @@ Checks: '-*,
modernize-use-nullptr,
modernize-use-override,
modernize-use-transparent-functors,
modernize-use-using,
readability-redundant-member-init'
HeaderFilterRegex: 'base/win/*'
CheckOptions:
......
......@@ -29,7 +29,7 @@ namespace win {
namespace {
typedef std::list<EVENT_TRACE> EventQueue;
using EventQueue = std::list<EVENT_TRACE>;
class TestConsumer : public EtwTraceConsumerBase<TestConsumer> {
public:
......
......@@ -23,11 +23,11 @@
namespace base {
namespace win {
typedef GUID EtwEventClass;
typedef UCHAR EtwEventType;
typedef UCHAR EtwEventLevel;
typedef USHORT EtwEventVersion;
typedef ULONG EtwEventFlags;
using EtwEventClass = GUID;
using EtwEventType = UCHAR;
using EtwEventLevel = UCHAR;
using EtwEventVersion = USHORT;
using EtwEventFlags = ULONG;
// Base class is a POD for correctness.
template <size_t N>
......@@ -40,7 +40,7 @@ struct EtwMofEventBase {
template <size_t N>
class EtwMofEvent : public EtwMofEventBase<N> {
public:
typedef EtwMofEventBase<N> Super;
using Super = EtwMofEventBase<N>;
// Clang and the C++ standard don't allow unqualified lookup into dependent
// bases, hence these using decls to explicitly pull the names out.
......
......@@ -12,7 +12,7 @@
namespace {
typedef decltype(::GetSystemPreferredUILanguages)* GetPreferredUILanguages_Fn;
using GetPreferredUILanguages_Fn = decltype(::GetSystemPreferredUILanguages)*;
bool GetPreferredUILanguageList(GetPreferredUILanguages_Fn function,
ULONG flags,
......
......@@ -32,65 +32,54 @@ class PEImage {
// Callback to enumerate sections.
// cookie is the value passed to the enumerate method.
// Returns true to continue the enumeration.
typedef bool (*EnumSectionsFunction)(const PEImage& image,
PIMAGE_SECTION_HEADER header,
PVOID section_start,
DWORD section_size,
PVOID cookie);
using EnumSectionsFunction =
bool (*)(const PEImage&, PIMAGE_SECTION_HEADER, PVOID, DWORD, PVOID);
// Callback to enumerate exports.
// function is the actual address of the symbol. If forward is not null, it
// contains the dll and symbol to forward this export to. cookie is the value
// passed to the enumerate method.
// Returns true to continue the enumeration.
typedef bool (*EnumExportsFunction)(const PEImage& image,
DWORD ordinal,
DWORD hint,
LPCSTR name,
PVOID function,
LPCSTR forward,
PVOID cookie);
using EnumExportsFunction =
bool (*)(const PEImage&, DWORD, DWORD, LPCSTR, PVOID, LPCSTR, PVOID);
// Callback to enumerate import blocks.
// name_table and iat point to the imports name table and address table for
// this block. cookie is the value passed to the enumerate method.
// Returns true to continue the enumeration.
typedef bool (*EnumImportChunksFunction)(const PEImage& image,
LPCSTR module,
PIMAGE_THUNK_DATA name_table,
PIMAGE_THUNK_DATA iat,
PVOID cookie);
using EnumImportChunksFunction = bool (*)(const PEImage&,
LPCSTR,
PIMAGE_THUNK_DATA,
PIMAGE_THUNK_DATA,
PVOID);
// Callback to enumerate imports.
// module is the dll that exports this symbol. cookie is the value passed to
// the enumerate method.
// Returns true to continue the enumeration.
typedef bool (*EnumImportsFunction)(const PEImage& image,
LPCSTR module,
DWORD ordinal,
LPCSTR name,
DWORD hint,
PIMAGE_THUNK_DATA iat,
PVOID cookie);
using EnumImportsFunction = bool (*)(const PEImage&,
LPCSTR,
DWORD,
LPCSTR,
DWORD,
PIMAGE_THUNK_DATA,
PVOID);
// Callback to enumerate delayed import blocks.
// module is the dll that exports this block of symbols. cookie is the value
// passed to the enumerate method.
// Returns true to continue the enumeration.
typedef bool (*EnumDelayImportChunksFunction)(const PEImage& image,
PImgDelayDescr delay_descriptor,
LPCSTR module,
PIMAGE_THUNK_DATA name_table,
PIMAGE_THUNK_DATA iat,
PVOID cookie);
using EnumDelayImportChunksFunction = bool (*)(const PEImage&,
PImgDelayDescr,
LPCSTR,
PIMAGE_THUNK_DATA,
PIMAGE_THUNK_DATA,
PVOID);
// Callback to enumerate relocations.
// cookie is the value passed to the enumerate method.
// Returns true to continue the enumeration.
typedef bool (*EnumRelocsFunction)(const PEImage& image,
WORD type,
PVOID address,
PVOID cookie);
using EnumRelocsFunction = bool (*)(const PEImage&, WORD, PVOID, PVOID);
explicit PEImage(HMODULE module) : module_(module) {}
explicit PEImage(const void* module) {
......
......@@ -38,7 +38,7 @@ namespace win {
template <class Traits, class Verifier>
class GenericScopedHandle {
public:
typedef typename Traits::Handle Handle;
using Handle = typename Traits::Handle;
GenericScopedHandle() : handle_(Traits::NullHandle()) {}
......@@ -113,7 +113,7 @@ class GenericScopedHandle {
// The traits class for Win32 handles that can be closed via CloseHandle() API.
class HandleTraits {
public:
typedef HANDLE Handle;
using Handle = HANDLE;
// Closes the handle.
static bool BASE_EXPORT CloseHandle(HANDLE handle);
......@@ -133,7 +133,7 @@ class HandleTraits {
// Do-nothing verifier.
class DummyVerifierTraits {
public:
typedef HANDLE Handle;
using Handle = HANDLE;
static void StartTracking(HANDLE handle,
const void* owner,
......@@ -151,7 +151,7 @@ class DummyVerifierTraits {
// Performs actual run-time tracking.
class BASE_EXPORT VerifierTraits {
public:
typedef HANDLE Handle;
using Handle = HANDLE;
static void StartTracking(HANDLE handle,
const void* owner,
......@@ -166,7 +166,7 @@ class BASE_EXPORT VerifierTraits {
DISALLOW_IMPLICIT_CONSTRUCTORS(VerifierTraits);
};
typedef GenericScopedHandle<HandleTraits, VerifierTraits> ScopedHandle;
using ScopedHandle = GenericScopedHandle<HandleTraits, VerifierTraits>;
// This function may be called by the embedder to disable the use of
// VerifierTraits at runtime. It has no effect if DummyVerifierTraits is used
......
......@@ -52,7 +52,7 @@ TEST(ScopedHandleTest, ScopedHandle) {
TEST(ScopedHandleTest, ActiveVerifierTrackedHasBeenClosed) {
HANDLE handle = ::CreateMutex(nullptr, false, nullptr);
ASSERT_NE(HANDLE(nullptr), handle);
typedef NTSTATUS(WINAPI * NtCloseFunc)(HANDLE);
using NtCloseFunc = decltype(&::NtClose);
NtCloseFunc ntclose = reinterpret_cast<NtCloseFunc>(
GetProcAddress(GetModuleHandle(L"ntdll.dll"), "NtClose"));
ASSERT_NE(nullptr, ntclose);
......
......@@ -27,12 +27,12 @@ void* GetHandleVerifier() {
namespace {
base::win::internal::ScopedHandleVerifier* g_active_verifier = nullptr;
typedef void* (*GetHandleVerifierFn)();
typedef std::unordered_map<HANDLE,
base::win::internal::ScopedHandleVerifierInfo,
base::win::internal::HandleHash>
HandleMap;
typedef base::internal::LockImpl NativeLock;
using GetHandleVerifierFn = void* (*)();
using HandleMap =
std::unordered_map<HANDLE,
base::win::internal::ScopedHandleVerifierInfo,
base::win::internal::HandleHash>;
using NativeLock = base::internal::LockImpl;
NativeLock* GetLock() {
static auto* native_lock = new NativeLock();
......
......@@ -289,7 +289,7 @@ bool IsKeyboardPresentOnSlate(HWND hwnd, std::string* reason) {
// 3. If step 1 and 2 fail then we check attached keyboards and return true
// if we find ACPI\* or HID\VID* keyboards.
typedef BOOL(WINAPI * GetAutoRotationState)(PAR_STATE state);
using GetAutoRotationState = decltype(&::GetAutoRotationState);
static const auto get_rotation_state = reinterpret_cast<GetAutoRotationState>(
GetUser32FunctionPointer("GetAutoRotationState"));
if (get_rotation_state) {
......@@ -550,7 +550,7 @@ bool IsDeviceUsedAsATablet(std::string* reason) {
// a convertible or a detachable.
// See
// https://msdn.microsoft.com/en-us/library/windows/desktop/dn629263(v=vs.85).aspx
typedef decltype(GetAutoRotationState)* GetAutoRotationStateType;
using GetAutoRotationStateType = decltype(GetAutoRotationState)*;
static const auto get_auto_rotation_state_func =
reinterpret_cast<GetAutoRotationStateType>(
GetUser32FunctionPointer("GetAutoRotationState"));
......@@ -601,8 +601,8 @@ bool IsUser32AndGdi32Available() {
if (GetVersion() < Version::WIN8)
return true;
typedef decltype(
GetProcessMitigationPolicy)* GetProcessMitigationPolicyType;
using GetProcessMitigationPolicyType =
decltype(GetProcessMitigationPolicy)*;
GetProcessMitigationPolicyType get_process_mitigation_policy_func =
reinterpret_cast<GetProcessMitigationPolicyType>(GetProcAddress(
GetModuleHandle(L"kernel32.dll"), "GetProcessMitigationPolicy"));
......
......@@ -35,7 +35,7 @@
struct IPropertyStore;
struct _tagpropertykey;
typedef _tagpropertykey PROPERTYKEY;
using PROPERTYKEY = _tagpropertykey;
namespace base {
......
......@@ -14,7 +14,7 @@
#include "base/macros.h"
#include "base/version.h"
typedef void* HANDLE;
using HANDLE = void*;
struct _OSVERSIONINFOEXW;
struct _SYSTEM_INFO;
......
......@@ -23,7 +23,7 @@ namespace win {
// expected behavior for this function is to not return, instead of returning
// EXCEPTION_EXECUTE_HANDLER or similar, given that in general we are not
// prepared to handle exceptions.
typedef int(__cdecl* WinProcExceptionFilter)(EXCEPTION_POINTERS* info);
using WinProcExceptionFilter = int __cdecl (*)(EXCEPTION_POINTERS* info);
// Sets the filter to deal with exceptions inside a WindowProc. Returns the old
// exception filter, if any.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment