https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/145743
>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 1/2] 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; } >From e3f15db227fec6c9d40d7527aa4f5265161debbe Mon Sep 17 00:00:00 2001 From: Aaron Ballman <aa...@aaronballman.com> Date: Wed, 25 Jun 2025 14:20:52 -0400 Subject: [PATCH 2/2] Go with = default instead --- clang/include/clang/AST/Type.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index f4d39afded322..1a87608e5be34 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -6409,14 +6409,7 @@ class SpirvOperand { SpirvOperand(const SpirvOperand &Other) { *this = Other; } ~SpirvOperand() {} - SpirvOperand &operator=(const SpirvOperand &Other) { - if (this != &Other) { - this->Kind = Other.Kind; - this->ResultType = Other.ResultType; - this->Value = Other.Value; - } - return *this; - } + SpirvOperand &operator=(const SpirvOperand &Other) = default; bool operator==(const SpirvOperand &Other) const { return Kind == Other.Kind && ResultType == Other.ResultType && _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits