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

Method simplifyAlignedStorage

lib/tokenize.cpp:11214–11263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11212}
11213
11214void Tokenizer::simplifyAlignedStorage()
11215{
11216 if (!isCPP())
11217 return;
11218
11219 const Standards::cppstd_t std = mSettings.standards.cpp;
11220 if (std < Standards::CPP11 || std >= Standards::CPP23)
11221 return;
11222
11223 for (Token *tok = list.front(); tok; tok = tok->next()) {
11224 if (!Token::simpleMatch(tok, "std :: aligned_storage <"))
11225 continue;
11226
11227 tok = tok->tokAt(3);
11228 const Token *end = tok->link();
11229 tok = tok->next();
11230
11231 if (!tok)
11232 break;
11233
11234 if (!end)
11235 continue;
11236
11237 for (; tok != end; tok = tok->next()) {
11238 if (Token::simpleMatch(tok, ",")) {
11239 tok = tok->next();
11240 break;
11241 }
11242
11243 if (Token::Match(tok, "(|<"))
11244 tok = tok->link();
11245 }
11246
11247 std::string str;
11248 for (; tok != end; tok = tok->next()) {
11249 str += " " + tok->str();
11250 }
11251
11252 if (str.empty())
11253 continue;
11254
11255 if (!Token::Match(tok, "> :: type %name%"))
11256 continue;
11257
11258 str = str.substr(1);
11259
11260 tok = tok->tokAt(3);
11261 tok->addAttributeAlignas(str);
11262 }
11263}
11264
11265void Tokenizer::setDirectives(std::list<Directive> directives)
11266{

Callers

nothing calls this directly

Calls 8

isCPPFunction · 0.85
frontMethod · 0.80
nextMethod · 0.80
addAttributeAlignasMethod · 0.80
simpleMatchFunction · 0.70
tokAtMethod · 0.45
strMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected