| 3802 | } |
| 3803 | |
| 3804 | void TemplateSimplifier::simplifyTemplates(const std::time_t maxtime) |
| 3805 | { |
| 3806 | // convert "sizeof ..." to "sizeof..." |
| 3807 | for (Token *tok = mTokenList.front(); tok; tok = tok->next()) { |
| 3808 | if (Token::simpleMatch(tok, "sizeof ...")) { |
| 3809 | tok->str("sizeof..."); |
| 3810 | tok->deleteNext(); |
| 3811 | } |
| 3812 | } |
| 3813 | |
| 3814 | // Remove "typename" unless used in template arguments or using type alias.. |
| 3815 | for (Token *tok = mTokenList.front(); tok; tok = tok->next()) { |
| 3816 | if (Token::Match(tok, "typename %name%") && !Token::Match(tok->tokAt(-3), "using %name% =")) |
| 3817 | tok->deleteThis(); |
| 3818 | |
| 3819 | if (Token::simpleMatch(tok, "template <")) { |
| 3820 | tok = tok->next()->findClosingBracket(); |
| 3821 | if (!tok) |
| 3822 | break; |
| 3823 | } |
| 3824 | } |
| 3825 | |
| 3826 | if (mSettings.standards.cpp >= Standards::CPP20) { |
| 3827 | // Remove concepts/requires |
| 3828 | // TODO concepts are not removed yet |
| 3829 | for (Token *tok = mTokenList.front(); tok; tok = tok->next()) { |
| 3830 | if (!Token::Match(tok, ")|>|>> requires %name%|(")) |
| 3831 | continue; |
| 3832 | const Token* end = skipRequires(tok->next()); |
| 3833 | if (end) |
| 3834 | Token::eraseTokens(tok, end); |
| 3835 | } |
| 3836 | |
| 3837 | // explicit(bool) |
| 3838 | for (Token *tok = mTokenList.front(); tok; tok = tok->next()) { |
| 3839 | if (Token::simpleMatch(tok, "explicit (")) { |
| 3840 | const bool isFalse = Token::simpleMatch(tok->tokAt(2), "false )"); |
| 3841 | Token::eraseTokens(tok, tok->linkAt(1)->next()); |
| 3842 | if (isFalse) |
| 3843 | tok->deleteThis(); |
| 3844 | } |
| 3845 | } |
| 3846 | } |
| 3847 | |
| 3848 | mTokenizer.calculateScopes(); |
| 3849 | |
| 3850 | unsigned int passCount = 0; |
| 3851 | constexpr unsigned int passCountMax = 10; |
| 3852 | for (; passCount < passCountMax; ++passCount) { |
| 3853 | if (passCount) { |
| 3854 | // it may take more than one pass to simplify type aliases |
| 3855 | bool usingChanged = false; |
| 3856 | while (mTokenizer.simplifyUsing()) |
| 3857 | usingChanged = true; |
| 3858 | |
| 3859 | if (!usingChanged && !mChanged) |
| 3860 | break; |
| 3861 |
nothing calls this directly
no test coverage detected