================
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -analyze -std=c++23 -analyzer-checker=core.DivideZero 
-verify %s
+
+int implicit_capture_by_value() {
+  int d = 0;
+  auto lam = [d]() { return 1 / d; }; // expected-warning {{Division by zero}}
+  return lam(); 
+}
+
+int explicit_rvalue_self_capture_by_reference() {
+  int d = 0;
+  auto lam = [&d](this auto &&self) { return 1 / d; }; // expected-warning 
{{Division by zero}}
+  return lam(); 
+}
+
+int gh218708_explicit_rvalue_self() {
+  int d = 0;
+  auto lam = [d](this auto &&self) { return 1 / d; }; // expected-warning 
{{Division by zero}}
+  return lam(); 
+}
+
+int gh218708_explicit_lvalue_self() {
+  int d = 0;
+  auto lam = [d](this auto &self) { return 1 / d; }; // expected-warning 
{{Division by zero}}
+  return lam(); 
+}
+
+int gh218708_explicit_by_value_self() {
+  int d = 0;
+  auto lam = [d](this auto self) { return 1 / d; }; // expected-warning 
{{Division by zero}}
+  return lam();
+}
+
----------------
steakhal wrote:

Given the subtleties of taking things by value, by l-value reference and 
r-value reference I'd love to see tests demonstrating the differences that they 
actually work as expected. Think about tests showcasing what obly lrefs, rrefs, 
and by-val explicit object parameters can do. Maybe the move checker can help 
you differentiate lref and rref tests too.

https://github.com/llvm/llvm-project/pull/219726
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to