@@ -6011,6 +6011,9 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
60116011 // Link < with >
60126012 createLinks2 ();
60136013
6014+ // Handle std::aligned_storage<...>
6015+ simplifyAlignedStorage ();
6016+
60146017 // Mark C++ casts
60156018 markCppCasts ();
60166019
@@ -10361,6 +10364,8 @@ void Tokenizer::simplifyNamespaceStd()
1036110364 mSettings .library .podtype (" std::" + tok->str ()) ||
1036210365 isStdContainerOrIterator (tok, mSettings ))
1036310366 insert = true ;
10367+ else if (Token::simpleMatch (tok, " aligned_storage" ))
10368+ insert = true ;
1036410369
1036510370 if (insert) {
1036610371 tok->previous ()->insertToken (" std" );
@@ -11176,6 +11181,57 @@ void Tokenizer::simplifyNamespaceAliases()
1117611181 }
1117711182}
1117811183
11184+ void Tokenizer::simplifyAlignedStorage ()
11185+ {
11186+ if (!isCPP ())
11187+ return ;
11188+
11189+ const Standards::cppstd_t std = mSettings .standards .cpp ;
11190+ if (std < Standards::CPP11 || std >= Standards::CPP23)
11191+ return ;
11192+
11193+ for (Token *tok = list.front (); tok; tok = tok->next ()) {
11194+ if (!Token::simpleMatch (tok, " std :: aligned_storage <" ))
11195+ continue ;
11196+
11197+ tok = tok->tokAt (3 );
11198+ const Token *end = tok->link ();
11199+ tok = tok->next ();
11200+
11201+ if (!tok)
11202+ break ;
11203+
11204+ if (!end)
11205+ continue ;
11206+
11207+ for (; tok != end; tok = tok->next ()) {
11208+ if (Token::simpleMatch (tok, " ," )) {
11209+ tok = tok->next ();
11210+ break ;
11211+ }
11212+
11213+ if (Token::Match (tok, " (|<" ))
11214+ tok = tok->link ();
11215+ }
11216+
11217+ std::string str;
11218+ for (; tok != end; tok = tok->next ()) {
11219+ str += " " + tok->str ();
11220+ }
11221+
11222+ if (str.empty ())
11223+ continue ;
11224+
11225+ if (!Token::Match (tok, " > :: type %name%" ))
11226+ continue ;
11227+
11228+ str = str.substr (1 );
11229+
11230+ tok = tok->tokAt (3 );
11231+ tok->addAttributeAlignas (str);
11232+ }
11233+ }
11234+
1117911235void Tokenizer::setDirectives (std::list<Directive> directives)
1118011236{
1118111237 mDirectives = std::move (directives);
0 commit comments