@@ -8,16 +8,18 @@ struct ForwardTraversal {
88 ValuePtr<ForwardAnalyzer> analyzer;
99 const Settings* settings;
1010
11- std::pair<bool , bool > evalCond (const Token* tok)
12- {
11+ std::pair<bool , bool > evalCond (const Token* tok) {
1312 std::vector<int > result = analyzer->evaluate (tok);
14- bool checkThen = std::any_of (result.begin (), result.end (), [](int x) { return x; });
15- bool checkElse = std::any_of (result.begin (), result.end (), [](int x) { return !x; });
13+ bool checkThen = std::any_of (result.begin (), result.end (), [](int x) {
14+ return x;
15+ });
16+ bool checkElse = std::any_of (result.begin (), result.end (), [](int x) {
17+ return !x;
18+ });
1619 return std::make_pair (checkThen, checkElse);
1720 }
1821
19- Progress update (Token* tok)
20- {
22+ Progress update (Token* tok) {
2123 ForwardAnalyzer::Action action = analyzer->analyze (tok);
2224 if (!action.isNone ())
2325 analyzer->update (tok, action);
@@ -26,8 +28,7 @@ struct ForwardTraversal {
2628 return Progress::Continue;
2729 }
2830
29- Progress updateTok (Token* tok, Token** out = nullptr )
30- {
31+ Progress updateTok (Token* tok, Token** out = nullptr ) {
3132 if (Token::Match (tok, " asm|goto|continue|setjmp|longjmp" ))
3233 return Progress::Break;
3334 else if (Token::Match (tok, " return|throw" ) || isEscapeFunction (tok, &settings->library )) {
@@ -57,8 +58,7 @@ struct ForwardTraversal {
5758 return Progress::Continue;
5859 }
5960
60- Progress updateRecursive (Token* tok)
61- {
61+ Progress updateRecursive (Token* tok) {
6262 if (!tok)
6363 return Progress::Continue;
6464 if (tok->astOperand1 () && updateRecursive (tok->astOperand1 ()) == Progress::Break)
@@ -71,8 +71,7 @@ struct ForwardTraversal {
7171 return Progress::Continue;
7272 }
7373
74- Progress updateConditional (Token* tok)
75- {
74+ Progress updateConditional (Token* tok) {
7675 if (Token::Match (tok, " ?|&&|%oror%" )) {
7776 Token* condTok = tok->astOperand1 ();
7877 if (updateRecursive (condTok) == Progress::Break)
@@ -105,8 +104,7 @@ struct ForwardTraversal {
105104 }
106105
107106 template <class T , class Predicate >
108- T* findRange (T* start, const Token* end, Predicate pred)
109- {
107+ T* findRange (T* start, const Token* end, Predicate pred) {
110108 for (T* tok = start; tok && tok != end; tok = tok->next ()) {
111109 ForwardAnalyzer::Action action = analyzer->analyze (tok);
112110 if (pred (action))
@@ -116,13 +114,13 @@ struct ForwardTraversal {
116114 }
117115
118116 template <class T >
119- T* findActionRange (T* start, const Token* end, ForwardAnalyzer::Action action)
120- {
121- return findRange (start, end, [&](ForwardAnalyzer::Action a) { return a == action; });
117+ T* findActionRange (T* start, const Token* end, ForwardAnalyzer::Action action) {
118+ return findRange (start, end, [&](ForwardAnalyzer::Action a) {
119+ return a == action;
120+ });
122121 }
123122
124- ForwardAnalyzer::Action analyzeRange (const Token* start, const Token* end)
125- {
123+ ForwardAnalyzer::Action analyzeRange (const Token* start, const Token* end) {
126124 ForwardAnalyzer::Action result = ForwardAnalyzer::Action::None;
127125 for (const Token* tok = start; tok && tok != end; tok = tok->next ()) {
128126 ForwardAnalyzer::Action action = analyzer->analyze (tok);
@@ -133,18 +131,18 @@ struct ForwardTraversal {
133131 return result;
134132 }
135133
136- void forkScope (const Token* endBlock, bool isModified = false )
137- {
134+ void forkScope (const Token* endBlock, bool isModified = false ) {
138135 if (analyzer->updateScope (endBlock, isModified)) {
139136 ForwardTraversal ft = *this ;
140137 ft.updateRange (endBlock->link (), endBlock);
141138 }
142139 }
143140
144- static bool hasGoto (const Token* endBlock) { return Token::findsimplematch (endBlock->link (), " goto" , endBlock); }
141+ static bool hasGoto (const Token* endBlock) {
142+ return Token::findsimplematch (endBlock->link (), " goto" , endBlock);
143+ }
145144
146- bool isEscapeScope (const Token* endBlock, bool unknown = false )
147- {
145+ bool isEscapeScope (const Token* endBlock, bool unknown = false ) {
148146 const Token* ftok = nullptr ;
149147 bool r = isReturnScope (endBlock, &settings->library , &ftok);
150148 if (!r && ftok)
@@ -159,17 +157,17 @@ struct ForwardTraversal {
159157 Inconclusive,
160158 };
161159
162- ForwardAnalyzer::Action analyzeScope (const Token* endBlock) { return analyzeRange (endBlock->link (), endBlock); }
160+ ForwardAnalyzer::Action analyzeScope (const Token* endBlock) {
161+ return analyzeRange (endBlock->link (), endBlock);
162+ }
163163
164- ForwardAnalyzer::Action checkScope (const Token* endBlock)
165- {
164+ ForwardAnalyzer::Action checkScope (const Token* endBlock) {
166165 ForwardAnalyzer::Action a = analyzeScope (endBlock);
167166 forkScope (endBlock, a.isModified ());
168167 return a;
169168 }
170169
171- Progress updateLoop (Token* endBlock, Token* condTok)
172- {
170+ Progress updateLoop (Token* endBlock, Token* condTok) {
173171 ForwardAnalyzer::Action a = analyzeScope (endBlock);
174172 if (a.isInconclusive ()) {
175173 if (!analyzer->lowerToInconclusive ())
@@ -193,8 +191,7 @@ struct ForwardTraversal {
193191 return Progress::Continue;
194192 }
195193
196- Progress updateRange (Token* start, const Token* end)
197- {
194+ Progress updateRange (Token* start, const Token* end) {
198195 for (Token* tok = start; tok && tok != end; tok = tok->next ()) {
199196 Token* next = nullptr ;
200197
@@ -348,15 +345,13 @@ struct ForwardTraversal {
348345 return Progress::Continue;
349346 }
350347
351- static bool isUnevaluated (const Token* tok)
352- {
348+ static bool isUnevaluated (const Token* tok) {
353349 if (Token::Match (tok->previous (), " sizeof|decltype (" ))
354350 return true ;
355351 return false ;
356352 }
357353
358- static Token* assignExpr (Token* tok)
359- {
354+ static Token* assignExpr (Token* tok) {
360355 while (tok->astParent () && astIsLHS (tok)) {
361356 if (Token::Match (tok->astParent (), " %assign%" ))
362357 return tok->astParent ();
@@ -365,15 +360,13 @@ struct ForwardTraversal {
365360 return nullptr ;
366361 }
367362
368- static const Scope* findBreakScope (const Scope* scope)
369- {
363+ static const Scope* findBreakScope (const Scope* scope) {
370364 while (scope && scope->type != Scope::eWhile && scope->type != Scope::eFor && scope->type != Scope::eSwitch)
371365 scope = scope->nestedIn ;
372366 return scope;
373367 }
374368
375- static Token* skipTo (Token* tok, const Token* dest, const Token* end = nullptr )
376- {
369+ static Token* skipTo (Token* tok, const Token* dest, const Token* end = nullptr ) {
377370 if (end && dest->index () > end->index ())
378371 return nullptr ;
379372 int i = dest->index () - tok->index ();
@@ -382,8 +375,7 @@ struct ForwardTraversal {
382375 return nullptr ;
383376 }
384377
385- static bool isConditional (const Token* tok)
386- {
378+ static bool isConditional (const Token* tok) {
387379 const Token* parent = tok->astParent ();
388380 while (parent && !Token::Match (parent, " %oror%|&&|:" )) {
389381 tok = parent;
@@ -393,8 +385,7 @@ struct ForwardTraversal {
393385 }
394386
395387 template <class T >
396- static T* getInitTok (T* tok)
397- {
388+ static T* getInitTok (T* tok) {
398389 if (!tok)
399390 return nullptr ;
400391 if (Token::Match (tok, " %name% (" ))
0 commit comments