From 57a2271d7cd6871d74361761ecb3013c09d21e20 Mon Sep 17 00:00:00 2001 From: Duncan Horn Date: Thu, 11 Dec 2025 16:12:44 -0800 Subject: [PATCH 1/4] Run clang-tidy in CI --- .github/workflows/ci.yml | 30 ++++++++++++++++++++++++++++++ CMakeLists.txt | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f0fff590..8b52ad273 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,36 @@ jobs: exit /b 1 ) + clang-tidy: + name: Clang-Tidy Check + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install/Update Clang + shell: cmd + run: | + choco upgrade llvm -y + if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL% + + REM This is somewhat of a hack... we want to use the path to LLVM instead of MSVC's LLVM installation, but + REM _only_ when we're actually building with Clang. This is taking advantage of the fact that we're only + REM setting this variable when 'matrix.compiler' is 'clang'. + echo C:\Program Files\LLVM\bin >> %GITHUB_PATH% + + - name: Run Clang-Tidy + shell: cmd + run: | + call scripts\call-vcvars.cmd x64 + if %ERRORLEVEL% NEQ 0 goto :eof + + call scripts\init.cmd -c clang -b relwithdebinfo + if %ERRORLEVEL% NEQ 0 goto :eof + + ninja -C build\clang-x64-relwithdebinfo run-clang-tidy + build_and_test: name: Build and Test strategy: diff --git a/CMakeLists.txt b/CMakeLists.txt index eb1f87433..7d1e574c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,7 @@ if (${WIL_BUILD_TESTS}) DEPENDS witest.cpplatest # Clang needs the pch, otherwise it fails USES_TERMINAL # Otherwise, we don't get any output until the command is done, which takes _a while_ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - COMMAND clang-tidy -p ${PROJECT_BINARY_DIR}/compile_commands.json tests/*.cpp + COMMAND clang-tidy -p ${PROJECT_BINARY_DIR}/compile_commands.json --warnings-as-errors=* tests/*.cpp ) endif() endif() From 93b19b391d445494bec28c0a4a8d823023b72285 Mon Sep 17 00:00:00 2001 From: Duncan Horn Date: Thu, 11 Dec 2025 16:34:05 -0800 Subject: [PATCH 2/4] readability-use-concise-preprocessor-directives --- include/wil/com.h | 8 +- include/wil/common.h | 12 +- include/wil/coroutine.h | 2 +- include/wil/cppwinrt_helpers.h | 2 +- include/wil/network.h | 14 +- include/wil/registry.h | 32 ++-- include/wil/registry_helpers.h | 62 ++++---- include/wil/resource.h | 22 +-- include/wil/result_macros.h | 6 +- include/wil/stl.h | 2 +- include/wil/wistd_config.h | 10 +- include/wil/wistd_type_traits.h | 6 +- tests/ComTests.cpp | 2 +- tests/CppWinRTAuthoringTests.cpp | 2 +- tests/RegistryTests.cpp | 242 +++++++++++++++---------------- tests/WinRTTests.cpp | 2 +- tests/common.h | 4 +- 17 files changed, 215 insertions(+), 215 deletions(-) diff --git a/include/wil/com.h b/include/wil/com.h index f6ff5d1e4..39decb6ff 100644 --- a/include/wil/com.h +++ b/include/wil/com.h @@ -542,7 +542,7 @@ class com_ptr_t // Prefast cannot see through the error policy + query_policy mapping and as a result fires 6388 and 28196 for this // function. Suppression is also not working. Wrapping this entire function in #pragma warning(disable: 6388 28196) does // not stop all of the prefast errors from being emitted. -#if defined(_PREFAST_) +#ifdef _PREFAST_ *ptrResult = nullptr; return err_policy::HResult(E_NOINTERFACE); #else @@ -579,7 +579,7 @@ class com_ptr_t // Prefast cannot see through the error policy + query_policy mapping and as a result and as a result fires 6388 and 28196 // for this function. Suppression is also not working. Wrapping this entire function in #pragma warning(disable: 6388 // 28196) does not stop the prefast errors from being emitted. -#if defined(_PREFAST_) +#ifdef _PREFAST_ *ptrResult = nullptr; return err_policy::HResult(E_NOINTERFACE); #else @@ -726,7 +726,7 @@ class com_ptr_t // Prefast cannot see through the error policy + query_policy mapping and as a result and as a result fires 6388 and // 28196 for this function. Suppression is also not working. Wrapping this entire function in #pragma warning(disable: // 6388 28196) does not stop the prefast errors from being emitted. -#if defined(_PREFAST_) +#ifdef _PREFAST_ *ptrResult = nullptr; return err_policy::HResult(E_NOINTERFACE); #else @@ -758,7 +758,7 @@ class com_ptr_t // Prefast cannot see through the error policy + query_policy mapping and as a result and as a result fires 6388 and // 28196 for this function. Suppression is also not working. Wrapping this entire function in #pragma warning(disable: // 6388 28196) does not stop the prefast errors from being emitted. -#if defined(_PREFAST_) +#ifdef _PREFAST_ *ptrResult = nullptr; return err_policy::HResult(E_NOINTERFACE); #else diff --git a/include/wil/common.h b/include/wil/common.h index 65aeaac83..6c14aae52 100644 --- a/include/wil/common.h +++ b/include/wil/common.h @@ -68,7 +68,7 @@ /// @endcond /// @cond -#if defined(_MSVC_LANG) +#ifdef _MSVC_LANG #define __WI_SUPPRESS_BREAKING_WARNINGS_S __pragma(warning(push)) __pragma(warning(disable : 4127 26498 4245 26814)) #define __WI_SUPPRESS_BREAKING_WARNINGS_E __pragma(warning(pop)) #define __WI_SUPPRESS_NULLPTR_ANALYSIS __pragma(warning(suppress : 28285 6504)) @@ -331,7 +331,7 @@ extern "C" #include "wistd_type_traits.h" //! This macro inserts ODR violation protection; the macro allows it to be compatible with straight "C" code -#if defined(_MSC_VER) +#ifdef _MSC_VER #define WI_ODR_PRAGMA(NAME, TOKEN) __pragma(detect_mismatch("ODR_violation_" NAME "_mismatch", TOKEN)) #else #define WI_ODR_PRAGMA(NAME, TOKEN) @@ -359,7 +359,7 @@ routines suddenly becoming available. */ #endif /// @cond -#if defined(WIL_EXCEPTION_MODE) +#ifdef WIL_EXCEPTION_MODE static_assert(WIL_EXCEPTION_MODE <= 2, "Invalid exception mode"); #elif !defined(WIL_LOCK_EXCEPTION_MODE) #define WIL_EXCEPTION_MODE 0 // default, can link exception-based and non-exception based libraries together @@ -430,7 +430,7 @@ deduce whether or not the STL is available and can be safely used. /// @endcond // block for documentation only -#if defined(WIL_DOXYGEN) +#ifdef WIL_DOXYGEN /** This define can be explicitly set to disable exception usage within wil. Normally this define is never needed as the WIL_ENABLE_EXCEPTIONS macro is enabled automatically by looking at _CPPUNWIND. If your code compiles with exceptions enabled, but does not want to enable the exception-based @@ -632,7 +632,7 @@ namespace details //! @} // group bitwise -#if defined(WIL_DOXYGEN) +#ifdef WIL_DOXYGEN /** This macro provides a C++ header with a guaranteed initialization function. Normally, were a global object's constructor used for this purpose, the optimizer/linker might throw the object away if it's unreferenced (which throws away the side-effects that the initialization function @@ -657,7 +657,7 @@ desktop APIs. Building this functionality as `#IFDEF`s within functions would c doing it with global function pointers and header initialization allows a runtime determination. */ #define WI_HEADER_INITIALIZATION_FUNCTION(name, fn) #elif defined(_M_IX86) || defined(_M_IA64) || defined(_M_AMD64) || defined(_M_ARM) || defined(_M_ARM64) -#if defined(_MSC_VER) +#ifdef _MSC_VER #ifdef _M_IX86 #define WI_HEADER_INITIALIZATION_FUNCTION(name, fn) \ extern "C" \ diff --git a/include/wil/coroutine.h b/include/wil/coroutine.h index d2f50c7ec..9c6269d9c 100644 --- a/include/wil/coroutine.h +++ b/include/wil/coroutine.h @@ -148,7 +148,7 @@ // Detect which version of the coroutine standard we have. /// @cond -#if defined(_RESUMABLE_FUNCTIONS_SUPPORTED) +#ifdef _RESUMABLE_FUNCTIONS_SUPPORTED #include #define __WI_COROUTINE_NAMESPACE ::std::experimental #elif defined(__cpp_impl_coroutine) diff --git a/include/wil/cppwinrt_helpers.h b/include/wil/cppwinrt_helpers.h index d3c09341a..c54c5f1cb 100644 --- a/include/wil/cppwinrt_helpers.h +++ b/include/wil/cppwinrt_helpers.h @@ -39,7 +39,7 @@ template struct dispatcher_traits; } // namespace wil::details -#if defined(_RESUMABLE_FUNCTIONS_SUPPORTED) +#ifdef _RESUMABLE_FUNCTIONS_SUPPORTED #include namespace wil::details { diff --git a/include/wil/network.h b/include/wil/network.h index c43c21558..916141fd6 100644 --- a/include/wil/network.h +++ b/include/wil/network.h @@ -87,7 +87,7 @@ namespace network return {}; } -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS // Calls WSAStartup and throws on error; returns an RAII object that reverts WI_NODISCARD inline ::wil::network::unique_wsacleanup_call WSAStartup() { @@ -173,7 +173,7 @@ namespace network explicit socket_address(const SOCKET_ADDRESS* addr) WI_NOEXCEPT; explicit socket_address(const IN_ADDR* addr, unsigned short port = 0) WI_NOEXCEPT; explicit socket_address(const IN6_ADDR* addr, unsigned short port = 0) WI_NOEXCEPT; -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS explicit socket_address(PCWSTR addr, unsigned short port = 0); #endif @@ -202,7 +202,7 @@ namespace network void set_address(const IN_ADDR* addr) WI_NOEXCEPT; void set_address(const IN6_ADDR* addr) WI_NOEXCEPT; -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS void reset_address(SOCKET s); void reset_address(PCWSTR address); void reset_address(PCSTR address); @@ -407,7 +407,7 @@ namespace network // not defining a type for ADDRINFOEXA as that type is formally __declspec(deprecated) using addr_infoex_iterator = addr_info_iterator_t; -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS // function to capture resolving IP addresses assigned to the local machine, throwing on error // returning an RAII object containing the results inline ::wil::unique_addrinfo resolve_name(PCWSTR name) @@ -711,7 +711,7 @@ namespace network set_port(port); } -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS inline socket_address::socket_address(PCWSTR addr, unsigned short port) { reset_address(addr); @@ -1020,7 +1020,7 @@ namespace network m_sockaddr.Ipv6.sin6_port = original_port; } -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS inline void socket_address::reset_address(SOCKET s) { THROW_IF_FAILED(reset_address_nothrow(s)); @@ -1176,7 +1176,7 @@ namespace network } // the Winsock headers require having set this #define to access ANSI-string versions of the Winsock API -#if defined(_WINSOCK_DEPRECATED_NO_WARNINGS) +#ifdef _WINSOCK_DEPRECATED_NO_WARNINGS inline HRESULT socket_address::format_complete_address_nothrow(socket_address_string& address) const WI_NOEXCEPT { ::memset(address, 0, sizeof(socket_address_string)); diff --git a/include/wil/registry.h b/include/wil/registry.h index ac37f62b8..a550032cb 100644 --- a/include/wil/registry.h +++ b/include/wil/registry.h @@ -31,7 +31,7 @@ namespace wil //! Functions and classes that support reading and writing values to/from the registry. namespace reg { -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS /** * @brief Opens a new HKEY to the specified path - see RegOpenKeyExW * @param key An open or well-known registry key @@ -101,7 +101,7 @@ namespace reg return return_value; } #endif // #if defined(__WIL_WINREG_STL) -#endif // #if defined(WIL_ENABLE_EXCEPTIONS) +#endif // #ifdef WIL_ENABLE_EXCEPTIONS /** * @brief Opens a new HKEY to the specified path - see RegOpenKeyExW @@ -221,7 +221,7 @@ namespace reg // // the HRESULT last_error() returns the registry error that prevented enumeration // } // -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS #if WIL_USE_STL || defined(WIL_DOXYGEN) using key_iterator = ::wil::reg::iterator_t<::wil::reg::key_iterator_data<::std::wstring>>; @@ -236,7 +236,7 @@ namespace reg using key_heap_string_iterator = ::wil::reg::iterator_t<::wil::reg::key_iterator_data<::wil::unique_process_heap_string>>; using value_heap_string_iterator = ::wil::reg::iterator_t<::wil::reg::value_iterator_data<::wil::unique_process_heap_string>>; -#endif // #if defined(WIL_ENABLE_EXCEPTIONS) +#endif // #ifdef WIL_ENABLE_EXCEPTIONS // no-throw versions of applicable registry iterators #if defined(__WIL_OLEAUTO_H_) || defined(WIL_DOXYGEN) @@ -337,7 +337,7 @@ namespace reg return S_OK; } -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS /** * @brief Queries for number of sub-keys * @param key The HKEY to query for number of sub-keys @@ -376,9 +376,9 @@ namespace reg THROW_IF_FAILED(::wil::reg::get_last_write_filetime_nothrow(key, &lastModified)); return lastModified; } -#endif // #if defined(WIL_ENABLE_EXCEPTIONS) +#endif // #ifdef WIL_ENABLE_EXCEPTIONS -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS // // template // void set_value(...) @@ -920,7 +920,7 @@ namespace reg } #endif -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS // // template // T get_value(...) @@ -1720,14 +1720,14 @@ namespace reg template ::std::optional try_get_value(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name) { -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ // not allowing unique types with try_get_value: wil::unique_bstr cannot be copied and thus is difficult to work with a std::optional static_assert(!wistd::is_same_v, "try_get with wil::unique_bstr is disabled"); -#endif // #if defined(__WIL_OLEAUTO_H_) -#if defined(__WIL_OBJBASE_H_) +#endif // #ifdef __WIL_OLEAUTO_H_ +#ifdef __WIL_OBJBASE_H_ // not allowing unique types with try_get_value: wil::unique_cotaskmem_string cannot be copied and thus is difficult to work with a std::optional static_assert(!wistd::is_same_v, "try_get with wil::unique_cotaskmem_string is disabled"); -#endif // #if defined(__WIL_OBJBASE_H_) +#endif // #ifdef __WIL_OBJBASE_H_ const reg_view_details::reg_view regview{key}; return regview.try_get_value(subkey, value_name); @@ -1747,14 +1747,14 @@ namespace reg template ::std::optional try_get_value(HKEY key, _In_opt_ PCWSTR value_name) { -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ // not allowing unique types with try_get_value: wil::unique_bstr cannot be copied and thus is difficult to work with a std::optional static_assert(!wistd::is_same_v, "try_get with wil::unique_bstr is disabled"); -#endif // #if defined(__WIL_OLEAUTO_H_) -#if defined(__WIL_OBJBASE_H_) +#endif // #ifdef __WIL_OLEAUTO_H_ +#ifdef __WIL_OBJBASE_H_ // not allowing unique types with try_get_value: wil::unique_cotaskmem_string cannot be copied and thus is difficult to work with a std::optional static_assert(!wistd::is_same_v, "try_get with wil::unique_cotaskmem_string is disabled"); -#endif // #if defined(__WIL_OBJBASE_H_) +#endif // #ifdef __WIL_OBJBASE_H_ return ::wil::reg::try_get_value(key, nullptr, value_name); } diff --git a/include/wil/registry_helpers.h b/include/wil/registry_helpers.h index 964462609..9e4f626cc 100644 --- a/include/wil/registry_helpers.h +++ b/include/wil/registry_helpers.h @@ -227,7 +227,7 @@ namespace reg } #endif -#if defined(__WIL_OBJBASE_H_) +#ifdef __WIL_OBJBASE_H_ template void get_multistring_bytearray_from_strings_nothrow(const PCWSTR data[C], ::wil::unique_cotaskmem_array_ptr& multistring) WI_NOEXCEPT { @@ -342,7 +342,7 @@ namespace reg ++arrayOffset; }); } -#endif // #if defined(__WIL_OBJBASE_H_) +#endif // #ifdef __WIL_OBJBASE_H_ namespace reg_value_type_info { @@ -603,7 +603,7 @@ namespace reg } #endif -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ inline void* get_buffer(const BSTR& value) WI_NOEXCEPT { return value; @@ -733,9 +733,9 @@ namespace reg string.reset(temp_bstr); return S_OK; } -#endif // #if defined(__WIL_OLEAUTO_H_) +#endif // #ifdef __WIL_OLEAUTO_H_ -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL inline void* get_buffer(const ::wil::shared_bstr& value) WI_NOEXCEPT { return value.get(); @@ -782,9 +782,9 @@ namespace reg string.reset(temp_bstr); return S_OK; } -#endif // #if defined(__WIL_OLEAUTO_H_STL) +#endif // #ifdef __WIL_OLEAUTO_H_STL -#if defined(__WIL_OBJBASE_H_) +#ifdef __WIL_OBJBASE_H_ inline void* get_buffer(const ::wil::unique_cotaskmem_string& value) WI_NOEXCEPT { return value.get(); @@ -843,9 +843,9 @@ namespace reg arrayValue = ::wistd::move(tempValue); return S_OK; } -#endif // #if defined(__WIL_OBJBASE_H_) +#endif // #ifdef __WIL_OBJBASE_H_ -#if defined(__WIL_OBJBASE_H_STL) +#ifdef __WIL_OBJBASE_H_STL inline void* get_buffer(const ::wil::shared_cotaskmem_string& value) WI_NOEXCEPT { return value.get(); @@ -875,7 +875,7 @@ namespace reg string = ::wistd::move(new_string); return S_OK; } -#endif // #if defined(__WIL_OBJBASE_H_STL) +#endif // #ifdef __WIL_OBJBASE_H_STL inline void* get_buffer(const ::wil::unique_process_heap_string& value) WI_NOEXCEPT { @@ -1012,7 +1012,7 @@ namespace reg } #endif -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ template <> constexpr DWORD get_value_type() WI_NOEXCEPT { @@ -1035,9 +1035,9 @@ namespace reg { return REG_SZ; } -#endif // #if defined(__WIL_OLEAUTO_H_) +#endif // #ifdef __WIL_OLEAUTO_H_ -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL template <> constexpr DWORD get_value_type<::wil::shared_bstr>() WI_NOEXCEPT @@ -1050,9 +1050,9 @@ namespace reg { return REG_SZ; } -#endif // #if defined(__WIL_OLEAUTO_H_STL) +#endif // #ifdef __WIL_OLEAUTO_H_STL -#if defined(__WIL_OBJBASE_H_) +#ifdef __WIL_OBJBASE_H_ template <> constexpr DWORD get_value_type<::wil::unique_cotaskmem_string>() WI_NOEXCEPT { @@ -1064,9 +1064,9 @@ namespace reg { return REG_SZ; } -#endif // defined(__WIL_OBJBASE_H_) +#endif // #ifdef __WIL_OBJBASE_H_ -#if defined(__WIL_OBJBASE_H_STL) +#ifdef __WIL_OBJBASE_H_STL template <> constexpr DWORD get_value_type<::wil::shared_cotaskmem_string>() WI_NOEXCEPT { @@ -1078,7 +1078,7 @@ namespace reg { return REG_SZ; } -#endif // #if defined(__WIL_OBJBASE_H_STL) +#endif // #ifdef __WIL_OBJBASE_H_STL } // namespace reg_value_type_info template @@ -1206,7 +1206,7 @@ namespace reg _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, R& return_value, DWORD type = reg_value_type_info::get_value_type()) const { if -#if defined(__cpp_if_constexpr) +#ifdef __cpp_if_constexpr constexpr #endif (reg_value_type_info::supports_prepare_buffer()) @@ -1238,7 +1238,7 @@ namespace reg // some return types we can grow as needed - e.g. when writing to a std::wstring // only compile and resize_buffer for those types that support dynamically growing the buffer if -#if defined(__cpp_if_constexpr) +#ifdef __cpp_if_constexpr constexpr #endif (reg_value_type_info::supports_resize_buffer_bytes()) @@ -1292,7 +1292,7 @@ namespace reg // some types (generally string types) require trimming its internal buffer after RegGetValueW successfully wrote into its buffer if -#if defined(__cpp_if_constexpr) +#ifdef __cpp_if_constexpr constexpr #endif (reg_value_type_info::supports_trim_buffer()) @@ -1309,9 +1309,9 @@ namespace reg }; using reg_view_nothrow = ::wil::reg::reg_view_details::reg_view_t<::wil::err_returncode_policy>; -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS using reg_view = ::wil::reg::reg_view_details::reg_view_t<::wil::err_exception_policy>; -#endif // #if defined(WIL_ENABLE_EXCEPTIONS) +#endif // #ifdef WIL_ENABLE_EXCEPTIONS } // namespace reg_view_details /// @endcond @@ -1332,12 +1332,12 @@ namespace reg { return key.get(); } -#if defined(__WIL_WINREG_STL) +#ifdef __WIL_WINREG_STL inline HKEY get_hkey(const ::wil::shared_hkey& key) WI_NOEXCEPT { return key.get(); } -#endif // #if defined(__WIL_WINREG_STL) +#endif // #ifdef __WIL_WINREG_STL #if (WIL_USE_STL && defined(WIL_ENABLE_EXCEPTIONS)) || defined(WIL_DOXYGEN) // overloads for some of the below string functions - specific for std::wstring @@ -1431,7 +1431,7 @@ namespace reg return ::wil::make_unique_string_nothrow(address_of_name(name), length); } -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ inline ::wil::unique_bstr copy_name(const ::wil::unique_bstr& name, size_t length) WI_NOEXCEPT { if (!can_derive_length(name)) @@ -1443,12 +1443,12 @@ namespace reg length = length > 0 ? length - 1 : length; return ::wil::unique_bstr{::SysAllocStringLen(name.get(), static_cast(length))}; } -#endif // #if defined(__WIL_OLEAUTO_H_) +#endif // #ifdef __WIL_OLEAUTO_H_ } // namespace reg_iterator_details /// @endcond // forward declaration to allow friend-ing the template iterator class -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS template class iterator_t; #endif @@ -1514,7 +1514,7 @@ namespace reg } private: -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS friend class ::wil::reg::iterator_t; #endif friend class ::wil::reg::iterator_nothrow_t; @@ -1654,7 +1654,7 @@ namespace reg } private: -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS friend class ::wil::reg::iterator_t; #endif friend class ::wil::reg::iterator_nothrow_t; @@ -1745,7 +1745,7 @@ namespace reg size_t m_name_length{}; }; -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS template class iterator_t { diff --git a/include/wil/resource.h b/include/wil/resource.h index eb70fc307..e703e9ac5 100644 --- a/include/wil/resource.h +++ b/include/wil/resource.h @@ -4960,7 +4960,7 @@ typedef weak_any weak_hkey; #define _WIL__propidl_h__ /// @endcond // if language extensions (/Za) disabled, PropVariantInit will not exist, PROPVARIANT has forward declaration only -#if defined(_MSC_EXTENSIONS) +#ifdef _MSC_EXTENSIONS using unique_prop_variant = wil::unique_struct; #endif @@ -6329,7 +6329,7 @@ using unique_wdf_collection = unique_wdf_any; using wdf_wait_lock_release_scope_exit = unique_any; -#if defined(WIL_KERNEL_MODE) +#ifdef WIL_KERNEL_MODE using unique_wdf_device_init = unique_any; #endif @@ -6613,7 +6613,7 @@ class wdf_request_completer wdf_request_completer(wdf_request_completer&& other) WI_NOEXCEPT : m_wdfRequest(other.m_wdfRequest), m_status(other.m_status), m_information(other.m_information), -#if defined(WIL_KERNEL_MODE) +#ifdef WIL_KERNEL_MODE m_priorityBoost(other.m_priorityBoost), #endif m_completionFlags(other.m_completionFlags) @@ -6629,7 +6629,7 @@ class wdf_request_completer m_wdfRequest = other.m_wdfRequest; m_status = other.m_status; m_information = other.m_information; -#if defined(WIL_KERNEL_MODE) +#ifdef WIL_KERNEL_MODE m_priorityBoost = other.m_priorityBoost; #endif m_completionFlags = other.m_completionFlags; @@ -6679,7 +6679,7 @@ class wdf_request_completer m_information = information; } -#if defined(WIL_KERNEL_MODE) +#ifdef WIL_KERNEL_MODE //! Set the priority boost with which the WDFREQUEST will be completed. If this method is //! called, the WDFREQUEST will eventually be completed with //! WdfRequestCompleteWithPriorityBoost. No effect if this object currently does not have @@ -6730,7 +6730,7 @@ class wdf_request_completer wistd::swap_wil(m_wdfRequest, other.m_wdfRequest); wistd::swap_wil(m_information, other.m_information); wistd::swap_wil(m_status, other.m_status); -#if defined(WIL_KERNEL_MODE) +#ifdef WIL_KERNEL_MODE wistd::swap_wil(m_priorityBoost, other.m_priorityBoost); #endif wistd::swap_wil(m_completionFlags, other.m_completionFlags); @@ -6745,7 +6745,7 @@ class wdf_request_completer // call WdfRequestCompleteWithInformation instead of calling WdfRequestSetInformation // followed by WdfRequestComplete. -#if defined(WIL_KERNEL_MODE) +#ifdef WIL_KERNEL_MODE if (m_completionFlags.priorityBoostSet) { if (m_completionFlags.informationSet) @@ -6780,7 +6780,7 @@ class wdf_request_completer completer.m_wdfRequest = newWdfRequest; completer.m_status = STATUS_UNSUCCESSFUL; completer.m_information = 0; -#if defined(WIL_KERNEL_MODE) +#ifdef WIL_KERNEL_MODE completer.m_priorityBoost = 0; #endif completer.m_completionFlags = {}; @@ -6798,7 +6798,7 @@ class wdf_request_completer NTSTATUS m_status = STATUS_UNSUCCESSFUL; // UMDF does not support WdfRequestCompleteWithPriorityBoost. -#if defined(WIL_KERNEL_MODE) +#ifdef WIL_KERNEL_MODE // This will not be used unless m_completionFlags.priorityBoostSet is set. CCHAR m_priorityBoost = 0; #endif @@ -6806,7 +6806,7 @@ class wdf_request_completer struct { UINT8 informationSet : 1; -#if defined(WIL_KERNEL_MODE) +#ifdef WIL_KERNEL_MODE UINT8 priorityBoostSet : 1; #endif } m_completionFlags = {}; @@ -7304,7 +7304,7 @@ namespace details /// @endcond typedef wil::unique_any unique_hcatadmin; -#if defined(WIL_RESOURCE_STL) +#ifdef WIL_RESOURCE_STL typedef shared_any shared_hcatadmin; struct hcatinfo_deleter { diff --git a/include/wil/result_macros.h b/include/wil/result_macros.h index b0bc79b95..5813d8d8a 100644 --- a/include/wil/result_macros.h +++ b/include/wil/result_macros.h @@ -37,7 +37,7 @@ #endif /// @cond -#if defined(_PREFAST_) +#ifdef _PREFAST_ #define __WI_ANALYSIS_ASSUME(_exp) _Analysis_assume_(static_cast(_exp)) #else #ifdef RESULT_DEBUG @@ -4140,13 +4140,13 @@ namespace details inline HRESULT ResultFromExceptionSeh( const DiagnosticsInfo& diagnostics, void* returnAddress, SupportedExceptions supported, IFunctor& functor) WI_NOEXCEPT { -#if defined(_MSC_VER) +#ifdef _MSC_VER __try #endif { return wil::details::ResultFromKnownExceptions(diagnostics, returnAddress, supported, functor); } -#if defined(_MSC_VER) +#ifdef _MSC_VER __except (wil::details::TerminateAndReportError(GetExceptionInformation()), EXCEPTION_CONTINUE_SEARCH) { WI_ASSERT(false); diff --git a/include/wil/stl.h b/include/wil/stl.h index 9e3dd437c..27464a144 100644 --- a/include/wil/stl.h +++ b/include/wil/stl.h @@ -29,7 +29,7 @@ #endif /// @endcond -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS namespace wil { diff --git a/include/wil/wistd_config.h b/include/wil/wistd_config.h index f260a406a..945ac3e7b 100644 --- a/include/wil/wistd_config.h +++ b/include/wil/wistd_config.h @@ -89,7 +89,7 @@ #define __WI_LIBCPP_CXX03_LANG #endif -#if defined(__ELF__) +#ifdef __ELF__ #define __WI_LIBCPP_OBJECT_FORMAT_ELF 1 #elif defined(__MACH__) #define __WI_LIBCPP_OBJECT_FORMAT_MACHO 1 @@ -101,7 +101,7 @@ #error Unknown object file format #endif -#if defined(__clang__) +#ifdef __clang__ #define __WI_LIBCPP_COMPILER_CLANG #elif defined(__GNUC__) #define __WI_LIBCPP_COMPILER_GCC @@ -111,7 +111,7 @@ #define __WI_LIBCPP_COMPILER_IBM #endif -#if defined(__WI_LIBCPP_COMPILER_MSVC) +#ifdef __WI_LIBCPP_COMPILER_MSVC #define __WI_PUSH_WARNINGS __pragma(warning(push)) #define __WI_POP_WARNINGS __pragma(warning(pop)) #elif defined(__WI_LIBCPP_COMPILER_CLANG) @@ -251,7 +251,7 @@ #endif #endif -#if defined(__MINGW32__) +#ifdef __MINGW32__ #define __WI_LIBCPP_IS_LITERAL(T) __is_literal_type(T) #elif __has_feature(is_literal) || __WI_GNUC_VER >= 407 #define __WI_LIBCPP_IS_LITERAL(T) __is_literal(T) @@ -475,7 +475,7 @@ #define __WI_NOEXCEPT_(x) #endif -#if defined(__WI_LIBCPP_OBJECT_FORMAT_COFF) +#ifdef __WI_LIBCPP_OBJECT_FORMAT_COFF #define __WI_LIBCPP_HIDDEN #define __WI_LIBCPP_TEMPLATE_VIS #endif // defined(__WI_LIBCPP_OBJECT_FORMAT_COFF) diff --git a/include/wil/wistd_type_traits.h b/include/wil/wistd_type_traits.h index 3966e931e..f01044f1a 100644 --- a/include/wil/wistd_type_traits.h +++ b/include/wil/wistd_type_traits.h @@ -1392,7 +1392,7 @@ __WI_LIBCPP_INLINE_VAR __WI_LIBCPP_CONSTEXPR bool is_abstract_v = is_abstract<_T // is_final -#if defined(__WI_LIBCPP_HAS_IS_FINAL) +#ifdef __WI_LIBCPP_HAS_IS_FINAL template struct __WI_LIBCPP_TEMPLATE_VIS __libcpp_is_final : public integral_constant { @@ -1562,7 +1562,7 @@ struct wi_is_convertible : public integral_constant< bool, wi_is_convertible_imp::wi_is_convertible_test<_T1, _T2>::value -#if defined(__WI_LIBCPP_HAS_NO_RVALUE_REFERENCES) +#ifdef __WI_LIBCPP_HAS_NO_RVALUE_REFERENCES && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value && (!is_const::type>::value || is_volatile::type>::value) && (is_same::type, typename remove_cv::type>::type>::value || @@ -4972,7 +4972,7 @@ enum class endian { little = 0xDEAD, big = 0xFACE, -#if defined(__WI_LIBCPP_LITTLE_ENDIAN) +#ifdef __WI_LIBCPP_LITTLE_ENDIAN native = little #elif defined(__WI_LIBCPP_BIG_ENDIAN) native = big diff --git a/tests/ComTests.cpp b/tests/ComTests.cpp index b80dca0f9..002d6ab8d 100644 --- a/tests/ComTests.cpp +++ b/tests/ComTests.cpp @@ -2285,7 +2285,7 @@ TEST_CASE("ComTests::VerifyCoGetClassObject", "[com][CoGetClassObject]") } #endif -#if defined(__IBackgroundCopyManager_INTERFACE_DEFINED__) +#ifdef __IBackgroundCopyManager_INTERFACE_DEFINED__ TEST_CASE("ComTests::VerifyCoCreateEx", "[com][CoCreateInstance]") { auto init = wil::CoInitializeEx_failfast(); diff --git a/tests/CppWinRTAuthoringTests.cpp b/tests/CppWinRTAuthoringTests.cpp index ec332e392..f24b8616b 100644 --- a/tests/CppWinRTAuthoringTests.cpp +++ b/tests/CppWinRTAuthoringTests.cpp @@ -270,7 +270,7 @@ TEST_CASE("CppWinRTAuthoringTests::EventsAndCppWinRt", "[property]") TEST_CASE("CppWinRTAuthoringTests::NotifyPropertyChanged", "[property]") { -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS auto uninit = wil::RoInitialize_failfast(RO_INIT_MULTITHREADED); // Since we're uninitializing COM, we need to clear the factory cache when we're done, otherwise DLLs might unload while we diff --git a/tests/RegistryTests.cpp b/tests/RegistryTests.cpp index 2374d778e..ac757a17b 100644 --- a/tests/RegistryTests.cpp +++ b/tests/RegistryTests.cpp @@ -18,7 +18,7 @@ constexpr auto* testSubkey = L"Software\\Microsoft\\BasicRegistryTest"; constexpr auto* dwordValueName = L"MyDwordValue"; constexpr auto* qwordValueName = L"MyQwordValue"; constexpr auto* stringValueName = L"MyStringValue"; -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS constexpr auto* multiStringValueName = L"MyMultiStringValue"; #endif constexpr auto* invalidValueName = L"NonExistentValue"; @@ -178,7 +178,7 @@ static bool AreStringsEqual(const wil::unique_bstr& lhs, const std::wstring& rhs return (0 == wcscmp(lhs.get(), rhs.c_str())); } -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL static bool AreStringsEqual(const wil::shared_bstr& lhs, const std::wstring& rhs) noexcept { if (!lhs && rhs.empty()) @@ -203,7 +203,7 @@ static bool AreStringsEqual(const wil::unique_cotaskmem_string& lhs, const std:: return (0 == wcscmp(lhs.get(), rhs.c_str())); } -#if defined(__WIL_OBJBASE_H_STL) +#ifdef __WIL_OBJBASE_H_STL static bool AreStringsEqual(const wil::shared_cotaskmem_string& lhs, const std::wstring& rhs) noexcept { if (!lhs && rhs.empty()) @@ -333,7 +333,7 @@ static void VerifyThrowsHr(HRESULT hr, const std::function& fn) // // They don't assert much: they simply validate that the code in the // documentation works. -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS TEST_CASE("BasicRegistryTests::ExampleUsage", "[registry]") { // These examples use the explicit registry key, to make the usage more @@ -348,7 +348,7 @@ TEST_CASE("BasicRegistryTests::ExampleUsage", "[registry]") // Disable "unused variable" warnings for these examples #pragma warning(disable : 4189) -#if defined(__clang__) +#ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-variable" #endif @@ -379,7 +379,7 @@ TEST_CASE("BasicRegistryTests::ExampleUsage", "[registry]") HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer", nothrow_key, wil::reg::key_access::readwrite)); } -#if defined(__cpp_lib_optional) +#ifdef __cpp_lib_optional SECTION("Read values") { // Get values (or try_get if the value might not exist) @@ -451,7 +451,7 @@ TEST_CASE("BasicRegistryTests::ExampleUsage", "[registry]") REQUIRE(wil::reg::is_registry_not_found(HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))); REQUIRE(wil::reg::is_registry_not_found(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND))); } -#if defined(__clang__) +#ifdef __clang__ #pragma clang diagnostic pop #endif #pragma warning(default : 4189) @@ -598,7 +598,7 @@ TEST_CASE("BasicRegistryTests::Open", "[registry]") REQUIRE_SUCCEEDED(wil::reg::get_child_value_count_nothrow(hkey.get(), &valueCount)); REQUIRE(valueCount == 4); } -#if defined(__WIL_WINREG_STL) +#ifdef __WIL_WINREG_STL SECTION("open_shared_key_nothrow: with opened key") { constexpr auto* subSubKey = L"subkey"; @@ -681,9 +681,9 @@ TEST_CASE("BasicRegistryTests::Open", "[registry]") REQUIRE(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)); REQUIRE(wil::reg::is_registry_not_found(hr)); } -#endif // #if defined(__WIL_WINREG_STL) +#endif // #ifdef __WIL_WINREG_STL -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS SECTION("open_unique_key: with opened key") { constexpr auto* subSubKey = L"subkey"; @@ -772,7 +772,7 @@ TEST_CASE("BasicRegistryTests::Open", "[registry]") REQUIRE(valueCount == 4); } -#if defined(__WIL_WINREG_STL) +#ifdef __WIL_WINREG_STL SECTION("open_shared_key: with opened key") { constexpr auto* subSubKey = L"subkey"; @@ -899,7 +899,7 @@ struct GenericBaseFns return wil::reg::get_value_nothrow(key, subkey, valueName, output); } -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS static void set(wil::unique_hkey const& key, PCWSTR valueName, SetType const& value) { wil::reg::set_value(key.get(), valueName, value); @@ -917,7 +917,7 @@ struct GenericBaseFns { return wil::reg::get_value(key, subkey, valueName); } -#if defined(__cpp_lib_optional) +#ifdef __cpp_lib_optional static std::optional try_get(wil::unique_hkey const& key, PCWSTR valueName) { return wil::reg::try_get_value(key.get(), valueName); @@ -976,7 +976,7 @@ struct DwordFns return wil::reg::get_value_dword_nothrow(key, subkey, valueName, output); } -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS static void set(wil::unique_hkey const& key, PCWSTR valueName, SetType const& value) { wil::reg::set_value_dword(key.get(), valueName, value); @@ -994,7 +994,7 @@ struct DwordFns { return wil::reg::get_value_dword(key, subkey, valueName); } -#if defined(__cpp_lib_optional) +#ifdef __cpp_lib_optional static std::optional try_get(wil::unique_hkey const& key, PCWSTR valueName) { return wil::reg::try_get_value_dword(key.get(), valueName); @@ -1082,7 +1082,7 @@ struct QwordFns return wil::reg::get_value_qword_nothrow(key, subkey, valueName, output); } -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS static void set(wil::unique_hkey const& key, PCWSTR valueName, SetType const& value) { wil::reg::set_value_qword(key.get(), valueName, value); @@ -1101,7 +1101,7 @@ struct QwordFns return wil::reg::get_value_qword(key, subkey, valueName); } -#if defined(__cpp_lib_optional) +#ifdef __cpp_lib_optional static std::optional try_get(wil::unique_hkey const& key, PCWSTR valueName) { return wil::reg::try_get_value_qword(key.get(), valueName); @@ -1143,7 +1143,7 @@ struct GenericQwordFns : GenericBaseFns } }; -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS struct MultiStringVectorFns { using RetType = std::vector; @@ -1200,7 +1200,7 @@ struct MultiStringVectorFns return wil::reg::get_value_multistring(key, subkey, valueName); } -#if defined(__cpp_lib_optional) +#ifdef __cpp_lib_optional static std::optional try_get(wil::unique_hkey const& key, PCWSTR valueName) { return wil::reg::try_get_value_multistring(key.get(), valueName); @@ -1242,7 +1242,7 @@ struct GenericMultiStringVectorFns : GenericBaseFns, s }; #endif // defined(WIL_ENABLE_EXCEPTIONS) -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS using NoThrowTypesToTest = std::tuple; using ThrowingTypesToTest = std::tuple; @@ -1337,7 +1337,7 @@ TEMPLATE_LIST_TEST_CASE("BasicRegistryTests::simple types typed nothrow gets/set } } -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS TEMPLATE_LIST_TEST_CASE("BasicRegistryTests::simple types typed gets/sets/try_gets", "[registry]", ThrowingTypesToTest) { const auto deleteHr = HRESULT_FROM_WIN32(::RegDeleteTreeW(HKEY_CURRENT_USER, testSubkey)); @@ -1410,7 +1410,7 @@ TEMPLATE_LIST_TEST_CASE("BasicRegistryTests::simple types typed gets/sets/try_ge } } -#if defined(__cpp_lib_optional) +#ifdef __cpp_lib_optional SECTION("try_get") { SECTION("with opened key") @@ -1476,7 +1476,7 @@ TEMPLATE_LIST_TEST_CASE("BasicRegistryTests::simple types typed gets/sets/try_ge } #endif // defined(WIL_ENABLE_EXCEPTIONS) -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS TEST_CASE("BasicRegistryTests::wstrings", "[registry]") { const auto deleteHr = HRESULT_FROM_WIN32(::RegDeleteTreeW(HKEY_CURRENT_USER, testSubkey)); @@ -1853,7 +1853,7 @@ void verify_string_generic_get_value_subkey() }); } -#if defined(__cpp_lib_optional) +#ifdef __cpp_lib_optional template void verify_try_string( const std::function(PCWSTR)>& tryGetFn, @@ -1971,16 +1971,16 @@ TEST_CASE("BasicRegistryTests::string types", "[registry]") REQUIRE(wcslen(pcwstr_result) == wcslen(test_empty_null_terminated_string)); REQUIRE(wcscmp(pcwstr_result, test_empty_null_terminated_string) == 0); -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ verify_string_nothrow(hkey.get()); -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL verify_string_nothrow(hkey.get()); #endif #endif -#if defined(__WIL_OBJBASE_H_) +#ifdef __WIL_OBJBASE_H_ verify_string_nothrow(hkey.get()); -#if defined(__WIL_OBJBASE_H_STL) +#ifdef __WIL_OBJBASE_H_STL verify_string_nothrow(hkey.get()); #endif #endif @@ -2001,16 +2001,16 @@ TEST_CASE("BasicRegistryTests::string types", "[registry]") REQUIRE(wcslen(pcwstr_result) == wcslen(test_empty_null_terminated_string)); REQUIRE(wcscmp(pcwstr_result, test_empty_null_terminated_string) == 0); -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ verify_string_nothrow(HKEY_CURRENT_USER, testSubkey); -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL verify_string_nothrow(HKEY_CURRENT_USER, testSubkey); #endif #endif -#if defined(__WIL_OBJBASE_H_) +#ifdef __WIL_OBJBASE_H_ verify_string_nothrow(HKEY_CURRENT_USER, testSubkey); -#if defined(__WIL_OBJBASE_H_STL) +#ifdef __WIL_OBJBASE_H_STL verify_string_nothrow(HKEY_CURRENT_USER, testSubkey); #endif #endif @@ -2033,16 +2033,16 @@ TEST_CASE("BasicRegistryTests::string types", "[registry]") REQUIRE(wcslen(pcwstr_result) == wcslen(test_empty_null_terminated_string)); REQUIRE(wcscmp(pcwstr_result, test_empty_null_terminated_string) == 0); -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ verify_string_generic_get_value_nothrow(hkey.get()); -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL verify_string_generic_get_value_nothrow(hkey.get()); #endif #endif -#if defined(__WIL_OBJBASE_H_) +#ifdef __WIL_OBJBASE_H_ verify_string_generic_get_value_nothrow(hkey.get()); -#if defined(__WIL_OBJBASE_H_STL) +#ifdef __WIL_OBJBASE_H_STL verify_string_generic_get_value_nothrow(hkey.get()); #endif #endif @@ -2062,16 +2062,16 @@ TEST_CASE("BasicRegistryTests::string types", "[registry]") REQUIRE(wcslen(pcwstr_result) == wcslen(test_empty_null_terminated_string)); REQUIRE(wcscmp(pcwstr_result, test_empty_null_terminated_string) == 0); -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ verify_string_generic_get_value_nothrow(HKEY_CURRENT_USER, testSubkey); -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL verify_string_generic_get_value_nothrow(HKEY_CURRENT_USER, testSubkey); #endif #endif -#if defined(__WIL_OBJBASE_H_) +#ifdef __WIL_OBJBASE_H_ verify_string_generic_get_value_nothrow(HKEY_CURRENT_USER, testSubkey); -#if defined(__WIL_OBJBASE_H_STL) +#ifdef __WIL_OBJBASE_H_STL verify_string_generic_get_value_nothrow(HKEY_CURRENT_USER, testSubkey); #endif #endif @@ -2094,16 +2094,16 @@ TEST_CASE("BasicRegistryTests::string types", "[registry]") REQUIRE(pcwstr_result.size() == wcslen(test_empty_null_terminated_string)); REQUIRE(pcwstr_result == test_empty_null_terminated_string); -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ verify_string(); -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL verify_string(); #endif #endif -#if defined(__WIL_OBJBASE_H_) +#ifdef __WIL_OBJBASE_H_ verify_string(); -#if defined(__WIL_OBJBASE_H_STL) +#ifdef __WIL_OBJBASE_H_STL verify_string(); #endif #endif @@ -2122,16 +2122,16 @@ TEST_CASE("BasicRegistryTests::string types", "[registry]") REQUIRE(pcwstr_result.size() == wcslen(test_empty_null_terminated_string)); REQUIRE(pcwstr_result == test_empty_null_terminated_string); -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ verify_string_subkey(); -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL verify_string_subkey(); #endif #endif -#if defined(__WIL_OBJBASE_H_) +#ifdef __WIL_OBJBASE_H_ verify_string_subkey(); -#if defined(__WIL_OBJBASE_H_STL) +#ifdef __WIL_OBJBASE_H_STL verify_string_subkey(); #endif #endif @@ -2153,16 +2153,16 @@ TEST_CASE("BasicRegistryTests::string types", "[registry]") REQUIRE(pcwstr_result.size() == wcslen(test_empty_null_terminated_string)); REQUIRE(pcwstr_result == test_empty_null_terminated_string); -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ verify_string_generic_get_value(); -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL verify_string_generic_get_value(); #endif #endif -#if defined(__WIL_OBJBASE_H_) +#ifdef __WIL_OBJBASE_H_ verify_string_generic_get_value(); -#if defined(__WIL_OBJBASE_H_STL) +#ifdef __WIL_OBJBASE_H_STL verify_string_generic_get_value(); #endif #endif @@ -2181,34 +2181,34 @@ TEST_CASE("BasicRegistryTests::string types", "[registry]") REQUIRE(pcwstr_result.size() == wcslen(test_empty_null_terminated_string)); REQUIRE(pcwstr_result == test_empty_null_terminated_string); -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ verify_string_generic_get_value_subkey(); -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL verify_string_generic_get_value_subkey(); #endif #endif -#if defined(__WIL_OBJBASE_H_) +#ifdef __WIL_OBJBASE_H_ verify_string_generic_get_value_subkey(); -#if defined(__WIL_OBJBASE_H_STL) +#ifdef __WIL_OBJBASE_H_STL verify_string_generic_get_value_subkey(); #endif #endif } -#if defined(__cpp_lib_optional) +#ifdef __cpp_lib_optional SECTION("strings set_value_string/try_get_value_string: with open key") { verify_try_string(); -#if defined(__WIL_OLEAUTO_H_) -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_ +#ifdef __WIL_OLEAUTO_H_STL verify_try_string(); #endif #endif -#if defined(__WIL_OBJBASE_H_) -#if defined(__WIL_OBJBASE_H_STL) +#ifdef __WIL_OBJBASE_H_ +#ifdef __WIL_OBJBASE_H_STL verify_try_string(); #endif #endif @@ -2218,14 +2218,14 @@ TEST_CASE("BasicRegistryTests::string types", "[registry]") { verify_try_string_subkey(); -#if defined(__WIL_OLEAUTO_H_) -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_ +#ifdef __WIL_OLEAUTO_H_STL verify_try_string_subkey(); #endif #endif -#if defined(__WIL_OBJBASE_H_) -#if defined(__WIL_OBJBASE_H_STL) +#ifdef __WIL_OBJBASE_H_ +#ifdef __WIL_OBJBASE_H_STL verify_try_string_subkey(); #endif #endif @@ -2235,18 +2235,18 @@ TEST_CASE("BasicRegistryTests::string types", "[registry]") { verify_try_string_generic_get_value(); -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ // must fail to compile try_* with wil::unique_bstr // verify_try_string_generic_get_value(); -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL verify_try_string_generic_get_value(); #endif #endif -#if defined(__WIL_OBJBASE_H_) +#ifdef __WIL_OBJBASE_H_ // must fail to compile try_* with wil::unique_cotaskmem_string // verify_try_string_generic_get_value(); -#if defined(__WIL_OBJBASE_H_STL) +#ifdef __WIL_OBJBASE_H_STL verify_try_string_generic_get_value(); #endif #endif @@ -2256,18 +2256,18 @@ TEST_CASE("BasicRegistryTests::string types", "[registry]") { verify_try_string_generic_get_value_subkey(); -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ // must fail to compile try_* with wil::unique_bstr // verify_try_string_generic_get_value_subkey(); -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL verify_try_string_generic_get_value_subkey(); #endif #endif -#if defined(__WIL_OBJBASE_H_) +#ifdef __WIL_OBJBASE_H_ // must fail to compile try_* with wil::unique_cotaskmem_string // verify_try_string_generic_get_value_subkey(); -#if defined(__WIL_OBJBASE_H_STL) +#ifdef __WIL_OBJBASE_H_STL verify_try_string_generic_get_value_subkey(); #endif #endif @@ -2518,7 +2518,7 @@ void verify_expanded_string( }); } -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS void verify_expanded_string() { wil::unique_hkey hkey; @@ -2583,7 +2583,7 @@ void verify_expanded_string_subkey() }); } -#if defined(__cpp_lib_optional) +#ifdef __cpp_lib_optional template void verify_try_expanded_string( const std::function::type>(PCWSTR)>& getFn, @@ -2683,7 +2683,7 @@ void verify_try_expanded_string_subkey() }); } #endif // defined(__cpp_lib_optional) -#endif // #if defined(WIL_ENABLE_EXCEPTIONS) +#endif // #ifdef WIL_ENABLE_EXCEPTIONS } // namespace TEST_CASE("BasicRegistryTests::expanded_string", "[registry]") @@ -2696,16 +2696,16 @@ TEST_CASE("BasicRegistryTests::expanded_string", "[registry]") SECTION("set_value_expanded_string_nothrow/get_value_expanded_string_nothrow: with opened key") { -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ verify_expanded_string_nothrow(); -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL verify_expanded_string_nothrow(); #endif #endif -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ verify_expanded_string_nothrow(); -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL verify_expanded_string_nothrow(); #endif #endif @@ -2713,37 +2713,37 @@ TEST_CASE("BasicRegistryTests::expanded_string", "[registry]") SECTION("set_value_expanded_string_nothrow/get_value_expanded_string_nothrow: with string key") { -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ verify_expanded_string_subkey_nothrow(); -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL verify_expanded_string_subkey_nothrow(); #endif #endif -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ verify_expanded_string_subkey_nothrow(); -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL verify_expanded_string_subkey_nothrow(); #endif #endif } -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS SECTION("set_value_expanded_string/get_value_expanded_string: with opened key") { verify_expanded_string(); verify_expanded_string(); -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ verify_expanded_string(); -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL verify_expanded_string(); #endif #endif -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ verify_expanded_string(); -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL verify_expanded_string(); #endif #endif @@ -2754,33 +2754,33 @@ TEST_CASE("BasicRegistryTests::expanded_string", "[registry]") verify_expanded_string_subkey(); verify_expanded_string_subkey(); -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ verify_expanded_string_subkey(); -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL verify_expanded_string_subkey(); #endif #endif -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ verify_expanded_string_subkey(); -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL verify_expanded_string_subkey(); #endif #endif } -#if defined(__cpp_lib_optional) +#ifdef __cpp_lib_optional SECTION("set_value_expanded_string/try_get_value_expanded_string: with open key") { verify_try_expanded_string(); verify_try_expanded_string(); -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL verify_try_expanded_string(); #endif -#if defined(__WIL_OLEAUTO_H_) -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_ +#ifdef __WIL_OLEAUTO_H_STL verify_try_expanded_string(); #endif #endif @@ -2791,18 +2791,18 @@ TEST_CASE("BasicRegistryTests::expanded_string", "[registry]") verify_try_expanded_string_subkey(); verify_try_expanded_string_subkey(); -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_STL verify_try_expanded_string_subkey(); #endif -#if defined(__WIL_OLEAUTO_H_) -#if defined(__WIL_OLEAUTO_H_STL) +#ifdef __WIL_OLEAUTO_H_ +#ifdef __WIL_OLEAUTO_H_STL verify_try_expanded_string_subkey(); #endif #endif } #endif -#endif // #if defined(WIL_ENABLE_EXCEPTIONS) +#endif // #ifdef WIL_ENABLE_EXCEPTIONS } TEST_CASE("BasicRegistryTests::multi-strings", "[registry]") @@ -2813,7 +2813,7 @@ TEST_CASE("BasicRegistryTests::multi-strings", "[registry]") REQUIRE_SUCCEEDED(deleteHr); } -#if defined(__WIL_OBJBASE_H_) +#ifdef __WIL_OBJBASE_H_ SECTION("set_value_nothrow/get_value_nothrow: empty array with opened key") { wil::unique_hkey hkey; @@ -2910,7 +2910,7 @@ TEST_CASE("BasicRegistryTests::multi-strings", "[registry]") } #endif // #define __WIL_OBJBASE_H_ -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS SECTION("set_value_multistring/get_value_multistring: odd values with string key") { REQUIRE(multiStringRawTestVector.size() == multiStringRawExpectedValues.size()); @@ -2977,7 +2977,7 @@ TEST_CASE("BasicRegistryTests::multi-strings", "[registry]") #endif // #ifdef __WIL_WINREG_STL } -#if defined(__cpp_lib_optional) +#ifdef __cpp_lib_optional SECTION("set_value/try_get_value_multistring: empty array with open key") { wil::unique_hkey hkey; @@ -3030,7 +3030,7 @@ TEST_CASE("BasicRegistryTests::multi-strings", "[registry]") #endif } -#if defined(__WIL_OBJBASE_H_) +#ifdef __WIL_OBJBASE_H_ static void verify_cotaskmem_array_nothrow( const std::function&)>& getFn, const std::function&)>& setFn, @@ -3175,7 +3175,7 @@ void verify_byte_vector( REQUIRE(result[3] == 0xff); } -#if defined(__cpp_lib_optional) +#ifdef __cpp_lib_optional void verify_try_byte_vector( const std::function>(PCWSTR, DWORD)>& tryGetFn, const std::function&)>& setFn, @@ -3212,7 +3212,7 @@ void verify_try_byte_vector( REQUIRE(result->at(2) == 0xff); REQUIRE(result->at(3) == 0xff); } -#endif // #if defined(__cpp_lib_optional) +#endif // #ifdef __cpp_lib_optional } // namespace TEST_CASE("BasicRegistryTests::vector-bytes", "[registry]") @@ -3275,7 +3275,7 @@ TEST_CASE("BasicRegistryTests::vector-bytes", "[registry]") }); } -#if defined(__cpp_lib_optional) +#ifdef __cpp_lib_optional SECTION("set_value_binary/try_get_value_binary: with open key") { wil::unique_hkey hkey; @@ -3306,11 +3306,11 @@ TEST_CASE("BasicRegistryTests::vector-bytes", "[registry]") wil::reg::set_value_dword(HKEY_CURRENT_USER, testSubkey, valueName, input); }); } -#endif // #if defined(__cpp_lib_optional) +#endif // #ifdef __cpp_lib_optional } #endif -#if defined(__WIL_OBJBASE_H_) +#ifdef __WIL_OBJBASE_H_ TEST_CASE("BasicRegistryTests::cotaskmem_array-bytes", "[registry]") { const auto deleteHr = HRESULT_FROM_WIN32(::RegDeleteTreeW(HKEY_CURRENT_USER, testSubkey)); @@ -3349,9 +3349,9 @@ TEST_CASE("BasicRegistryTests::cotaskmem_array-bytes", "[registry]") }); } } -#endif // #if defined(__WIL_OBJBASE_H_) +#endif // #ifdef __WIL_OBJBASE_H_ -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS TEST_CASE("BasicRegistryTests::value_iterator", "[registry]") { const auto deleteHr = HRESULT_FROM_WIN32(::RegDeleteTreeW(HKEY_CURRENT_USER, testSubkey)); @@ -3876,7 +3876,7 @@ TEST_CASE("BasicRegistryTests::key_iterator", "[registry]") wil::reg::key_iterator(wil::reg::open_unique_key(HKEY_CURRENT_USER, testSubkey).get()), wil::reg::key_iterator{}, L"xyz"); REQUIRE(std_count == 0); -#if defined(__WIL_WINREG_STL) +#ifdef __WIL_WINREG_STL // repeat with wil::shared_hkey std_count = std::count( wil::reg::key_iterator(wil::reg::open_shared_key(HKEY_CURRENT_USER, testSubkey).get()), wil::reg::key_iterator{}, test_enum_KeyName1); @@ -3897,7 +3897,7 @@ TEST_CASE("BasicRegistryTests::key_iterator", "[registry]") std_count = std::count( wil::reg::key_iterator(wil::reg::open_shared_key(HKEY_CURRENT_USER, testSubkey).get()), wil::reg::key_iterator{}, L"xyz"); REQUIRE(std_count == 0); -#endif // #if defined(__WIL_WINREG_STL) +#endif // #ifdef __WIL_WINREG_STL } SECTION("key_iterator with many subkeys - range-for iterator usage") @@ -3937,7 +3937,7 @@ TEST_CASE("BasicRegistryTests::key_iterator", "[registry]") } } -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ TEST_CASE("BasicRegistryTests::value_bstr_iterator", "[registry]") { const auto deleteHr = HRESULT_FROM_WIN32(::RegDeleteTreeW(HKEY_CURRENT_USER, testSubkey)); @@ -4470,7 +4470,7 @@ TEST_CASE("BasicRegistryTests::key_bstr_iterator", "[registry]") }); REQUIRE(std_count == 0); -#if defined(__WIL_WINREG_STL) +#ifdef __WIL_WINREG_STL // repeat with wil::shared_hkey std_count = std::count_if( wil::reg::key_bstr_iterator(wil::reg::open_shared_key(HKEY_CURRENT_USER, testSubkey).get()), @@ -4511,7 +4511,7 @@ TEST_CASE("BasicRegistryTests::key_bstr_iterator", "[registry]") return 0 == wcscmp(test_data.name.get(), L"xyz"); }); REQUIRE(std_count == 0); -#endif // #if defined(__WIL_WINREG_STL) +#endif // #ifdef __WIL_WINREG_STL } SECTION("key_bstr_iterator with many subkeys - range-for iterator usage") @@ -5075,7 +5075,7 @@ TEST_CASE("BasicRegistryTests::key_heap_string_iterator", "[registry]") }); REQUIRE(std_count == 0); -#if defined(__WIL_WINREG_STL) +#ifdef __WIL_WINREG_STL // repeat with wil::shared_hkey std_count = std::count_if( wil::reg::key_heap_string_iterator(wil::reg::open_shared_key(HKEY_CURRENT_USER, testSubkey).get()), @@ -5116,7 +5116,7 @@ TEST_CASE("BasicRegistryTests::key_heap_string_iterator", "[registry]") return 0 == wcscmp(test_data.name.get(), L"xyz"); }); REQUIRE(std_count == 0); -#endif // #if defined(__WIL_WINREG_STL) +#endif // #ifdef __WIL_WINREG_STL } SECTION("key_heap_string_iterator with many subkeys - range-for iterator usage") @@ -5152,9 +5152,9 @@ TEST_CASE("BasicRegistryTests::key_heap_string_iterator", "[registry]") } } } -#endif // #if defined(WIL_ENABLE_EXCEPTIONS) +#endif // #ifdef WIL_ENABLE_EXCEPTIONS -#if defined(__WIL_OLEAUTO_H_) +#ifdef __WIL_OLEAUTO_H_ TEST_CASE("BasicRegistryTests::value_bstr_nothrow_iterator", "[registry]") { const auto deleteHr = HRESULT_FROM_WIN32(::RegDeleteTreeW(HKEY_CURRENT_USER, testSubkey)); diff --git a/tests/WinRTTests.cpp b/tests/WinRTTests.cpp index 6f974a6ac..84b2da008 100644 --- a/tests/WinRTTests.cpp +++ b/tests/WinRTTests.cpp @@ -742,7 +742,7 @@ static auto cast_to(ComPtr const& src) TEST_CASE("WinRTTests::VectorToVectorTest", "[winrt][to_vector]") { -#if defined(WIL_ENABLE_EXCEPTIONS) +#ifdef WIL_ENABLE_EXCEPTIONS auto uninit = wil::RoInitialize_failfast(); auto ints = MakeSampleInspectableVector(100); auto vec = wil::to_vector(ints.Get()); diff --git a/tests/common.h b/tests/common.h index 5b00f95c1..567a8cc88 100644 --- a/tests/common.h +++ b/tests/common.h @@ -210,14 +210,14 @@ template bool DoesCodeCrash(TLambda&& lambda) { bool crashed = false; -#if defined(_MSC_VER) +#ifdef _MSC_VER __try #endif { // for the purposes of this test, throwing an exception is not a crash DoesCodeThrow(wistd::forward(lambda)); } -#if defined(_MSC_VER) +#ifdef _MSC_VER __except (EXCEPTION_EXECUTE_HANDLER) { From a50b0acb1d521455dcdf66ad7ba847649fe96c52 Mon Sep 17 00:00:00 2001 From: Duncan Horn Date: Thu, 11 Dec 2025 17:09:03 -0800 Subject: [PATCH 3/4] Address more warnings --- .clang-tidy | 1 + include/wil/cppwinrt.h | 2 +- tests/ComTests.cpp | 30 +++++++++++++++--------------- tests/FakeWinRTTypes.h | 2 +- tests/common.h | 2 +- tests/cppwinrt_threadpool_guard.h | 2 +- tests/mocking.h | 2 +- tests/test_objects.h | 2 +- 8 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index ba6adeeae..ceb3e0968 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -33,6 +33,7 @@ Checks: - -readability-magic-numbers # Maybe we can revisit later, but for now this is too noisy - -readability-named-parameter # Too noisy, negatively impacts the use of tag types, and generally not that useful of a check - -readability-qualified-auto # Changes 'auto' to 'auto*' for pointers... Not really all that useful and kind of annoying for HANDLE +- -readability-use-concise-preprocessor-directives # Suggests 'elif(n)def' with >= C++23, but we need to support down to C++17 and there's no option to suppress CheckOptions: bugprone-empty-catch.IgnoreCatchWithKeywords: 'Fall through' misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: true # Makes this check more tolerable diff --git a/include/wil/cppwinrt.h b/include/wil/cppwinrt.h index d2b8521ae..e8a771b20 100644 --- a/include/wil/cppwinrt.h +++ b/include/wil/cppwinrt.h @@ -40,7 +40,7 @@ constexpr int version_from_string(const char* versionString) int result = 0; while ((*versionString >= '0') && (*versionString <= '9')) { - result = result * 10 + (*versionString - '0'); + result = (result * 10) + (*versionString - '0'); ++versionString; } diff --git a/tests/ComTests.cpp b/tests/ComTests.cpp index 002d6ab8d..b1c2da96f 100644 --- a/tests/ComTests.cpp +++ b/tests/ComTests.cpp @@ -2339,22 +2339,22 @@ TEST_CASE("ComTests::VerifyTryCoCreateInstanceMissingInterface", "[com][CoCreate // request some implemented, one not (IPropertyBag), partial results enabled { - auto [sp, pb] = + auto [copyMgr, propBag] = wil::TryCoCreateInstanceEx(__uuidof(BackgroundCopyManager), CLSCTX_LOCAL_SERVER); - REQUIRE(sp != nullptr); - REQUIRE(pb == nullptr); + REQUIRE(copyMgr != nullptr); + REQUIRE(propBag == nullptr); } { - auto [sp, pb] = wil::TryCoCreateInstanceExNoThrow( + auto [copyMgr, propBag] = wil::TryCoCreateInstanceExNoThrow( __uuidof(BackgroundCopyManager), CLSCTX_LOCAL_SERVER); - REQUIRE(sp != nullptr); - REQUIRE(pb == nullptr); + REQUIRE(copyMgr != nullptr); + REQUIRE(propBag == nullptr); } { - auto [sp, pb] = wil::TryCoCreateInstanceExFailFast( + auto [copyMgr, propBag] = wil::TryCoCreateInstanceExFailFast( __uuidof(BackgroundCopyManager), CLSCTX_LOCAL_SERVER); - REQUIRE(sp != nullptr); - REQUIRE(pb == nullptr); + REQUIRE(copyMgr != nullptr); + REQUIRE(propBag == nullptr); } } @@ -2363,12 +2363,12 @@ TEST_CASE("ComTests::VerifyQueryMultipleInterfaces", "[com][com_multi_query]") auto init = wil::CoInitializeEx_failfast(); auto mgr = wil::CoCreateInstance(CLSCTX_LOCAL_SERVER); - auto [sp, ps] = wil::com_multi_query(mgr.get()); - REQUIRE(sp); - REQUIRE(ps); - auto [sp1, pb] = wil::try_com_multi_query(mgr.get()); - REQUIRE(sp1); - REQUIRE(!pb); + auto [copyMgr, unk] = wil::com_multi_query(mgr.get()); + REQUIRE(copyMgr); + REQUIRE(unk); + auto [copyMgr1, propBag] = wil::try_com_multi_query(mgr.get()); + REQUIRE(copyMgr1); + REQUIRE(!propBag); } #endif #endif // __IBackgroundCopyManager_INTERFACE_DEFINED__ diff --git a/tests/FakeWinRTTypes.h b/tests/FakeWinRTTypes.h index d82d3c576..e922a60be 100644 --- a/tests/FakeWinRTTypes.h +++ b/tests/FakeWinRTTypes.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once // NOLINT(portability-avoid-pragma-once) #include #include diff --git a/tests/common.h b/tests/common.h index 567a8cc88..0d4a691b2 100644 --- a/tests/common.h +++ b/tests/common.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once // NOLINT(portability-avoid-pragma-once) #include #include diff --git a/tests/cppwinrt_threadpool_guard.h b/tests/cppwinrt_threadpool_guard.h index a482fa790..10d6d6f2b 100644 --- a/tests/cppwinrt_threadpool_guard.h +++ b/tests/cppwinrt_threadpool_guard.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once // NOLINT(portability-avoid-pragma-once) #include diff --git a/tests/mocking.h b/tests/mocking.h index c2e6a4f35..3ff2784f8 100644 --- a/tests/mocking.h +++ b/tests/mocking.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once // NOLINT(portability-avoid-pragma-once) #include #include diff --git a/tests/test_objects.h b/tests/test_objects.h index ccffea906..c84a84270 100644 --- a/tests/test_objects.h +++ b/tests/test_objects.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once // NOLINT(portability-avoid-pragma-once) #include "catch.hpp" From fe2918a6a062f842b11a298a9638b7aba6cdde6e Mon Sep 17 00:00:00 2001 From: Duncan Horn Date: Wed, 17 Dec 2025 13:13:22 -0600 Subject: [PATCH 4/4] New warning --- tests/Rpc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Rpc.cpp b/tests/Rpc.cpp index df7573fe2..eb2150648 100644 --- a/tests/Rpc.cpp +++ b/tests/Rpc.cpp @@ -93,6 +93,7 @@ TEST_CASE("Rpc::NonThrowing", "[rpc]") #include +// NOLINTNEXTLINE(portability-template-virtual-member-function): 'match' on base class not instantiated class WilExceptionMatcher : public Catch::Matchers::MatcherBase { HRESULT m_expected;