File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -148,6 +148,15 @@ class Variables {
148148 void clear () {
149149 mVarUsage .clear ();
150150 }
151+ void clearConst () {
152+ std::set<int > keys;
153+ for (const std::pair<const nonneg int , Variables::VariableUsage>& var : mVarUsage ) {
154+ if (var.second ._var && var.second ._var ->isConst ())
155+ keys.emplace (var.first );
156+ }
157+ for (const int key : keys)
158+ mvarUsage.erase (key);
159+ }
151160 const std::map<nonneg int , VariableUsage> &varUsage () const {
152161 return mVarUsage ;
153162 }
@@ -796,9 +805,8 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
796805 // templates
797806 if (tok->isName () && endsWith (tok->str (), ' >' )) {
798807 // TODO: This is a quick fix to handle when constants are used
799- // as template parameters. Try to handle this better, perhaps
800- // only remove constants.
801- variables.clear ();
808+ // as template parameters.
809+ variables.clearConst ();
802810 }
803811
804812 else if (Token::Match (tok->previous (), " [;{}]" )) {
You can’t perform that action at this time.
0 commit comments