@@ -74,6 +74,10 @@ T* findToken(T* start, const Token* end, const Predicate& pred)
7474 return result;
7575}
7676
77+ bool findTokensSkipDeadCodeImplMatch_1 (const Token* tok);
78+ bool findTokensSkipDeadCodeImplMatch_2 (const Token* tok);
79+ bool findTokensSkipDeadCodeImplMatch_3 (const Token* tok);
80+
7781template <class T ,
7882 class Predicate ,
7983 class Found ,
@@ -92,7 +96,8 @@ bool findTokensSkipDeadCodeImpl(const Library& library,
9296 if (found (tok))
9397 return true ;
9498 }
95- if (Token::Match (tok, " if|for|while (" ) && Token::simpleMatch (tok->linkAt (1 ), " ) {" )) {
99+ // if (Token::Match(tok, "if|for|while (") && Token::simpleMatch(tok->linkAt(1), ") {")) {
100+ if (findTokensSkipDeadCodeImplMatch_1 (tok)) {
96101 const Token* condTok = getCondTok (tok);
97102 if (!condTok)
98103 continue ;
@@ -124,7 +129,8 @@ bool findTokensSkipDeadCodeImpl(const Library& library,
124129 return true ;
125130 tok = thenStart->link ();
126131 }
127- } else if (Token::Match (tok->astParent (), " &&|?|%oror%" ) && astIsLHS (tok)) {
132+ // } else if (Token::Match(tok->astParent(), "&&|?|%oror%") && astIsLHS(tok)) {
133+ } else if (findTokensSkipDeadCodeImplMatch_2 (tok) && astIsLHS (tok)) {
128134 auto result = evaluate (tok);
129135 if (result.empty ())
130136 continue ;
@@ -158,7 +164,8 @@ bool findTokensSkipDeadCodeImpl(const Library& library,
158164 if (r != 0 ) {
159165 tok = tok->linkAt (2 );
160166 }
161- } else if (Token::simpleMatch (tok, " [" ) && Token::Match (tok->link (), " ] (|{" )) {
167+ // } else if (Token::simpleMatch(tok, "[") && Token::Match(tok->link(), "] (|{")) {
168+ } else if (findTokensSkipDeadCodeImplMatch_3 (tok)) {
162169 T* afterCapture = tok->link ()->next ();
163170 if (Token::simpleMatch (afterCapture, " (" ) && afterCapture->link ())
164171 tok = afterCapture->link ()->next ();
0 commit comments