Commit 0b328328 authored by Marco Bubke's avatar Marco Bubke

Clang: Fix move assignment in ClangString

Don't move if you assign to yourself.

Change-Id: I33977fe34cc89849337c17c1ff418ff48d68e708
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent f2e8abfe
......@@ -49,20 +49,23 @@ bool ClangString::isNull() const
return cxString.data == nullptr;
}
ClangString &ClangString::operator=(ClangString &&clangString)
ClangString &ClangString::operator=(ClangString &&other)
{
cxString = std::move(clangString.cxString);
clangString.cxString.data = nullptr;
clangString.cxString.private_flags = 0;
if (this != &other) {
clang_disposeString(cxString);
cxString = std::move(other.cxString);
other.cxString.data = nullptr;
other.cxString.private_flags = 0;
}
return *this;
}
ClangString::ClangString(ClangString &&clangString)
: cxString(std::move(clangString.cxString))
ClangString::ClangString(ClangString &&other)
: cxString(std::move(other.cxString))
{
clangString.cxString.data = nullptr;
clangString.cxString.private_flags = 0;
other.cxString.data = nullptr;
other.cxString.private_flags = 0;
}
ClangString::operator Utf8String() const
......
......@@ -43,11 +43,11 @@ public:
ClangString(CXString cxString);
~ClangString();
ClangString(const ClangString &clangString) = delete;
const ClangString &operator=(const ClangString &clangString) = delete;
ClangString(const ClangString &) = delete;
const ClangString &operator=(const ClangString &) = delete;
ClangString(ClangString &&clangString);
ClangString &operator=(ClangString &&clangString);
ClangString(ClangString &&other);
ClangString &operator=(ClangString &&other);
operator Utf8String() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment