Skip to content

Commit

Permalink
Fix Cert C++ warnings reported by Cppcheck Premium (#5528)
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar committed Oct 9, 2023
1 parent 06b5ef1 commit 47d2c0f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2189,10 +2189,9 @@ Variable& Variable::operator=(const Variable &var)
mScope = var.mScope;
mDimensions = var.mDimensions;
delete mValueType;
mValueType = nullptr;
if (var.mValueType)
mValueType = new ValueType(*var.mValueType);
else
mValueType = nullptr;

return *this;
}
Expand Down Expand Up @@ -2347,6 +2346,7 @@ void Variable::setValueType(const ValueType &valueType)
return;
}
delete mValueType;
mValueType = nullptr;
mValueType = new ValueType(valueType);
if ((mValueType->pointer > 0) && (!isArray() || Token::Match(mNameToken->previous(), "( * %name% )")))
setFlag(fIsPointer, true);
Expand Down
4 changes: 2 additions & 2 deletions lib/symboldatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -546,15 +546,15 @@ class CPPCHECKLIB Variable {
* @return length of dimension
*/
MathLib::bigint dimension(nonneg int index_) const {
return mDimensions[index_].num;
return mDimensions.at(index_).num;
}

/**
* Get array dimension known.
* @return length of dimension known
*/
bool dimensionKnown(nonneg int index_) const {
return mDimensions[index_].known;
return mDimensions.at(index_).known;
}

/**
Expand Down
8 changes: 0 additions & 8 deletions lib/templatesimplifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,6 @@ TemplateSimplifier::TokenAndName::TokenAndName(const TokenAndName& other) :
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()
{
if (mToken && mToken->templateSimplifierPointers())
Expand Down
1 change: 0 additions & 1 deletion lib/templatesimplifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ class CPPCHECKLIB TemplateSimplifier {
*/
TokenAndName(Token *token, std::string scope, const Token *nameToken, const Token *paramEnd);
TokenAndName(const TokenAndName& other);
TokenAndName(TokenAndName&& other) NOEXCEPT;
~TokenAndName();

bool operator == (const TokenAndName & rhs) const {
Expand Down

0 comments on commit 47d2c0f

Please sign in to comment.