Skip to content

Commit

Permalink
Sync with c027f28954dcfc8ce4b9040d57b94680cfe72971 (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
dunhor committed Jan 22, 2024
1 parent 8501377 commit 832d0c5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
4 changes: 4 additions & 0 deletions include/wil/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -6214,14 +6214,18 @@ typedef weak_any<shared_mdd_package_dependency_context> weak_mdd_package_depende
/// @cond
#define __WIL_APISETLIBLOADER_
/// @endcond
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
typedef unique_any<DLL_DIRECTORY_COOKIE, decltype(&::RemoveDllDirectory), ::RemoveDllDirectory> unique_dll_directory_cookie;
#endif
#endif // __WIL_APISETLIBLOADER_
#if (defined(_APISETLIBLOADER_) && !defined(__WIL_APISETLIBLOADER_STL) && defined(WIL_RESOURCE_STL)) || defined(WIL_DOXYGEN)
/// @cond
#define __WIL_APISETLIBLOADER_STL
/// @endcond
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
typedef shared_any<unique_dll_directory_cookie> shared_dll_directory_cookie;
typedef weak_any<shared_dll_directory_cookie> weak_dll_directory_cookie;
#endif
#endif // __WIL_APISETLIBLOADER_STL

#if (defined(WDFAPI) && !defined(__WIL_WDFAPI)) || defined(WIL_DOXYGEN)
Expand Down
4 changes: 2 additions & 2 deletions include/wil/result_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ WI_ODR_PRAGMA("WIL_FreeMemory", "0")
} while ((void)0, 0)

// Like 'FAIL_FAST_IF', but raises an assertion failure first for easier debugging
#define FAIL_FAST_ASSERT(condition) \
#define WI_FAIL_FAST_ASSERT(condition) \
do \
{ \
if (!wil::verify_bool(condition)) \
Expand All @@ -1270,7 +1270,7 @@ WI_ODR_PRAGMA("WIL_FreeMemory", "0")
__RFF_FN(FailFast_Unexpected)(__RFF_INFO_ONLY(#condition)) \
} \
} while (0, 0)
#define FAIL_FAST_ASSERT_MSG(condition, msg) \
#define WI_FAIL_FAST_ASSERT_MSG(condition, msg) \
do \
{ \
if (!wil::verify_bool(condition)) \
Expand Down
22 changes: 11 additions & 11 deletions include/wil/winrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -827,9 +827,9 @@ class vector_range_nothrow
WI_NODISCARD pointer operator->() const
{
#if WIL_ITERATOR_DEBUG_LEVEL > 0
FAIL_FAST_ASSERT_MSG(m_version == m_range->m_version, "Dereferencing an out-of-date vector_iterator_nothrow");
FAIL_FAST_ASSERT_MSG(SUCCEEDED(*m_range->m_result), "Dereferencing a vector_iterator_nothrow in a failed state");
FAIL_FAST_ASSERT_MSG(m_i < m_range->m_size, "Dereferencing an 'end' iterator");
WI_FAIL_FAST_ASSERT_MSG(m_version == m_range->m_version, "Dereferencing an out-of-date vector_iterator_nothrow");
WI_FAIL_FAST_ASSERT_MSG(SUCCEEDED(*m_range->m_result), "Dereferencing a vector_iterator_nothrow in a failed state");
WI_FAIL_FAST_ASSERT_MSG(m_i < m_range->m_size, "Dereferencing an 'end' iterator");
#endif
return wistd::addressof(m_range->m_currentElement);
}
Expand Down Expand Up @@ -863,13 +863,13 @@ class vector_range_nothrow
#if WIL_ITERATOR_DEBUG_LEVEL == 2
// This is _technically_ safe because we are not reading the out-of-date cached value, however having two active
// copies of iterators is generally a sign of problematic code with a bug waiting to happen
FAIL_FAST_ASSERT_MSG(
WI_FAIL_FAST_ASSERT_MSG(
m_version == m_range->m_version, "Incrementing/decrementing an out-of-date copy of a vector_iterator_nothrow");
#endif
m_i += n;
#if WIL_ITERATOR_DEBUG_LEVEL > 0
// NOTE: 'm_i' is unsigned, hence the single check for increment/decrement
FAIL_FAST_ASSERT_MSG(m_i <= m_range->m_size, "Incrementing/decrementing a vector_iterator_nothrow out of range");
WI_FAIL_FAST_ASSERT_MSG(m_i <= m_range->m_size, "Incrementing/decrementing a vector_iterator_nothrow out of range");
#endif
m_range->get_at_current(m_i);
#if WIL_ITERATOR_DEBUG_LEVEL > 0
Expand Down Expand Up @@ -1205,9 +1205,9 @@ class iterable_range_nothrow
WI_NODISCARD pointer operator->() const WI_NOEXCEPT
{
#if WIL_ITERATOR_DEBUG_LEVEL > 0
FAIL_FAST_ASSERT_MSG(SUCCEEDED(*m_range->m_result), "Dereferencing an iterable_iterator_nothrow in a failed state");
FAIL_FAST_ASSERT_MSG(m_i >= 0, "Dereferencing an 'end' iterator");
FAIL_FAST_ASSERT_MSG(m_i == m_range->m_index, "Dereferencing an out-of-date iterable_iterator_nothrow");
WI_FAIL_FAST_ASSERT_MSG(SUCCEEDED(*m_range->m_result), "Dereferencing an iterable_iterator_nothrow in a failed state");
WI_FAIL_FAST_ASSERT_MSG(m_i >= 0, "Dereferencing an 'end' iterator");
WI_FAIL_FAST_ASSERT_MSG(m_i == m_range->m_index, "Dereferencing an out-of-date iterable_iterator_nothrow");
#endif
return wistd::addressof(m_range->m_element);
}
Expand All @@ -1216,8 +1216,8 @@ class iterable_range_nothrow
{
#if WIL_ITERATOR_DEBUG_LEVEL > 0
// Failing this check is always bad because the iterator object we hold always advances forward
FAIL_FAST_ASSERT_MSG(m_i >= 0, "Incrementing an end iterator");
FAIL_FAST_ASSERT_MSG(m_i == m_range->m_index, "Incrementing an out-of-date copy of an iterable_iterator_nothrow");
WI_FAIL_FAST_ASSERT_MSG(m_i >= 0, "Incrementing an end iterator");
WI_FAIL_FAST_ASSERT_MSG(m_i == m_range->m_index, "Incrementing an out-of-date copy of an iterable_iterator_nothrow");
#endif
boolean hasCurrent;
*m_range->m_result = m_range->m_iterator->MoveNext(&hasCurrent);
Expand Down Expand Up @@ -1260,7 +1260,7 @@ class iterable_range_nothrow
#if WIL_ITERATOR_DEBUG_LEVEL == 2
// The IIterator we hold only advances forward; we can't reset it back to the beginning. Calling this method more than
// once will very likely lead to unexpected behavior.
FAIL_FAST_ASSERT_MSG(m_index == 0, "Calling begin() on an already advanced iterable_range_nothrow");
WI_FAIL_FAST_ASSERT_MSG(m_index == 0, "Calling begin() on an already advanced iterable_range_nothrow");
#endif
return iterable_iterator_nothrow(this, this->m_iterator ? 0 : -1);
}
Expand Down

0 comments on commit 832d0c5

Please sign in to comment.