MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / simplifyName

Function simplifyName

externals/simplecpp/simplecpp.cpp:2733–2753  ·  view source on GitHub ↗

Evaluate name * @throws std::runtime_error thrown on undefined function-like macro */

Source from the content-addressed store, hash-verified

2731 * @throws std::runtime_error thrown on undefined function-like macro
2732 */
2733static void simplifyName(simplecpp::TokenList &expr)
2734{
2735 for (simplecpp::Token *tok = expr.front(); tok; tok = tok->next) {
2736 if (tok->name) {
2737 static const std::set<std::string> altop{"and","or","bitand","bitor","compl","not","not_eq","xor"};
2738 if (altop.find(tok->str()) != altop.end()) {
2739 bool alt;
2740 if (tok->str() == "not" || tok->str() == "compl") {
2741 alt = isAlternativeUnaryOp(tok,tok->str());
2742 } else {
2743 alt = isAlternativeBinaryOp(tok,tok->str());
2744 }
2745 if (alt)
2746 continue;
2747 }
2748 if (tok->next && tok->next->str() == "(")
2749 throw std::runtime_error("undefined function-like macro invocation: " + tok->str() + "( ... )");
2750 tok->setstr("0");
2751 }
2752 }
2753}
2754
2755/*
2756 * Reads at least minlen and at most maxlen digits (inc. prefix) in base base

Callers 1

evaluateFunction · 0.85

Calls 6

isAlternativeUnaryOpFunction · 0.85
isAlternativeBinaryOpFunction · 0.85
frontMethod · 0.80
findMethod · 0.45
strMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected