diff --git a/clang/lib/AST/APValue.cpp b/clang/lib/AST/APValue.cpp index 7bbde6d065316..5b0a5e256e411 100644 --- a/clang/lib/AST/APValue.cpp +++ b/clang/lib/AST/APValue.cpp @@ -390,13 +390,11 @@ APValue &APValue::operator=(const APValue &RHS) { } APValue &APValue::operator=(APValue &&RHS) { - if (this != RHS) { - if (Kind != None && Kind != Indeterminate) - DestroyDataAndMakeUninit(); - Kind = RHS.Kind; - Data = RHS.Data; - RHS.Kind = None; - } + if (Kind != None && Kind != Indeterminate) + DestroyDataAndMakeUninit(); + Kind = RHS.Kind; + Data = RHS.Data; + RHS.Kind = None; return *this; } diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index 5b089f3330c42..58ee6dd64c4fc 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -832,10 +832,8 @@ class ApplyDebugLocation { // Define copy assignment operator. ApplyDebugLocation &operator=(ApplyDebugLocation &&Other) { - if (this != Other) { - CGF = Other.CGF; - Other.CGF = nullptr; - } + CGF = Other.CGF; + Other.CGF = nullptr; return *this; } diff --git a/clang/lib/Interpreter/Value.cpp b/clang/lib/Interpreter/Value.cpp index 68adfc268261a..6d0eaf1b82e10 100644 --- a/clang/lib/Interpreter/Value.cpp +++ b/clang/lib/Interpreter/Value.cpp @@ -201,17 +201,16 @@ Value &Value::operator=(const Value &RHS) { } Value &Value::operator=(Value &&RHS) noexcept { - if (this != RHS) { - if (IsManuallyAlloc) - ValueStorage::getFromPayload(getPtr())->Release(); + if (IsManuallyAlloc) + ValueStorage::getFromPayload(getPtr())->Release(); - Interp = std::exchange(RHS.Interp, nullptr); - OpaqueType = std::exchange(RHS.OpaqueType, nullptr); - ValueKind = std::exchange(RHS.ValueKind, K_Unspecified); - IsManuallyAlloc = std::exchange(RHS.IsManuallyAlloc, false); + Interp = std::exchange(RHS.Interp, nullptr); + OpaqueType = std::exchange(RHS.OpaqueType, nullptr); + ValueKind = std::exchange(RHS.ValueKind, K_Unspecified); + IsManuallyAlloc = std::exchange(RHS.IsManuallyAlloc, false); + + Data = RHS.Data; - Data = RHS.Data; - } return *this; }