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

Method constFoldShift

externals/simplecpp/simplecpp.cpp:1254–1275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1252}
1253
1254void simplecpp::TokenList::constFoldShift(Token *tok)
1255{
1256 for (; tok && tok->op != ')'; tok = tok->next) {
1257 if (!tok->previous || !tok->previous->number)
1258 continue;
1259 if (!tok->next || !tok->next->number)
1260 continue;
1261
1262 long long result;
1263 if (tok->str() == "<<")
1264 result = stringToLL(tok->previous->str()) << stringToLL(tok->next->str());
1265 else if (tok->str() == ">>")
1266 result = stringToLL(tok->previous->str()) >> stringToLL(tok->next->str());
1267 else
1268 continue;
1269
1270 tok = tok->previous;
1271 tok->setstr(toString(result));
1272 deleteToken(tok->next);
1273 deleteToken(tok->next);
1274 }
1275}
1276
1277static const std::string NOTEQ("not_eq");
1278void simplecpp::TokenList::constFoldComparison(Token *tok)

Callers

nothing calls this directly

Calls 4

stringToLLFunction · 0.85
deleteTokenFunction · 0.85
toStringFunction · 0.70
strMethod · 0.45

Tested by

no test coverage detected