Preprocessor: Removed unused function renameMacroVariables
This commit is contained in:
parent
e68c1aec21
commit
e064208f54
|
@ -1424,72 +1424,6 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To avoid name collisions, we will rename macro variables by
|
||||
* adding _prefix in front of the name of each variable.
|
||||
* Returns the macro with converted names
|
||||
* @param result If return value is false, this is not touched. If
|
||||
* return value is true, this will contain new macro line
|
||||
* (all that comes after #define) e.g.
|
||||
* "A(__cppcheck__x) foo(__cppcheck__x);"
|
||||
* @param macro The macro which is about to cause name collision.
|
||||
* @return true if code needs to be changed, false is no changes
|
||||
* are required.
|
||||
*/
|
||||
bool renameMacroVariables(std::string &result, const PreprocessorMacro ¯o)
|
||||
{
|
||||
// No variables
|
||||
if (_params.empty())
|
||||
return false;
|
||||
|
||||
// Already renamed
|
||||
if (_params[0].compare(0, _prefix.length(), _prefix) == 0)
|
||||
return false;
|
||||
|
||||
// Check does the macro contain tokens that have
|
||||
// the same name as parameters in this macro.
|
||||
const Token *tok = macro.tokens();
|
||||
if (Token::Match(tok->next(), "("))
|
||||
{
|
||||
std::map<std::string, bool> paramMap;
|
||||
for (unsigned int i = 0; i < _params.size(); ++i)
|
||||
paramMap[_params[i]] = true;
|
||||
|
||||
bool collision = false;
|
||||
tok = Token::findmatch(tok, ")", 0);
|
||||
for (; tok; tok = tok->next())
|
||||
{
|
||||
if (paramMap.find(tok->str()) != paramMap.end())
|
||||
{
|
||||
// Name collision
|
||||
collision = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!collision)
|
||||
return false;
|
||||
}
|
||||
|
||||
result = "";
|
||||
result.append(_name);
|
||||
result.append("(");
|
||||
std::vector<std::string> values;
|
||||
for (unsigned int i = 0; i < _params.size(); ++i)
|
||||
{
|
||||
if (i > 0)
|
||||
result.append(",");
|
||||
values.push_back(_prefix + _params[i]);
|
||||
result.append(values.back());
|
||||
}
|
||||
|
||||
result.append(") ");
|
||||
std::string temp;
|
||||
this->code(values, temp);
|
||||
result.append(temp);
|
||||
return true;
|
||||
}
|
||||
|
||||
/** return tokens of this macro */
|
||||
const Token *tokens() const
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue