================ @@ -139,4 +139,16 @@ #define LLDB_DEPRECATED_FIXME(MSG, FIX) LLDB_DEPRECATED(MSG) #endif +// When asserts are enabled, use an assert to check expr. If they are not +// enabled, return the value retval if expr is not true. Used when a hard +// failure is useful during development but in a release build without asserts +// you need to return to prevent corrupting state. +#ifdef NDEBUG +#define LLDB_ASSERT_OR_RETURN(expr, retval) \ + if (!(expr)) \ + return retval; +#else +#define LLDB_ASSERT_OR_RETURN(expr, retval) assert(expr); +#endif ---------------- DavidSpickett wrote:
So I had that at first, but tried to be fancy and not emit the if if the assert was going to be there. I could go with either. I also wondered if a static analyser would tell us that the if could never fail given the assert above it. https://github.com/llvm/llvm-project/pull/71175 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits