From 1151c3dafd6fd26b6bd60c7954d35dfc2df1e05b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 28 Jan 2021 13:46:00 +0100 Subject: [PATCH] Fixed msvc compilation error by implementing Variable::operator= --- lib/symboldatabase.cpp | 52 +++++++++++++++++++++++------------------- lib/symboldatabase.h | 2 +- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 2b91b8eab..a45e522fa 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1887,35 +1887,16 @@ Variable::Variable(const Token *name_, const std::string &clangType, const Token } Variable::Variable(const Variable &var, const Scope *scope) - : mNameToken(var.mNameToken) - , mTypeStartToken(var.mTypeStartToken) - , mTypeEndToken(var.mTypeEndToken) - , mIndex(var.mIndex) - , mAccess(var.mAccess) - , mFlags(var.mFlags) - , mType(var.mType) - , mScope(scope ? scope : var.mScope) - , mValueType(nullptr) - , mDimensions(var.mDimensions) + : mValueType(nullptr) { - if (var.mValueType) - mValueType = new ValueType(*var.mValueType); + *this = var; + mScope = scope; } Variable::Variable(const Variable &var) - : mNameToken(var.mNameToken) - , mTypeStartToken(var.mTypeStartToken) - , mTypeEndToken(var.mTypeEndToken) - , mIndex(var.mIndex) - , mAccess(var.mAccess) - , mFlags(var.mFlags) - , mType(var.mType) - , mScope(var.mScope) - , mValueType(nullptr) - , mDimensions(var.mDimensions) + : mValueType(nullptr) { - if (var.mValueType) - mValueType = new ValueType(*var.mValueType); + *this = var; } Variable::~Variable() @@ -1923,6 +1904,29 @@ Variable::~Variable() delete mValueType; } +Variable& Variable::operator=(const Variable &var) +{ + if (this == &var) + return *this; + + mNameToken = var.mNameToken; + mTypeStartToken = var.mTypeStartToken; + mTypeEndToken = var.mTypeEndToken; + mIndex = var.mIndex; + mAccess = var.mAccess; + mFlags = var.mFlags; + mType = var.mType; + mScope = var.mScope; + mDimensions = var.mDimensions; + delete mValueType; + if (var.mValueType) + mValueType = new ValueType(*var.mValueType); + else + mValueType = nullptr; + + return *this; +} + bool Variable::isPointerArray() const { return isArray() && nameToken() && nameToken()->previous() && (nameToken()->previous()->str() == "*"); diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index 681c5fb47..4ed3c3ae3 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -246,7 +246,7 @@ public: ~Variable(); - Variable &operator=(const Variable &var) = delete; + Variable &operator=(const Variable &var); /** * Get name token.