Skip to content

Commit

Permalink
avoid some const_cast usage [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Mar 5, 2024
1 parent 14833a4 commit b86fd5e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/symboldatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -1355,12 +1355,12 @@ class CPPCHECKLIB SymbolDatabase {
const Type* findType(const Token* startTok, const Scope* startScope, bool lookOutside = false) const;
Type* findType(const Token* startTok, Scope* startScope, bool lookOutside = false)
{
return const_cast<Type*>(this->findType(startTok, const_cast<const Scope*>(startScope), lookOutside));
return const_cast<Type*>(this->findType(startTok, static_cast<const Scope*>(startScope), lookOutside));
}

const Scope *findScope(const Token *tok, const Scope *startScope) const;
Scope *findScope(const Token *tok, Scope *startScope) {
return const_cast<Scope *>(this->findScope(tok, const_cast<const Scope *>(startScope)));
return const_cast<Scope *>(this->findScope(tok, static_cast<const Scope *>(startScope)));
}

// cppcheck-suppress unusedFunction
Expand Down
4 changes: 2 additions & 2 deletions lib/token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ const Token * Token::findClosingBracket() const
Token * Token::findClosingBracket()
{
// return value of const function
return const_cast<Token*>(const_cast<const Token*>(this)->findClosingBracket());
return const_cast<Token*>(static_cast<const Token*>(this)->findClosingBracket());
}

const Token * Token::findOpeningBracket() const
Expand Down Expand Up @@ -1042,7 +1042,7 @@ const Token * Token::findOpeningBracket() const
Token * Token::findOpeningBracket()
{
// return value of const function
return const_cast<Token*>(const_cast<const Token*>(this)->findOpeningBracket());
return const_cast<Token*>(static_cast<const Token*>(this)->findOpeningBracket());
}

//---------------------------------------------------------------------------
Expand Down

0 comments on commit b86fd5e

Please sign in to comment.