diff options
Diffstat (limited to 'src/mongo/util/assert_util.h')
-rw-r--r-- | src/mongo/util/assert_util.h | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/mongo/util/assert_util.h b/src/mongo/util/assert_util.h index e3ca9855b4c..71ed502aecc 100644 --- a/src/mongo/util/assert_util.h +++ b/src/mongo/util/assert_util.h @@ -481,12 +481,13 @@ inline void massertStatusOKWithLocation(const Status& status, const char* file, } } -#define MONGO_BASE_ASSERT_VA_FAILED(fail_func, ...) \ - do { \ - [&]() MONGO_COMPILER_COLD_FUNCTION { \ - fail_func(::mongo::error_details::makeStatus(__VA_ARGS__), MONGO_SOURCE_LOCATION()); \ - }(); \ - MONGO_COMPILER_UNREACHABLE; \ +#define MONGO_BASE_ASSERT_VA_FAILED(fail_func, ...) \ + do { \ + auto mongoSourceLocation = MONGO_SOURCE_LOCATION(); \ + [&]() MONGO_COMPILER_COLD_FUNCTION { \ + fail_func(::mongo::error_details::makeStatus(__VA_ARGS__), mongoSourceLocation); \ + }(); \ + MONGO_COMPILER_UNREACHABLE; \ } while (false) #define MONGO_BASE_ASSERT_VA_4(fail_func, code, msg, cond) \ @@ -709,3 +710,21 @@ Status exceptionToStatus() noexcept; * Like `MONGO_UNREACHABLE`, but triggers a `tassert` instead of an `invariant` */ #define MONGO_UNREACHABLE_TASSERT(msgid) tasserted(msgid, "Hit a MONGO_UNREACHABLE_TASSERT!") + +/** + * Produces an invariant failure if executed. Subset of MONGO_UNREACHABLE, but specifically + * to indicate that the program has reached a function that is unimplemented and should be + * unreachable from production. + * Example: + * + * void myFuncToDo() { + * MONGO_UNIMPLEMENTED; + * } + */ +#define MONGO_UNIMPLEMENTED \ + ::mongo::invariantFailed("Hit a MONGO_UNIMPLEMENTED!", __FILE__, __LINE__); + +/** + * Like `MONGO_UNIMPLEMENTED`, but triggers a `tassert` instead of an `invariant` + */ +#define MONGO_UNIMPLEMENTED_TASSERT(msgid) tasserted(msgid, "Hit a MONGO_UNIMPLEMENTED_TASSERT!") |