Use const_cast to add const, better variable name
This commit is contained in:
parent
eb3b3de81f
commit
c760ccee13
|
@ -871,12 +871,12 @@ public:
|
||||||
|
|
||||||
const Scope *findRecordInNestedList(const std::string & name) const;
|
const Scope *findRecordInNestedList(const std::string & name) const;
|
||||||
Scope *findRecordInNestedList(const std::string & name) {
|
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;
|
const Type* findType(const std::string& name) const;
|
||||||
Type* findType(const std::string& name) {
|
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;
|
const Type* findType(const Token *tok, const Scope *startScope) const;
|
||||||
Type* findType(const Token *tok, 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;
|
const Scope *findScope(const Token *tok, const Scope *startScope) const;
|
||||||
Scope *findScope(const Token *tok, 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 {
|
const Variable *getVariableFromVarId(std::size_t varId) const {
|
||||||
|
|
|
@ -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))
|
if (Token::simpleMatch(tok, pattern))
|
||||||
return tok;
|
return tok;
|
||||||
}
|
}
|
||||||
return 0;
|
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))
|
if (Token::simpleMatch(tok, pattern))
|
||||||
return tok;
|
return tok;
|
||||||
}
|
}
|
||||||
return 0;
|
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))
|
if (Token::Match(tok, pattern, varId))
|
||||||
return tok;
|
return tok;
|
||||||
}
|
}
|
||||||
return 0;
|
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))
|
if (Token::Match(tok, pattern, varId))
|
||||||
return tok;
|
return tok;
|
||||||
}
|
}
|
||||||
|
|
28
lib/token.h
28
lib/token.h
|
@ -105,7 +105,7 @@ public:
|
||||||
*/
|
*/
|
||||||
const Token *tokAt(int index) const;
|
const Token *tokAt(int index) const;
|
||||||
Token *tokAt(int index) {
|
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;
|
const Token *linkAt(int index) const;
|
||||||
Token *linkAt(int index) {
|
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);
|
setFlag(fIsComplex, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const Token *findsimplematch(const Token *tok, const char pattern[]);
|
static const Token *findsimplematch(const Token *startTok, const char pattern[]);
|
||||||
static const Token *findsimplematch(const Token *tok, const char pattern[], const Token *end);
|
static const Token *findsimplematch(const Token *startTok, 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 *startTok, 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 const Token *findmatch(const Token *startTok, const char pattern[], const Token *end, unsigned int varId = 0);
|
||||||
static Token *findsimplematch(Token *tok, const char pattern[]) {
|
static Token *findsimplematch(Token *startTok, const char pattern[]) {
|
||||||
return const_cast<Token *>(findsimplematch(static_cast<const Token *>(tok), pattern));
|
return const_cast<Token *>(findsimplematch(const_cast<const Token *>(startTok), pattern));
|
||||||
}
|
}
|
||||||
static Token *findsimplematch(Token *tok, const char pattern[], const Token *end) {
|
static Token *findsimplematch(Token *startTok, const char pattern[], const Token *end) {
|
||||||
return const_cast<Token *>(findsimplematch(static_cast<const Token *>(tok), pattern, 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) {
|
static Token *findmatch(Token *startTok, const char pattern[], unsigned int varId = 0) {
|
||||||
return const_cast<Token *>(findmatch(static_cast<const Token *>(tok), pattern, varId));
|
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) {
|
static Token *findmatch(Token *startTok, const char pattern[], const Token *end, unsigned int varId = 0) {
|
||||||
return const_cast<Token *>(findmatch(static_cast<const Token *>(tok), pattern, end, varId));
|
return const_cast<Token *>(findmatch(const_cast<const Token *>(startTok), pattern, end, varId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue