https://github.com/AaronBallman created 
https://github.com/llvm/llvm-project/pull/145743

This was caught by a static analysis tool and seemed like a reasonable code 
quality improvement.

>From edde45b2a4d1ee4408b798be17e3b63ffb80f949 Mon Sep 17 00:00:00 2001
From: Aaron Ballman <aa...@aaronballman.com>
Date: Wed, 25 Jun 2025 13:26:03 -0400
Subject: [PATCH] Guard against self-assignment; NFC

This was caught by a static analysis tool and seemed like a reasonable
code quality improvement.
---
 clang/include/clang/AST/Type.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 24f3ae78e857b..f4d39afded322 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -6410,9 +6410,11 @@ class SpirvOperand {
   ~SpirvOperand() {}
 
   SpirvOperand &operator=(const SpirvOperand &Other) {
-    this->Kind = Other.Kind;
-    this->ResultType = Other.ResultType;
-    this->Value = Other.Value;
+    if (this != &Other) {
+      this->Kind = Other.Kind;
+      this->ResultType = Other.ResultType;
+      this->Value = Other.Value;
+    }
     return *this;
   }
 

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to