xbolva00 updated this revision to Diff 163818.
xbolva00 added a comment.

- Use early return


https://reviews.llvm.org/D51604

Files:
  source/Utility/LLDBAssert.cpp


Index: source/Utility/LLDBAssert.cpp
===================================================================
--- source/Utility/LLDBAssert.cpp
+++ source/Utility/LLDBAssert.cpp
@@ -19,14 +19,14 @@
 void lldb_private::lldb_assert(bool expression, const char *expr_text,
                                const char *func, const char *file,
                                unsigned int line) {
-  if (expression)
-    ;
-  else {
-    errs() << format("Assertion failed: (%s), function %s, file %s, line %u\n",
-                     expr_text, func, file, line);
-    errs() << "backtrace leading to the failure:\n";
-    llvm::sys::PrintStackTrace(errs());
-    errs() << "please file a bug report against lldb reporting this failure "
-              "log, and as many details as possible\n";
-  }
+  if (LLVM_LIKELY(expression))
+    return;
+
+  errs() << format("Assertion failed: (%s), function %s, file %s, line %u\n",
+                   expr_text, func, file, line);
+  errs() << "backtrace leading to the failure:\n";
+  llvm::sys::PrintStackTrace(errs());
+  errs() << "please file a bug report against lldb reporting this failure "
+            "log, and as many details as possible\n";
+  exit(1);
 }


Index: source/Utility/LLDBAssert.cpp
===================================================================
--- source/Utility/LLDBAssert.cpp
+++ source/Utility/LLDBAssert.cpp
@@ -19,14 +19,14 @@
 void lldb_private::lldb_assert(bool expression, const char *expr_text,
                                const char *func, const char *file,
                                unsigned int line) {
-  if (expression)
-    ;
-  else {
-    errs() << format("Assertion failed: (%s), function %s, file %s, line %u\n",
-                     expr_text, func, file, line);
-    errs() << "backtrace leading to the failure:\n";
-    llvm::sys::PrintStackTrace(errs());
-    errs() << "please file a bug report against lldb reporting this failure "
-              "log, and as many details as possible\n";
-  }
+  if (LLVM_LIKELY(expression))
+    return;
+
+  errs() << format("Assertion failed: (%s), function %s, file %s, line %u\n",
+                   expr_text, func, file, line);
+  errs() << "backtrace leading to the failure:\n";
+  llvm::sys::PrintStackTrace(errs());
+  errs() << "please file a bug report against lldb reporting this failure "
+            "log, and as many details as possible\n";
+  exit(1);
 }
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to