Fix Cert C++ warnings reported by Cppcheck Premium (#5528)

This commit is contained in:
Daniel Marjamäki 2023-10-09 11:20:56 +02:00 committed by GitHub
parent 06b5ef1e4d
commit 47d2c0f619
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 13 deletions

View File

@ -2189,10 +2189,9 @@ Variable& Variable::operator=(const Variable &var)
mScope = var.mScope; mScope = var.mScope;
mDimensions = var.mDimensions; mDimensions = var.mDimensions;
delete mValueType; delete mValueType;
mValueType = nullptr;
if (var.mValueType) if (var.mValueType)
mValueType = new ValueType(*var.mValueType); mValueType = new ValueType(*var.mValueType);
else
mValueType = nullptr;
return *this; return *this;
} }
@ -2347,6 +2346,7 @@ void Variable::setValueType(const ValueType &valueType)
return; return;
} }
delete mValueType; delete mValueType;
mValueType = nullptr;
mValueType = new ValueType(valueType); mValueType = new ValueType(valueType);
if ((mValueType->pointer > 0) && (!isArray() || Token::Match(mNameToken->previous(), "( * %name% )"))) if ((mValueType->pointer > 0) && (!isArray() || Token::Match(mNameToken->previous(), "( * %name% )")))
setFlag(fIsPointer, true); setFlag(fIsPointer, true);

View File

@ -546,7 +546,7 @@ public:
* @return length of dimension * @return length of dimension
*/ */
MathLib::bigint dimension(nonneg int index_) const { MathLib::bigint dimension(nonneg int index_) const {
return mDimensions[index_].num; return mDimensions.at(index_).num;
} }
/** /**
@ -554,7 +554,7 @@ public:
* @return length of dimension known * @return length of dimension known
*/ */
bool dimensionKnown(nonneg int index_) const { bool dimensionKnown(nonneg int index_) const {
return mDimensions[index_].known; return mDimensions.at(index_).known;
} }
/** /**

View File

@ -234,14 +234,6 @@ TemplateSimplifier::TokenAndName::TokenAndName(const TokenAndName& other) :
mToken->templateSimplifierPointer(this); mToken->templateSimplifierPointer(this);
} }
TemplateSimplifier::TokenAndName::TokenAndName(TokenAndName&& other) NOEXCEPT :
mToken(other.mToken), mScope(std::move(other.mScope)), mName(std::move(other.mName)), mFullName(std::move(other.mFullName)),
mNameToken(other.mNameToken), mParamEnd(other.mParamEnd), mFlags(other.mFlags)
{
if (mToken)
mToken->templateSimplifierPointer(this);
}
TemplateSimplifier::TokenAndName::~TokenAndName() TemplateSimplifier::TokenAndName::~TokenAndName()
{ {
if (mToken && mToken->templateSimplifierPointers()) if (mToken && mToken->templateSimplifierPointers())

View File

@ -152,7 +152,6 @@ public:
*/ */
TokenAndName(Token *token, std::string scope, const Token *nameToken, const Token *paramEnd); TokenAndName(Token *token, std::string scope, const Token *nameToken, const Token *paramEnd);
TokenAndName(const TokenAndName& other); TokenAndName(const TokenAndName& other);
TokenAndName(TokenAndName&& other) NOEXCEPT;
~TokenAndName(); ~TokenAndName();
bool operator == (const TokenAndName & rhs) const { bool operator == (const TokenAndName & rhs) const {