@@ -110,23 +110,15 @@ class CppCheck::CppCheckLogger : public ErrorLogger
110110 void setLocationMacros (const Token* startTok, const std::vector<std::string>& files, const std::list<simplecpp::MacroUsage>& macroUsage)
111111 {
112112 mLocationMacros .clear ();
113- std::set<std::string> usedNames;
114- std::transform (macroUsage.cbegin (), macroUsage.cend (), std::inserter (usedNames, usedNames.end ()), [](const simplecpp::MacroUsage& usage) {
115- return usage.macroName ;
116- });
117- std::set<std::pair<Location, int >> unexpanded;
118113 for (const Token* tok = startTok; tok; tok = tok->next ()) {
119- const Location loc (files[tok->fileIndex ()], tok->linenr ());
120114 if (!tok->getMacroName ().empty ())
121- mLocationMacros [loc].emplace (tok->getMacroName ());
122- else if (tok->isName () && usedNames.count (tok->str ()) != 0 )
123- unexpanded.emplace (loc, tok->column ());
115+ mLocationMacros [Location (files[tok->fileIndex ()], tok->linenr ())].emplace (tok->getMacroName ());
124116 }
125- // a token only knows the innermost macro it was expanded from; usages that produced no tokens are skipped
117+ // a token only knows the innermost macro it was expanded from; usages on lines without macro-expanded tokens are skipped
126118 for (const simplecpp::MacroUsage& usage : macroUsage) {
127119 const Location loc (files[usage.useLocation .fileIndex ], usage.useLocation .line );
128120 const auto it = mLocationMacros .find (loc);
129- if (it != mLocationMacros .end () && unexpanded. count ({loc, usage. useLocation . col }) == 0 )
121+ if (it != mLocationMacros .end ())
130122 it->second .emplace (usage.macroName );
131123 }
132124 }
0 commit comments