| 837 | } |
| 838 | |
| 839 | template<class T, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*> )> |
| 840 | static T* getCondTokImpl(T* tok) |
| 841 | { |
| 842 | if (!tok) |
| 843 | return nullptr; |
| 844 | if (Token::simpleMatch(tok, "(")) |
| 845 | return getCondTok(tok->previous()); |
| 846 | if (Token::simpleMatch(tok, "do {")) { |
| 847 | T* endTok = tok->linkAt(1); |
| 848 | if (Token::simpleMatch(endTok, "} while (")) |
| 849 | return endTok->tokAt(2)->astOperand2(); |
| 850 | } |
| 851 | if (Token::simpleMatch(tok, "for") && Token::simpleMatch(tok->next()->astOperand2(), ";") && |
| 852 | tok->next()->astOperand2()->astOperand2()) |
| 853 | return tok->next()->astOperand2()->astOperand2()->astOperand1(); |
| 854 | if (Token::simpleMatch(tok->next()->astOperand2(), ";")) |
| 855 | return tok->next()->astOperand2()->astOperand1(); |
| 856 | if (tok->isName() && !tok->isControlFlowKeyword()) |
| 857 | return nullptr; |
| 858 | return tok->next()->astOperand2(); |
| 859 | } |
| 860 | |
| 861 | template<class T, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*> )> |
| 862 | static T* getCondTokFromEndImpl(T* endBlock) |
no test coverage detected