@@ -163,7 +163,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
163163void SymbolDatabase::findAllScopes (const Token* startToken, const Token* endToken, Scope* startScope)
164164{
165165 // pointer to current scope
166- Scope * scope = startScope;
166+ Scope* scope = startScope;
167167
168168 // Store the ending of init lists
169169 std::stack<std::pair<const Token*, const Scope*>> endInitList;
@@ -218,7 +218,7 @@ void SymbolDatabase::findAllScopes(const Token* startToken, const Token* endToke
218218 ProgressReporter progressReporter (mErrorLogger , mSettings .reportProgress , mTokenizer .list .getSourceFilePath (), " SymbolDatabase (find all scopes)" );
219219
220220 // find all scopes
221- for (const Token * tok = startToken; tok && tok != endToken; tok = tok ? tok->next () : nullptr ) {
221+ for (const Token* tok = startToken; tok && tok != endToken; tok = tok ? tok->next () : nullptr ) {
222222 // #5593 suggested to add here:
223223
224224 progressReporter.report (tok->progressValue ());
@@ -962,7 +962,7 @@ void SymbolDatabase::setFunctionReturnType(Function& function, const Scope& scop
962962{
963963 if (!function.retDef )
964964 return ;
965- const Token * type = function.retDef ;
965+ const Token* type = function.retDef ;
966966 while (Token::Match (type, " static|const|struct|union|enum" ))
967967 type = type->next ();
968968 if (type) {
@@ -1084,13 +1084,13 @@ void SymbolDatabase::createSymbolDatabaseNeedInitialization()
10841084
10851085void SymbolDatabase::addVariablesToSymbolTable (Scope& scope)
10861086{
1087- for (Variable& var: scope.varlist ) {
1087+ for (Variable& var : scope.varlist ) {
10881088 const int varId = var.declarationId ();
10891089 if (varId)
10901090 mVariableList [varId] = &var;
10911091 // fix up variables without type
10921092 if (!var.type () && !var.typeStartToken ()->isStandardType ()) {
1093- const Type * type = findType (var.typeStartToken (), &scope);
1093+ const Type* type = findType (var.typeStartToken (), &scope);
10941094 if (type)
10951095 var.type (type);
10961096 }
@@ -1099,14 +1099,14 @@ void SymbolDatabase::addVariablesToSymbolTable(Scope& scope)
10991099
11001100void SymbolDatabase::addArgumentsToSymbolTable (Function& function, const Scope& scope)
11011101{
1102- for (Variable& arg: function.argumentList ) {
1102+ for (Variable& arg : function.argumentList ) {
11031103 // check for named parameters
11041104 if (arg.nameToken () && arg.declarationId ()) {
11051105 const int declarationId = arg.declarationId ();
11061106 mVariableList [declarationId] = &arg;
11071107 // fix up parameters without type
11081108 if (!arg.type () && !arg.typeStartToken ()->isStandardType ()) {
1109- const Type * type = findTypeInNested (arg.typeStartToken (), &scope);
1109+ const Type* type = findTypeInNested (arg.typeStartToken (), &scope);
11101110 if (type)
11111111 arg.type (type);
11121112 }
@@ -1116,7 +1116,7 @@ void SymbolDatabase::addArgumentsToSymbolTable(Function& function, const Scope&
11161116
11171117void SymbolDatabase::fillMissingVariables (const Scope& functionScope)
11181118{
1119- for (const Token * tok = functionScope.bodyStart ->next (); tok && tok != functionScope.bodyEnd ; tok = tok->next ()) {
1119+ for (const Token* tok = functionScope.bodyStart ->next (); tok && tok != functionScope.bodyEnd ; tok = tok->next ()) {
11201120 // check for member variable
11211121 if (!Token::Match (tok, " %var% .|[" ))
11221122 continue ;
@@ -1125,9 +1125,9 @@ void SymbolDatabase::fillMissingVariables(const Scope& functionScope)
11251125 tokDot = tokDot->link ()->next ();
11261126 if (!Token::Match (tokDot, " . %var%" ))
11271127 continue ;
1128- const Token * member = tokDot->next ();
1128+ const Token* member = tokDot->next ();
11291129 if (mVariableList [member->varId ()] == nullptr ) {
1130- const Variable * var1 = mVariableList [tok->varId ()];
1130+ const Variable* var1 = mVariableList [tok->varId ()];
11311131 if (var1 && var1->typeScope ()) {
11321132 const Variable* memberVar = var1->typeScope ()->getVariable (member->str ());
11331133 if (memberVar) {
@@ -1153,7 +1153,7 @@ void SymbolDatabase::createSymbolDatabaseVariableSymbolTable()
11531153 }
11541154
11551155 // fill in missing variables if possible
1156- for (const Scope * func: functionScopes)
1156+ for (const Scope* func : functionScopes)
11571157 fillMissingVariables (*func);
11581158}
11591159
@@ -1881,10 +1881,16 @@ void SymbolDatabase::removeSymbolsForTokens(const std::unordered_set<const Token
18811881 if ((scope.classDef && removedTokens.count (scope.classDef ) != 0 ) ||
18821882 (scope.bodyStart && removedTokens.count (scope.bodyStart ) != 0 )) {
18831883 removedScopes.insert (&scope);
1884- std::transform (scope.varlist .cbegin (), scope.varlist .cend (), std::inserter (removedVariables, removedVariables.end ()), [](const Variable& var) {
1884+ std::transform (scope.varlist .cbegin (),
1885+ scope.varlist .cend (),
1886+ std::inserter (removedVariables, removedVariables.end ()),
1887+ [](const Variable& var) {
18851888 return &var;
18861889 });
1887- std::transform (scope.enumeratorList .cbegin (), scope.enumeratorList .cend (), std::inserter (removedEnumerators, removedEnumerators.end ()), [](const Enumerator& enumerator) {
1890+ std::transform (scope.enumeratorList .cbegin (),
1891+ scope.enumeratorList .cend (),
1892+ std::inserter (removedEnumerators, removedEnumerators.end ()),
1893+ [](const Enumerator& enumerator) {
18881894 return &enumerator;
18891895 });
18901896 }
@@ -1894,7 +1900,10 @@ void SymbolDatabase::removeSymbolsForTokens(const std::unordered_set<const Token
18941900 for (Function& function : scope.functionList ) {
18951901 if (function.tokenDef && removedTokens.count (function.tokenDef ) != 0 ) {
18961902 removedFunctions.insert (&function);
1897- std::transform (function.argumentList .cbegin (), function.argumentList .cend (), std::inserter (removedVariables, removedVariables.end ()), [](const Variable& arg) {
1903+ std::transform (function.argumentList .cbegin (),
1904+ function.argumentList .cend (),
1905+ std::inserter (removedVariables, removedVariables.end ()),
1906+ [](const Variable& arg) {
18981907 return &arg;
18991908 });
19001909 } else if (function.token && removedTokens.count (function.token ) != 0 ) {
@@ -1933,20 +1942,29 @@ void SymbolDatabase::removeSymbolsForTokens(const std::unordered_set<const Token
19331942 if (mVariableList [i] && removedVariables.count (mVariableList [i]) != 0 )
19341943 mVariableList [i] = nullptr ;
19351944 }
1936- functionScopes.erase (std::remove_if (functionScopes.begin (), functionScopes.end (), [&](const Scope* scope) {
1945+ functionScopes.erase (std::remove_if (functionScopes.begin (),
1946+ functionScopes.end (),
1947+ [&](const Scope* scope) {
19371948 return removedScopes.count (scope) != 0 ;
1938- }), functionScopes.end ());
1939- classAndStructScopes.erase (std::remove_if (classAndStructScopes.begin (), classAndStructScopes.end (), [&](const Scope* scope) {
1949+ }),
1950+ functionScopes.end ());
1951+ classAndStructScopes.erase (std::remove_if (classAndStructScopes.begin (),
1952+ classAndStructScopes.end (),
1953+ [&](const Scope* scope) {
19401954 return removedScopes.count (scope) != 0 ;
1941- }), classAndStructScopes.end ());
1955+ }),
1956+ classAndStructScopes.end ());
19421957
19431958 // remove from the owning scopes
19441959 for (Scope& scope : scopeList) {
19451960 if (removedScopes.count (&scope) != 0 )
19461961 continue ;
1947- scope.nestedList .erase (std::remove_if (scope.nestedList .begin (), scope.nestedList .end (), [&](const Scope* nested) {
1962+ scope.nestedList .erase (std::remove_if (scope.nestedList .begin (),
1963+ scope.nestedList .end (),
1964+ [&](const Scope* nested) {
19481965 return removedScopes.count (nested) != 0 ;
1949- }), scope.nestedList .end ());
1966+ }),
1967+ scope.nestedList .end ());
19501968 for (auto it = scope.functionMap .begin (); it != scope.functionMap .end ();) {
19511969 if (removedFunctions.count (it->second ) != 0 )
19521970 it = scope.functionMap .erase (it);
@@ -2008,8 +2026,7 @@ void SymbolDatabase::addSymbolsForNewTokenRanges(const std::vector<std::pair<Tok
20082026 // an anchor that closes the enclosing scope means the new tokens are in its parent.
20092027 // a namespace can consist of multiple blocks and bodyStart/bodyEnd only track the
20102028 // latest block - so for namespaces any closing brace with the namespace scope closes it.
2011- if (anchor && anchor->str () == " }" &&
2012- (anchor == enclosing->bodyEnd || enclosing->type == ScopeType::eNamespace))
2029+ if (anchor && anchor->str () == " }" && (anchor == enclosing->bodyEnd || enclosing->type == ScopeType::eNamespace))
20132030 enclosing = enclosing->nestedIn ? enclosing->nestedIn : &scopeList.front ();
20142031 findAllScopes (range.first , range.second ->next (), const_cast <Scope*>(enclosing));
20152032 }
@@ -2022,7 +2039,7 @@ void SymbolDatabase::addSymbolsForNewTokenRanges(const std::vector<std::pair<Tok
20222039 for (; it != scopeList.end (); ++it)
20232040 newScopes.push_back (&(*it));
20242041 }
2025- std::vector<std::pair<Function*, Scope*>> newFunctions; // the function and the scope it is declared in
2042+ std::vector<std::pair<Function*, Scope*>> newFunctions; // the function and the scope it is declared in
20262043 for (Scope& scope : scopeList) {
20272044 for (Function& function : scope.functionList ) {
20282045 if (function.tokenDef && newTokens.count (function.tokenDef ) != 0 )
@@ -2066,9 +2083,9 @@ void SymbolDatabase::addSymbolsForNewTokenRanges(const std::vector<std::pair<Tok
20662083 // pointers are updated afterwards by updateFunctionAndVariablePointers().
20672084 for (const auto & f : newFunctions) {
20682085 if (f.first ->tokenDef )
2069- const_cast <Token *>(f.first ->tokenDef )->function (f.first );
2086+ const_cast <Token*>(f.first ->tokenDef )->function (f.first );
20702087 if (f.first ->token )
2071- const_cast <Token *>(f.first ->token )->function (f.first );
2088+ const_cast <Token*>(f.first ->token )->function (f.first );
20722089 }
20732090
20742091 // type/enumerator pointers - these only set pointers that are not set, so the old
@@ -8004,15 +8021,15 @@ static int getIntegerConstantMacroWidth(const Token* tok) {
80048021 return intnum;
80058022}
80068023
8007- void SymbolDatabase::setValueTypeInTokenList (bool reportDebugWarnings, Token * tokens, const Token * endToken)
8024+ void SymbolDatabase::setValueTypeInTokenList (bool reportDebugWarnings, Token* tokens, const Token* endToken)
80088025{
80098026 if (!tokens)
80108027 tokens = mTokenizer .list .front ();
80118028
8012- for (Token * tok = tokens; tok && tok != endToken; tok = tok->next ())
8029+ for (Token* tok = tokens; tok && tok != endToken; tok = tok->next ())
80138030 tok->setValueType (nullptr );
80148031
8015- for (Token * tok = tokens; tok && tok != endToken; tok = tok->next ()) {
8032+ for (Token* tok = tokens; tok && tok != endToken; tok = tok->next ()) {
80168033 if (tok->isNumber ()) {
80178034 if (MathLib::isFloat (tok->str ())) {
80188035 ValueType::Type type = ValueType::Type::DOUBLE ;
@@ -8447,7 +8464,7 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
84478464 }
84488465
84498466 if (reportDebugWarnings && mSettings .debugwarnings ) {
8450- for (Token * tok = tokens; tok && tok != endToken; tok = tok->next ()) {
8467+ for (Token* tok = tokens; tok && tok != endToken; tok = tok->next ()) {
84518468 if (tok->str () == " auto" && !tok->valueType ()) {
84528469 if (Token::Match (tok->next (), " %name% ; %name% = [" ) && isLambdaCaptureList (tok->tokAt (5 )))
84538470 continue ;
0 commit comments