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

Method stringify

lib/token.cpp:1270–1316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1268}
1269
1270std::string Token::stringify(const stringifyOptions& options) const
1271{
1272 std::string ret;
1273 if (options.attributes) {
1274 if (isUnsigned())
1275 ret += "unsigned ";
1276 else if (isSigned())
1277 ret += "signed ";
1278 if (isComplex())
1279 ret += "_Complex ";
1280 if (isLong()) {
1281 if (!(mTokType == eString || mTokType == eChar))
1282 ret += "long ";
1283 }
1284 }
1285 if (options.macro && isExpandedMacro())
1286 ret += '$';
1287 if (isName() && mStr.find(' ') != std::string::npos) {
1288 for (const char i : mStr) {
1289 if (i != ' ')
1290 ret += i;
1291 }
1292 } else if (mStr[0] != '\"' || mStr.find('\0') == std::string::npos)
1293 ret += mStr;
1294 else {
1295 for (const char i : mStr) {
1296 if (i == '\0')
1297 ret += "\\0";
1298 else
1299 ret += i;
1300 }
1301 }
1302 if (options.varid && mImpl->mVarId != 0) {
1303 ret += '@';
1304 ret += (options.idtype ? "var" : "");
1305 ret += std::to_string(mImpl->mVarId);
1306 } else if (options.exprid && mImpl->mExprId != 0) {
1307 ret += '@';
1308 ret += (options.idtype ? "expr" : "");
1309 if ((mImpl->mExprId & (1U << efIsUnique)) != 0)
1310 ret += "UNIQUE";
1311 else
1312 ret += std::to_string(mImpl->mExprId);
1313 }
1314
1315 return ret;
1316}
1317
1318std::string Token::stringify(bool varid, bool attributes, bool macro) const
1319{

Callers 5

argumentTypeMethod · 0.45
fileLineMethod · 0.45
printOutMethod · 0.45
stringifyListMethod · 0.45
checkDuplicateBranchMethod · 0.45

Calls 7

isUnsignedFunction · 0.85
isSignedFunction · 0.85
isComplexFunction · 0.85
isLongFunction · 0.85
isExpandedMacroFunction · 0.85
isNameFunction · 0.85
findMethod · 0.45

Tested by

no test coverage detected