================
@@ -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
----------------
adrian-prantl wrote:

I would find this easier to read:
```
#define LLDB_ASSERT_AND_RETURN(expr, retval)                                    
\
  assert(expr); \
  if (!(expr))                                                                 \
    return retval;
```

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

Reply via email to