Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid some const_cast usage #4344

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/symboldatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -1356,12 +1356,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));
danmar marked this conversation as resolved.
Show resolved Hide resolved
}

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 @@ -900,7 +900,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 @@ -932,7 +932,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
Loading