SymbolDatabase: rename _start and _end

This commit is contained in:
Daniel Marjamäki 2018-06-16 16:03:36 +02:00
parent 311454669f
commit 8209c4aebd
2 changed files with 28 additions and 28 deletions

View File

@ -1622,10 +1622,10 @@ void Variable::evaluate(const Library* lib)
if (mNameToken) if (mNameToken)
setFlag(fIsArray, arrayDimensions(lib)); setFlag(fIsArray, arrayDimensions(lib));
const Token* tok = _start; const Token* tok = mTypeStartToken;
while (tok && tok->previous() && tok->previous()->isName()) while (tok && tok->previous() && tok->previous()->isName())
tok = tok->previous(); tok = tok->previous();
const Token* end = _end; const Token* end = mTypeEndToken;
if (end) if (end)
end = end->next(); end = end->next();
while (tok != end) { while (tok != end) {
@ -1659,24 +1659,24 @@ void Variable::evaluate(const Library* lib)
tok = tok->next(); tok = tok->next();
} }
while (Token::Match(_start, "static|const|volatile %any%")) while (Token::Match(mTypeStartToken, "static|const|volatile %any%"))
_start = _start->next(); mTypeStartToken = mTypeStartToken->next();
while (_end && _end->previous() && Token::Match(_end, "const|volatile")) while (mTypeEndToken && mTypeEndToken->previous() && Token::Match(mTypeEndToken, "const|volatile"))
_end = _end->previous(); mTypeEndToken = mTypeEndToken->previous();
if (_start) { if (mTypeStartToken) {
std::string strtype = _start->str(); std::string strtype = mTypeStartToken->str();
for (const Token *typeToken = _start; Token::Match(typeToken, "%type% :: %type%"); typeToken = typeToken->tokAt(2)) for (const Token *typeToken = mTypeStartToken; Token::Match(typeToken, "%type% :: %type%"); typeToken = typeToken->tokAt(2))
strtype += "::" + typeToken->strAt(2); strtype += "::" + typeToken->strAt(2);
setFlag(fIsClass, !lib->podtype(strtype) && !_start->isStandardType() && !isEnumType() && !isPointer() && !isReference()); setFlag(fIsClass, !lib->podtype(strtype) && !mTypeStartToken->isStandardType() && !isEnumType() && !isPointer() && !isReference());
setFlag(fIsStlType, Token::simpleMatch(_start, "std ::")); setFlag(fIsStlType, Token::simpleMatch(mTypeStartToken, "std ::"));
setFlag(fIsStlString, isStlType() && (Token::Match(_start->tokAt(2), "string|wstring|u16string|u32string !!::") || (Token::simpleMatch(_start->tokAt(2), "basic_string <") && !Token::simpleMatch(_start->linkAt(3), "> ::")))); setFlag(fIsStlString, isStlType() && (Token::Match(mTypeStartToken->tokAt(2), "string|wstring|u16string|u32string !!::") || (Token::simpleMatch(mTypeStartToken->tokAt(2), "basic_string <") && !Token::simpleMatch(mTypeStartToken->linkAt(3), "> ::"))));
} }
if (_access == Argument) { if (_access == Argument) {
tok = mNameToken; tok = mNameToken;
if (!tok) { if (!tok) {
// Argument without name // Argument without name
tok = _end; tok = mTypeEndToken;
// back up to start of array dimensions // back up to start of array dimensions
while (tok && tok->str() == "]") while (tok && tok->str() == "]")
tok = tok->link()->previous(); tok = tok->link()->previous();
@ -1702,8 +1702,8 @@ void Variable::evaluate(const Library* lib)
setFlag(fHasDefault, true); setFlag(fHasDefault, true);
} }
if (_start) { if (mTypeStartToken) {
if (Token::Match(_start, "float|double")) if (Token::Match(mTypeStartToken, "float|double"))
setFlag(fIsFloatType, true); setFlag(fIsFloatType, true);
} }
} }
@ -2445,9 +2445,9 @@ bool Type::isDerivedFrom(const std::string & ancestor) const
bool Variable::arrayDimensions(const Library* lib) bool Variable::arrayDimensions(const Library* lib)
{ {
const Library::Container* container = lib->detectContainer(_start); const Library::Container* container = lib->detectContainer(mTypeStartToken);
if (container && container->arrayLike_indexOp && container->size_templateArgNo > 0) { if (container && container->arrayLike_indexOp && container->size_templateArgNo > 0) {
const Token* tok = Token::findsimplematch(_start, "<"); const Token* tok = Token::findsimplematch(mTypeStartToken, "<");
if (tok) { if (tok) {
Dimension dimension_; Dimension dimension_;
tok = tok->next(); tok = tok->next();
@ -2473,7 +2473,7 @@ bool Variable::arrayDimensions(const Library* lib)
const Token *dim = mNameToken; const Token *dim = mNameToken;
if (!dim) { if (!dim) {
// Argument without name // Argument without name
dim = _end; dim = mTypeEndToken;
// back up to start of array dimensions // back up to start of array dimensions
while (dim && dim->str() == "]") while (dim && dim->str() == "]")
dim = dim->link()->previous(); dim = dim->link()->previous();
@ -2604,8 +2604,8 @@ void SymbolDatabase::printVariable(const Variable *var, const char *indent) cons
if (var->nameToken()) { if (var->nameToken()) {
std::cout << indent << " declarationId: " << var->declarationId() << std::endl; std::cout << indent << " declarationId: " << var->declarationId() << std::endl;
} }
std::cout << indent << "_start: " << tokenToString(var->typeStartToken(), _tokenizer) << std::endl; std::cout << indent << "mTypeStartToken: " << tokenToString(var->typeStartToken(), _tokenizer) << std::endl;
std::cout << indent << "_end: " << tokenToString(var->typeEndToken(), _tokenizer) << std::endl; std::cout << indent << "mTypeEndToken: " << tokenToString(var->typeEndToken(), _tokenizer) << std::endl;
const Token * autoTok = nullptr; const Token * autoTok = nullptr;
std::cout << indent << " "; std::cout << indent << " ";

View File

@ -223,8 +223,8 @@ public:
std::size_t index_, AccessControl access_, const Type *type_, std::size_t index_, AccessControl access_, const Type *type_,
const Scope *scope_, const Library* lib) const Scope *scope_, const Library* lib)
: mNameToken(name_), : mNameToken(name_),
_start(start_), mTypeStartToken(start_),
_end(end_), mTypeEndToken(end_),
_index(index_), _index(index_),
_access(access_), _access(access_),
_flags(0), _flags(0),
@ -251,7 +251,7 @@ public:
* @return type start token * @return type start token
*/ */
const Token *typeStartToken() const { const Token *typeStartToken() const {
return _start; return mTypeStartToken;
} }
/** /**
@ -263,7 +263,7 @@ public:
* @return type end token * @return type end token
*/ */
const Token *typeEndToken() const { const Token *typeEndToken() const {
return _end; return mTypeEndToken;
} }
/** /**
@ -564,7 +564,7 @@ public:
* @return true if it is an stl type and its type matches any of the types in 'stlTypes' * @return true if it is an stl type and its type matches any of the types in 'stlTypes'
*/ */
bool isStlType(const std::string& stlType) const { bool isStlType(const std::string& stlType) const {
return isStlType() && stlType==_start->strAt(2); return isStlType() && stlType==mTypeStartToken->strAt(2);
} }
/** /**
@ -578,7 +578,7 @@ public:
* @return true if it is an stl type and its type matches any of the types in 'stlTypes' * @return true if it is an stl type and its type matches any of the types in 'stlTypes'
*/ */
bool isStlType(const std::set<std::string>& stlTypes) const { bool isStlType(const std::set<std::string>& stlTypes) const {
return isStlType() && stlTypes.find(_start->strAt(2))!=stlTypes.end(); return isStlType() && stlTypes.find(mTypeStartToken->strAt(2))!=stlTypes.end();
} }
/** /**
@ -619,10 +619,10 @@ private:
const Token *mNameToken; const Token *mNameToken;
/** @brief variable type start token */ /** @brief variable type start token */
const Token *_start; const Token *mTypeStartToken;
/** @brief variable type end token */ /** @brief variable type end token */
const Token *_end; const Token *mTypeEndToken;
/** @brief order declared */ /** @brief order declared */
std::size_t _index; std::size_t _index;