[clang] [clang][analyzer] Fix crash caused by overload operator member function with explicit this (PR #132581)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 24 03:18:22 PDT 2025


================
@@ -0,0 +1,21 @@
+// RUN: %clang_analyze_cc1 -std=c++23 %s -verify -analyzer-checker=alpha.cplusplus.InvalidatedIterator -analyzer-config aggressive-binary-operation-simplification=true
+
+// expected-no-diagnostics
+
+class ExplicitThis {
+  int f = 0;
+public:
+  ExplicitThis();
+  ExplicitThis(ExplicitThis& other);
+
+  ExplicitThis& operator=(this ExplicitThis& self, ExplicitThis const& other) { // no crash
+    self.f = other.f;
+    return self;
+  }
+
+  ~ExplicitThis();
+};
+
+void func(ExplicitThis& obj1) {
+    obj1 = obj1;
+}
----------------
steakhal wrote:

Can we put this into the file testing `InvalidatedIterator` and have wrap this into a namespace `GH116372`?
This is an experimental (and crashing) checker. I don't think it deserves a dedicated test file.

https://github.com/llvm/llvm-project/pull/132581


More information about the cfe-commits mailing list