Merge pull request #655 from Dmitry-Me/explicitConstCastBetterNames

Use const_cast to add const, better variable name
This commit is contained in:
Daniel Marjamäki 2015-08-27 17:04:07 +02:00
commit 436d7b6d59
3 changed files with 26 additions and 26 deletions

View File

@ -871,12 +871,12 @@ public:
const Scope *findRecordInNestedList(const std::string & name) const;
Scope *findRecordInNestedList(const std::string & name) {
return const_cast<Scope *>(static_cast<const Scope *>(this)->findRecordInNestedList(name));
return const_cast<Scope *>(const_cast<const Scope *>(this)->findRecordInNestedList(name));
}
const Type* findType(const std::string& name) const;
Type* findType(const std::string& name) {
return const_cast<Type*>(static_cast<const Scope *>(this)->findType(name));
return const_cast<Type*>(const_cast<const Scope *>(this)->findType(name));
}
/**
@ -975,12 +975,12 @@ public:
const Type* findType(const Token *tok, const Scope *startScope) const;
Type* findType(const Token *tok, Scope *startScope) const {
return const_cast<Type*>(this->findType(tok, static_cast<const Scope *>(startScope)));
return const_cast<Type*>(this->findType(tok, const_cast<const Scope *>(startScope)));
}
const Scope *findScope(const Token *tok, const Scope *startScope) const;
Scope *findScope(const Token *tok, Scope *startScope) const {
return const_cast<Scope *>(this->findScope(tok, static_cast<const Scope *>(startScope)));
return const_cast<Scope *>(this->findScope(tok, const_cast<const Scope *>(startScope)));
}
const Variable *getVariableFromVarId(std::size_t varId) const {

View File

@ -853,36 +853,36 @@ Token * Token::findClosingBracket()
//---------------------------------------------------------------------------
const Token *Token::findsimplematch(const Token *tok, const char pattern[])
const Token *Token::findsimplematch(const Token *startTok, const char pattern[])
{
for (; tok; tok = tok->next()) {
for (const Token* tok = startTok; tok; tok = tok->next()) {
if (Token::simpleMatch(tok, pattern))
return tok;
}
return 0;
}
const Token *Token::findsimplematch(const Token *tok, const char pattern[], const Token *end)
const Token *Token::findsimplematch(const Token *startTok, const char pattern[], const Token *end)
{
for (; tok && tok != end; tok = tok->next()) {
for (const Token* tok = startTok; tok && tok != end; tok = tok->next()) {
if (Token::simpleMatch(tok, pattern))
return tok;
}
return 0;
}
const Token *Token::findmatch(const Token *tok, const char pattern[], unsigned int varId)
const Token *Token::findmatch(const Token *startTok, const char pattern[], unsigned int varId)
{
for (; tok; tok = tok->next()) {
for (const Token* tok = startTok; tok; tok = tok->next()) {
if (Token::Match(tok, pattern, varId))
return tok;
}
return 0;
}
const Token *Token::findmatch(const Token *tok, const char pattern[], const Token *end, unsigned int varId)
const Token *Token::findmatch(const Token *startTok, const char pattern[], const Token *end, unsigned int varId)
{
for (; tok && tok != end; tok = tok->next()) {
for (const Token* tok = startTok; tok && tok != end; tok = tok->next()) {
if (Token::Match(tok, pattern, varId))
return tok;
}

View File

@ -105,7 +105,7 @@ public:
*/
const Token *tokAt(int index) const;
Token *tokAt(int index) {
return const_cast<Token *>(static_cast<const Token *>(this)->tokAt(index));
return const_cast<Token *>(const_cast<const Token *>(this)->tokAt(index));
}
/**
@ -114,7 +114,7 @@ public:
*/
const Token *linkAt(int index) const;
Token *linkAt(int index) {
return const_cast<Token *>(static_cast<const Token *>(this)->linkAt(index));
return const_cast<Token *>(const_cast<const Token *>(this)->linkAt(index));
}
/**
@ -388,21 +388,21 @@ public:
setFlag(fIsComplex, value);
}
static const Token *findsimplematch(const Token *tok, const char pattern[]);
static const Token *findsimplematch(const Token *tok, const char pattern[], const Token *end);
static const Token *findmatch(const Token *tok, const char pattern[], unsigned int varId = 0);
static const Token *findmatch(const Token *tok, const char pattern[], const Token *end, unsigned int varId = 0);
static Token *findsimplematch(Token *tok, const char pattern[]) {
return const_cast<Token *>(findsimplematch(static_cast<const Token *>(tok), pattern));
static const Token *findsimplematch(const Token *startTok, const char pattern[]);
static const Token *findsimplematch(const Token *startTok, const char pattern[], const Token *end);
static const Token *findmatch(const Token *startTok, const char pattern[], unsigned int varId = 0);
static const Token *findmatch(const Token *startTok, const char pattern[], const Token *end, unsigned int varId = 0);
static Token *findsimplematch(Token *startTok, const char pattern[]) {
return const_cast<Token *>(findsimplematch(const_cast<const Token *>(startTok), pattern));
}
static Token *findsimplematch(Token *tok, const char pattern[], const Token *end) {
return const_cast<Token *>(findsimplematch(static_cast<const Token *>(tok), pattern, end));
static Token *findsimplematch(Token *startTok, const char pattern[], const Token *end) {
return const_cast<Token *>(findsimplematch(const_cast<const Token *>(startTok), pattern, end));
}
static Token *findmatch(Token *tok, const char pattern[], unsigned int varId = 0) {
return const_cast<Token *>(findmatch(static_cast<const Token *>(tok), pattern, varId));
static Token *findmatch(Token *startTok, const char pattern[], unsigned int varId = 0) {
return const_cast<Token *>(findmatch(const_cast<const Token *>(startTok), pattern, varId));
}
static Token *findmatch(Token *tok, const char pattern[], const Token *end, unsigned int varId = 0) {
return const_cast<Token *>(findmatch(static_cast<const Token *>(tok), pattern, end, varId));
static Token *findmatch(Token *startTok, const char pattern[], const Token *end, unsigned int varId = 0) {
return const_cast<Token *>(findmatch(const_cast<const Token *>(startTok), pattern, end, varId));
}
/**