From b3974c6ed3885498404e4c588908071e5e72a2d8 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Tue, 14 Dec 2021 06:41:38 -0800 Subject: [PATCH] [wpimath] Upgrade to Drake v0.37.0 (#3786) --- upstream_utils/update_drake.py | 2 +- .../include/drake/common/drake_assert.h | 31 ++++++++--------- .../native/include/drake/common/drake_throw.h | 33 ++++++++----------- 3 files changed, 28 insertions(+), 38 deletions(-) diff --git a/upstream_utils/update_drake.py b/upstream_utils/update_drake.py index 91fe3e71f8..069d3a8c55 100755 --- a/upstream_utils/update_drake.py +++ b/upstream_utils/update_drake.py @@ -8,7 +8,7 @@ from upstream_utils import setup_upstream_repo, comment_out_invalid_includes, wa def main(): root, repo = setup_upstream_repo("https://github.com/RobotLocomotion/drake", - "v0.36.0") + "v0.37.0") wpimath = os.path.join(root, "wpimath") # Delete old install diff --git a/wpimath/src/main/native/include/drake/common/drake_assert.h b/wpimath/src/main/native/include/drake/common/drake_assert.h index 88587fad79..e9c3aa290d 100644 --- a/wpimath/src/main/native/include/drake/common/drake_assert.h +++ b/wpimath/src/main/native/include/drake/common/drake_assert.h @@ -88,14 +88,6 @@ namespace internal { // Report an assertion failure; will either Abort(...) or throw. [[noreturn]] void AssertionFailed(const char* condition, const char* func, const char* file, int line); -template -constexpr void DrakeAssertWasUsedWithRawPointer() {} -template<> -[[deprecated("\nDRAKE DEPRECATED: When using DRAKE_ASSERT or DRAKE_DEMAND on" -" a raw pointer, always write out DRAKE_ASSERT(foo != nullptr), do not write" -" DRAKE_ASSERT(foo) and rely on implicit pointer-to-bool conversion." -"\nThe deprecated code will be removed from Drake on or after 2021-12-01.")]] -constexpr void DrakeAssertWasUsedWithRawPointer() {} } // namespace internal namespace assert { // Allows for specialization of how to bool-convert Conditions used in @@ -122,8 +114,11 @@ struct ConditionTraits { typedef ::drake::assert::ConditionTraits< \ typename std::remove_cv_t> Trait; \ static_assert(Trait::is_valid, "Condition should be bool-convertible."); \ - ::drake::internal::DrakeAssertWasUsedWithRawPointer< \ - std::is_pointer_v>(); \ + static_assert( \ + !std::is_pointer_v, \ + "When using DRAKE_DEMAND on a raw pointer, always write out " \ + "DRAKE_DEMAND(foo != nullptr), do not write DRAKE_DEMAND(foo) " \ + "and rely on implicit pointer-to-bool conversion."); \ if (!Trait::Evaluate(condition)) { \ ::drake::internal::AssertionFailed( \ #condition, __func__, __FILE__, __LINE__); \ @@ -149,13 +144,15 @@ namespace drake { constexpr bool kDrakeAssertIsArmed = false; constexpr bool kDrakeAssertIsDisarmed = true; } // namespace drake -# define DRAKE_ASSERT(condition) do { \ - static_assert( \ - ::drake::assert::ConditionTraits< \ - typename std::remove_cv_t>::is_valid, \ - "Condition should be bool-convertible."); \ - ::drake::internal::DrakeAssertWasUsedWithRawPointer< \ - std::is_pointer_v>(); \ +# define DRAKE_ASSERT(condition) do { \ + typedef ::drake::assert::ConditionTraits< \ + typename std::remove_cv_t> Trait; \ + static_assert(Trait::is_valid, "Condition should be bool-convertible."); \ + static_assert( \ + !std::is_pointer_v, \ + "When using DRAKE_ASSERT on a raw pointer, always write out " \ + "DRAKE_ASSERT(foo != nullptr), do not write DRAKE_ASSERT(foo) " \ + "and rely on implicit pointer-to-bool conversion."); \ } while (0) # define DRAKE_ASSERT_VOID(expression) static_assert( \ std::is_convertible_v, \ diff --git a/wpimath/src/main/native/include/drake/common/drake_throw.h b/wpimath/src/main/native/include/drake/common/drake_throw.h index bb4bae8926..fdd07a2622 100644 --- a/wpimath/src/main/native/include/drake/common/drake_throw.h +++ b/wpimath/src/main/native/include/drake/common/drake_throw.h @@ -14,16 +14,6 @@ namespace internal { // Throw an error message. [[noreturn]] void Throw(const char* condition, const char* func, const char* file, int line); - -template -constexpr void DrakeThrowUnlessWasUsedWithRawPointer() {} -template<> -[[deprecated("\nDRAKE DEPRECATED: When using DRAKE_THROW_UNLESS on a raw" -" pointer, always write out DRAKE_THROW_UNLESS(foo != nullptr), do not write" -" DRAKE_THROW_UNLESS(foo) and rely on implicit pointer-to-bool conversion." -"\nThe deprecated code will be removed from Drake on or after 2021-12-01.")]] -constexpr void DrakeThrowUnlessWasUsedWithRawPointer() {} - } // namespace internal } // namespace drake @@ -41,14 +31,17 @@ constexpr void DrakeThrowUnlessWasUsedWithRawPointer() {} /// users, we should err on the side of extra detail about the failure. The /// meaning of "foo" isolated within error message text does not make it /// clear that a null pointer is the proximate cause of the problem. -#define DRAKE_THROW_UNLESS(condition) \ - do { \ - typedef ::drake::assert::ConditionTraits< \ - typename std::remove_cv_t> Trait; \ - static_assert(Trait::is_valid, "Condition should be bool-convertible."); \ - ::drake::internal::DrakeThrowUnlessWasUsedWithRawPointer< \ - std::is_pointer_v>(); \ - if (!Trait::Evaluate(condition)) { \ - ::drake::internal::Throw(#condition, __func__, __FILE__, __LINE__); \ - } \ +#define DRAKE_THROW_UNLESS(condition) \ + do { \ + typedef ::drake::assert::ConditionTraits< \ + typename std::remove_cv_t> Trait; \ + static_assert(Trait::is_valid, "Condition should be bool-convertible."); \ + static_assert( \ + !std::is_pointer_v, \ + "When using DRAKE_THROW_UNLESS on a raw pointer, always write out " \ + "DRAKE_THROW_UNLESS(foo != nullptr), do not write DRAKE_THROW_UNLESS" \ + "(foo) and rely on implicit pointer-to-bool conversion."); \ + if (!Trait::Evaluate(condition)) { \ + ::drake::internal::Throw(#condition, __func__, __FILE__, __LINE__); \ + } \ } while (0)