Cppcheck
|
Simplify templates from the preprocessed and partially simplified code. More...
#include <templatesimplifier.h>
Classes | |
class | TokenAndName |
Token and its full scopename. More... | |
Public Member Functions | |
TemplateSimplifier (Tokenizer &tokenizer) | |
const std::string & | dump () const |
void | checkComplicatedSyntaxErrorsInTemplates () |
int | getTemplateNamePosition (const Token *tok) |
Match template declaration/instantiation. More... | |
void | simplifyTemplates (const std::time_t maxtime) |
Simplify templates. More... | |
bool | simplifyCalculations (Token *frontToken=nullptr, const Token *backToken=nullptr, bool isTemplate=true) |
Simplify constant calculations such as "1+2" => "3". More... | |
void | simplifyTemplateArgs (Token *start, const Token *end, std::vector< newInstantiation > *newInst=nullptr) |
Simplify template instantiation arguments. More... | |
Static Public Member Functions | |
static unsigned int | templateParameters (const Token *tok) |
is the token pointing at a template parameters block < int , 3 > => yes More... | |
static Token * | findTemplateDeclarationEnd (Token *tok) |
Find last token of a template declaration. More... | |
static const Token * | findTemplateDeclarationEnd (const Token *tok) |
static bool | instantiateMatch (const Token *instance, const std::size_t numberOfArguments, bool variadic, const char patternAfter[]) |
Match template declaration/instantiation. More... | |
static bool | getTemplateNamePositionTemplateClass (const Token *tok, int &namepos) |
Get class template name position. More... | |
static bool | getTemplateNamePositionTemplateFunction (const Token *tok, int &namepos) |
Get function template name position. More... | |
static bool | getTemplateNamePositionTemplateVariable (const Token *tok, int &namepos) |
Get variable template name position. More... | |
static bool | simplifyNumericCalculations (Token *tok, bool isTemplate=true) |
Simplify constant calculations such as "1+2" => "3". More... | |
Private Member Functions | |
bool | getTemplateDeclarations () |
Get template declarations. More... | |
void | addInstantiation (Token *token, const std::string &scope) |
Add template instantiation. More... | |
void | getTemplateInstantiations () |
Get template instantiations. More... | |
void | fixForwardDeclaredDefaultArgumentValues () |
Fix forward declared default argument values by copying them when they are not present in the declaration. More... | |
void | useDefaultArgumentValues () |
simplify template instantiations (use default argument values) More... | |
void | useDefaultArgumentValues (TokenAndName &declaration) |
simplify template instantiations (use default argument values) More... | |
void | getSpecializations () |
Try to locate a matching declaration for each user defined specialization. More... | |
void | getPartialSpecializations () |
Try to locate a matching declaration for each user defined partial specialization. More... | |
void | simplifyTemplateAliases () |
simplify template aliases More... | |
bool | simplifyTemplateInstantiations (const TokenAndName &templateDeclaration, const std::list< const Token * > &specializations, const std::time_t maxtime, std::set< std::string > &expandedtemplates) |
Simplify templates : expand all instantiations for a template. More... | |
void | addNamespace (const TokenAndName &templateDeclaration, const Token *tok) |
Simplify templates : add namespace to template name. More... | |
void | expandTemplate (const TokenAndName &templateDeclaration, const TokenAndName &templateInstantiation, const std::vector< const Token * > &typeParametersInDeclaration, const std::string &newName, bool copy) |
Expand a template. More... | |
void | replaceTemplateUsage (const TokenAndName &instantiation, const std::list< std::string > &typeStringsUsedInTemplateInstantiation, const std::string &newName) |
Replace all matching template usages 'Foo < int >' => 'Foo<int>'. More... | |
std::string | getNewName (Token *tok2, std::list< std::string > &typeStringsUsedInTemplateInstantiation) |
Get the new token name. More... | |
void | printOut (const TokenAndName &tokenAndName, const std::string &indent=" ") const |
void | printOut (const std::string &text=emptyString) const |
Static Private Member Functions | |
static bool | alreadyHasNamespace (const TokenAndName &templateDeclaration, const Token *tok) |
Simplify templates : check if namespace already present. More... | |
static void | getTemplateParametersInDeclaration (const Token *tok, std::vector< const Token * > &typeParametersInDeclaration) |
TemplateParametersInDeclaration. More... | |
static bool | removeTemplate (Token *tok, std::map< Token *, Token * > *forwardDecls=nullptr) |
Remove a specific "template < ..." template class/function. More... | |
static NORETURN void | syntaxError (const Token *tok) |
Syntax error. More... | |
static bool | matchSpecialization (const Token *templateDeclarationNameToken, const Token *templateInstantiationNameToken, const std::list< const Token * > &specializations) |
static void | eraseTokens (Token *begin, const Token *end) |
static void | deleteToken (Token *tok) |
Delete specified token without invalidating pointer to following token. More... | |
Private Attributes | |
Tokenizer & | mTokenizer |
TokenList & | mTokenList |
const Settings & | mSettings |
ErrorLogger & | mErrorLogger |
bool | mChanged {} |
std::list< TokenAndName > | mTemplateDeclarations |
std::list< TokenAndName > | mTemplateForwardDeclarations |
std::map< Token *, Token * > | mTemplateForwardDeclarationsMap |
std::map< Token *, Token * > | mTemplateSpecializationMap |
std::map< Token *, Token * > | mTemplatePartialSpecializationMap |
std::list< TokenAndName > | mTemplateInstantiations |
std::list< TokenAndName > | mInstantiatedTemplates |
std::list< TokenAndName > | mMemberFunctionsToDelete |
std::vector< TokenAndName > | mExplicitInstantiationsToDelete |
std::vector< TokenAndName > | mTypesUsedInTemplateInstantiation |
std::unordered_map< const Token *, int > | mTemplateNamePos |
std::string | mDump |
Friends | |
class | TestSimplifyTemplate |
Simplify templates from the preprocessed and partially simplified code.
Definition at line 46 of file templatesimplifier.h.
|
explicit |
Definition at line 276 of file templatesimplifier.cpp.
|
private |
Add template instantiation.
token | first token of instantiation |
scope | scope of instantiation |
Definition at line 712 of file templatesimplifier.cpp.
References Token::findClosingBracket(), mTemplateInstantiations, Token::next(), simplifyTemplateArgs(), and Token::tokAt().
Referenced by getTemplateInstantiations(), and simplifyTemplateAliases().
|
private |
Simplify templates : add namespace to template name.
templateDeclaration | template declaration |
tok | place to insert namespace |
Definition at line 1534 of file templatesimplifier.cpp.
References TokenList::addtoken(), TokenList::back(), Token::column(), emptyString, Token::fileIndex(), Token::insertToken(), Token::linenr(), Token::Match(), mTokenList, TemplateSimplifier::TokenAndName::scope(), Token::str(), Token::strAt(), and Token::tokAt().
Referenced by expandTemplate().
|
staticprivate |
Simplify templates : check if namespace already present.
templateDeclaration | template declaration |
tok | place to start looking for namespace |
Definition at line 1596 of file templatesimplifier.cpp.
References TemplateSimplifier::TokenAndName::scope(), Token::simpleMatch(), and Token::tokAt().
Referenced by expandTemplate().
void TemplateSimplifier::checkComplicatedSyntaxErrorsInTemplates | ( | ) |
Definition at line 281 of file templatesimplifier.cpp.
References TokenList::front(), Token::link(), Token::Match(), mTokenList, Token::next(), Token::simpleMatch(), Tokenizer::startOfExecutableScope(), syntaxError(), and Token::tokAt().
Referenced by Tokenizer::findComplicatedSyntaxErrorsInTemplates().
|
staticprivate |
Delete specified token without invalidating pointer to following token.
tok will be invalidated.
tok | token to delete |
Definition at line 619 of file templatesimplifier.cpp.
References Token::deletePrevious(), Token::deleteThis(), and Token::next().
Referenced by removeTemplate(), and simplifyTemplateAliases().
|
inline |
Definition at line 52 of file templatesimplifier.h.
Referenced by Tokenizer::dump().
Definition at line 609 of file templatesimplifier.cpp.
References Token::deleteNext(), and Token::next().
Referenced by expandTemplate(), removeTemplate(), replaceTemplateUsage(), simplifyCalculations(), simplifyTemplateAliases(), simplifyTemplates(), and useDefaultArgumentValues().
|
private |
Expand a template.
Create "expanded" class/function at end of tokenlist.
templateDeclaration | Template declaration information |
templateInstantiation | Full name of template |
typeParametersInDeclaration | The type parameters of the template |
newName | New name of class/function. |
copy | copy or expand in place |
Definition at line 1618 of file templatesimplifier.cpp.
References addNamespace(), TokenList::addtoken(), alreadyHasNamespace(), TokenList::back(), Token::column(), Token::createMutualLinks(), Token::deleteThis(), eraseTokens(), Token::fileIndex(), Token::findClosingBracket(), findTemplateDeclarationEnd(), TokenList::front(), Token::getMacroName(), getTemplateNamePosition(), getTemplateParametersInDeclaration(), Token::insertToken(), Token::insertTokenBefore(), instantiateMatch(), TemplateSimplifier::TokenAndName::isClass(), TemplateSimplifier::TokenAndName::isFunction(), Tokenizer::isFunctionHead(), Token::isLong(), Token::isName(), Token::isSigned(), TemplateSimplifier::TokenAndName::isSpecialization(), Token::isStandardType(), Token::isTemplateArg(), Token::isUnsigned(), TemplateSimplifier::TokenAndName::isVariable(), TemplateSimplifier::TokenAndName::isVariadic(), Token::linenr(), Token::link(), Token::linkAt(), Token::Match(), mExplicitInstantiationsToDelete, mMemberFunctionsToDelete, mTemplateDeclarations, mTemplateForwardDeclarations, mTemplateForwardDeclarationsMap, mTemplateInstantiations, mTemplateSpecializationMap, mTokenList, mTypesUsedInTemplateInstantiation, TemplateSimplifier::TokenAndName::name(), TemplateSimplifier::TokenAndName::nameToken(), Token::next(), Token::originalName(), TemplateSimplifier::TokenAndName::paramEnd(), Token::previous(), TemplateSimplifier::TokenAndName::scope(), Token::simpleMatch(), simplifyTemplateArgs(), Token::str(), Token::strAt(), templateParameters(), Token::tokAt(), and TemplateSimplifier::TokenAndName::token().
Referenced by simplifyTemplateInstantiations().
Definition at line 604 of file templatesimplifier.cpp.
References findTemplateDeclarationEndImpl().
Find last token of a template declaration.
tok | start token of declaration "template" or token after "template < ... >" |
Definition at line 599 of file templatesimplifier.cpp.
References findTemplateDeclarationEndImpl().
Referenced by expandTemplate(), getTemplateDeclarations(), getTemplateInstantiations(), removeTemplate(), and Tokenizer::simplifyUsing().
|
private |
Fix forward declared default argument values by copying them when they are not present in the declaration.
Definition at line 3485 of file templatesimplifier.cpp.
References TokenList::copyTokens(), getTemplateParametersInDeclaration(), Token::Match(), mTemplateDeclarations, mTemplateForwardDeclarations, mTemplateForwardDeclarationsMap, Token::next(), and Token::previous().
Referenced by simplifyTemplates().
|
private |
Get the new token name.
tok2 | name token |
typeStringsUsedInTemplateInstantiation | type strings use in template instantiation |
Definition at line 2993 of file templatesimplifier.cpp.
References Token::findClosingBracket(), Token::Match(), mTypesUsedInTemplateInstantiation, Token::next(), templateParameters(), and Token::tokAt().
Referenced by simplifyTemplateInstantiations().
|
private |
Try to locate a matching declaration for each user defined partial specialization.
Definition at line 3464 of file templatesimplifier.cpp.
References mTemplateDeclarations, mTemplateForwardDeclarations, and mTemplatePartialSpecializationMap.
Referenced by simplifyTemplates().
|
private |
Try to locate a matching declaration for each user defined specialization.
Definition at line 3443 of file templatesimplifier.cpp.
References mTemplateDeclarations, mTemplateForwardDeclarations, and mTemplateSpecializationMap.
Referenced by simplifyTemplates().
|
private |
Get template declarations.
Definition at line 655 of file templatesimplifier.cpp.
References Token::findClosingBracket(), findTemplateDeclarationEnd(), TokenList::front(), getTemplateNamePosition(), TemplateSimplifier::TokenAndName::isForwardDeclaration(), Token::link(), Token::Match(), mTemplateDeclarations, mTemplateForwardDeclarations, mTokenList, Token::next(), Token::simpleMatch(), syntaxError(), and Token::tokAt().
Referenced by simplifyTemplates().
|
private |
Get template instantiations.
Definition at line 777 of file templatesimplifier.cpp.
References addInstantiation(), areAllParamsTypes(), Token::deleteNext(), Token::eBoolean, Token::eChar, Token::eNumber, Token::eString, Token::findClosingBracket(), Token::findsimplematch(), findTemplateDeclarationEnd(), TokenList::front(), getFunctionArguments(), MathLib::getSuffix(), getTemplateNamePosition(), getTemplateParametersInDeclaration(), Token::insertToken(), Token::insertTokenBefore(), MathLib::value::isFloat(), MathLib::value::isInt(), Token::isLong(), Token::Match(), match(), mTemplateDeclarations, mTemplateForwardDeclarations, mTokenList, Token::next(), Token::previous(), Token::scopeInfo(), Token::simpleMatch(), Token::str(), Token::strAt(), templateParameters(), Token::tokAt(), and Token::tokType().
Referenced by simplifyTemplates().
int TemplateSimplifier::getTemplateNamePosition | ( | const Token * | tok | ) |
Match template declaration/instantiation.
tok | The ">" token e.g. before "class" |
Definition at line 1509 of file templatesimplifier.cpp.
References Settings::debugtemplate, getTemplateNamePositionTemplateClass(), getTemplateNamePositionTemplateFunction(), getTemplateNamePositionTemplateVariable(), Token::Match(), mSettings, mTemplateNamePos, Token::str(), syntaxError(), and Token::tokAt().
Referenced by expandTemplate(), getTemplateDeclarations(), and getTemplateInstantiations().
|
static |
Get class template name position.
tok | The ">" token e.g. before "class" |
namepos | return offset to name |
Definition at line 1480 of file templatesimplifier.cpp.
References Token::findClosingBracket(), Token::Match(), Token::next(), Token::strAt(), and Token::tokAt().
Referenced by getTemplateNamePosition().
|
static |
Get function template name position.
tok | The ">" token |
namepos | return offset to name |
Definition at line 1416 of file templatesimplifier.cpp.
References Token::findClosingBracket(), Tokenizer::isFunctionHead(), Token::linkAt(), Token::Match(), Token::next(), Token::previous(), Token::simpleMatch(), Token::strAt(), and Token::tokAt().
Referenced by getTemplateNamePosition().
|
static |
Get variable template name position.
tok | The ">" token |
namepos | return offset to name |
Definition at line 1448 of file templatesimplifier.cpp.
References Token::findClosingBracket(), Token::linkAt(), Token::Match(), Token::next(), Token::simpleMatch(), and Token::tokAt().
Referenced by getTemplateNamePosition().
|
staticprivate |
TemplateParametersInDeclaration.
tok | template < typename T, typename S > ^ tok |
typeParametersInDeclaration | template < typename T, typename S > ^ [0] ^ [1] |
Definition at line 2909 of file templatesimplifier.cpp.
References Token::findClosingBracket(), Token::link(), Token::Match(), Token::next(), Token::previous(), Token::simpleMatch(), Token::str(), and Token::strAt().
Referenced by expandTemplate(), fixForwardDeclaredDefaultArgumentValues(), getTemplateInstantiations(), matchSpecialization(), simplifyTemplateAliases(), and simplifyTemplateInstantiations().
|
static |
Match template declaration/instantiation.
instance | template instantiation |
numberOfArguments | number of template arguments |
variadic | last template argument is variadic |
patternAfter | pattern that must match the tokens after the ">" |
Definition at line 1397 of file templatesimplifier.cpp.
References Token::findClosingBracket(), Token::Match(), Token::next(), numberOfArguments(), Token::strAt(), and templateParameters().
Referenced by expandTemplate(), and simplifyTemplateInstantiations().
|
staticprivate |
Definition at line 2943 of file templatesimplifier.cpp.
References Token::findClosingBracket(), getTemplateParametersInDeclaration(), Token::isLong(), Token::isSigned(), Token::isUnsigned(), Token::Match(), Token::next(), Token::previous(), Token::simpleMatch(), Token::str(), templateParameters(), and Token::tokAt().
Referenced by simplifyTemplateInstantiations().
|
private |
Definition at line 3609 of file templatesimplifier.cpp.
References mTemplateDeclarations, mTemplateForwardDeclarations, mTemplateForwardDeclarationsMap, mTemplateInstantiations, mTemplatePartialSpecializationMap, mTemplateSpecializationMap, and printOut().
|
private |
Definition at line 3537 of file templatesimplifier.cpp.
References TemplateSimplifier::TokenAndName::aliasEndToken(), TemplateSimplifier::TokenAndName::aliasStartToken(), TokenList::fileLine(), Token::findClosingBracket(), TemplateSimplifier::TokenAndName::fullName(), indent(), TemplateSimplifier::TokenAndName::isAlias(), TemplateSimplifier::TokenAndName::isClass(), TemplateSimplifier::TokenAndName::isForwardDeclaration(), TemplateSimplifier::TokenAndName::isFriend(), TemplateSimplifier::TokenAndName::isFunction(), Token::isLong(), TemplateSimplifier::TokenAndName::isPartialSpecialization(), Token::isSigned(), TemplateSimplifier::TokenAndName::isSpecialization(), Token::isUnsigned(), TemplateSimplifier::TokenAndName::isVariable(), TemplateSimplifier::TokenAndName::isVariadic(), mTokenList, TemplateSimplifier::TokenAndName::name(), TemplateSimplifier::TokenAndName::nameToken(), Token::next(), TemplateSimplifier::TokenAndName::paramEnd(), TemplateSimplifier::TokenAndName::scope(), Token::str(), Token::strAt(), and TemplateSimplifier::TokenAndName::token().
Referenced by printOut(), and simplifyTemplates().
|
staticprivate |
Remove a specific "template < ..." template class/function.
Definition at line 639 of file templatesimplifier.cpp.
References deleteToken(), eraseTokens(), findTemplateDeclarationEnd(), invalidateForwardDecls(), Token::next(), and Token::simpleMatch().
Referenced by simplifyTemplates().
|
private |
Replace all matching template usages 'Foo < int >' => 'Foo<int>'.
instantiation | Template instantiation information. |
typeStringsUsedInTemplateInstantiation | template parameters. list of token strings. |
newName | The new type name |
Definition at line 3346 of file templatesimplifier.cpp.
References eraseTokens(), Token::findClosingBracket(), TokenList::front(), TemplateSimplifier::TokenAndName::fullName(), Token::Match(), matchTemplateParameters(), mTemplateInstantiations, mTemplateNamePos, mTokenList, TemplateSimplifier::TokenAndName::name(), Token::next(), Token::simpleMatch(), and Token::str().
Referenced by simplifyTemplateInstantiations().
bool TemplateSimplifier::simplifyCalculations | ( | Token * | frontToken = nullptr , |
const Token * | backToken = nullptr , |
||
bool | isTemplate = true |
||
) |
Simplify constant calculations such as "1+2" => "3".
This also performs simple cleanup of parentheses etc.
Definition at line 2650 of file templatesimplifier.cpp.
References Token::deleteNext(), eraseTokens(), TokenList::front(), MathLib::getSuffix(), MathLib::isFloat(), MathLib::isInt(), isLowerThanLogicalAnd(), isLowerThanMulDiv(), isLowerThanXor(), Token::Match(), mTokenList, Token::next(), op1, op2, simplifyNumericCalculations(), Token::str(), MathLib::toBigNumber(), Token::tokAt(), validTokenEnd(), and validTokenStart().
Referenced by simplifyTemplateArgs().
|
static |
Simplify constant calculations such as "1+2" => "3".
tok | start token |
Definition at line 2329 of file templatesimplifier.cpp.
References MathLib::add(), MathLib::calculate(), Token::deleteNext(), MathLib::divide(), InternalError::INSTANTIATION, MathLib::value::isInt(), isLowerEqualThanMulDiv(), isLowerThanAnd(), isLowerThanLogicalAnd(), isLowerThanMulDiv(), isLowerThanOr(), isLowerThanPlusMinus(), isLowerThanShift(), isLowerThanXor(), MathLib::isNegative(), MathLib::isNullValue(), Token::isNumber(), Token::Match(), MathLib::multiply(), Token::next(), op1, op2, Token::previous(), Token::str(), MathLib::subtract(), Token::tokAt(), and InternalError::token.
Referenced by SymbolDatabase::setArrayDimensionsUsingValueFlow(), simplifyCalculations(), and Tokenizer::simplifyTokenList1().
|
private |
simplify template aliases
Definition at line 1271 of file templatesimplifier.cpp.
References addInstantiation(), TemplateSimplifier::TokenAndName::aliasEndToken(), TemplateSimplifier::TokenAndName::aliasStartToken(), TokenList::copyTokens(), Token::deleteThis(), deleteToken(), eraseTokens(), Token::findClosingBracket(), TokenList::front(), TemplateSimplifier::TokenAndName::fullName(), getTemplateParametersInDeclaration(), TemplateSimplifier::TokenAndName::isAlias(), TemplateSimplifier::TokenAndName::isAliasToken(), TemplateSimplifier::TokenAndName::isVariadic(), Token::link(), Token::Match(), mChanged, mTemplateDeclarations, mTemplateInstantiations, mTokenList, Token::next(), Token::previous(), Token::scope(), Token::str(), Token::tokAt(), and TemplateSimplifier::TokenAndName::token().
Referenced by simplifyTemplates().
void TemplateSimplifier::simplifyTemplateArgs | ( | Token * | start, |
const Token * | end, | ||
std::vector< newInstantiation > * | newInst = nullptr |
||
) |
Simplify template instantiation arguments.
start | first token of arguments |
end | token following last argument token |
Definition at line 2458 of file templatesimplifier.cpp.
References bool_to_string(), Token::deleteNext(), Token::eraseTokens(), TokenList::front(), Token::getStrLength(), invalidateInst(), MathLib::isInt(), Token::Match(), mTokenizer, mTokenList, Token::next(), op1, op2, Token::previous(), Token::simpleMatch(), simplifyCalculations(), Tokenizer::sizeOfType(), skipTernaryOp(), Token::str(), templateParameters(), MathLib::toBigNumber(), and Token::tokAt().
Referenced by addInstantiation(), expandTemplate(), and useDefaultArgumentValues().
|
private |
Simplify templates : expand all instantiations for a template.
templateDeclaration | template declaration |
specializations | template specializations (list each template name token) |
maxtime | time when the simplification will stop |
expandedtemplates | all templates that has been expanded so far. The full names are stored. |
Definition at line 3049 of file templatesimplifier.cpp.
References debug, Settings::debugwarnings, emptyString, expandTemplate(), Token::findOpeningBracket(), TemplateSimplifier::TokenAndName::fullName(), TokenList::getFiles(), getFunctionArguments(), getNewName(), getTemplateParametersInDeclaration(), information, instantiateMatch(), SimpleEnableGroup< T >::isEnabled(), TemplateSimplifier::TokenAndName::isFunction(), TemplateSimplifier::TokenAndName::isSpecialization(), TemplateSimplifier::TokenAndName::isVariable(), TemplateSimplifier::TokenAndName::isVariadic(), Token::linkAt(), Tokenizer::list, Token::Match(), matchSpecialization(), Settings::maxTemplateRecursion, mChanged, mErrorLogger, mSettings, mTemplateInstantiations, mTokenizer, mTokenList, mTypesUsedInTemplateInstantiation, TemplateSimplifier::TokenAndName::name(), TemplateSimplifier::TokenAndName::nameToken(), Token::next(), normal, Token::previous(), Token::progressValue(), replaceTemplateUsage(), ErrorLogger::reportErr(), ErrorLogger::reportProgress(), TemplateSimplifier::TokenAndName::scope(), Settings::severity, Token::simpleMatch(), Token::str(), Token::strAt(), Token::tokAt(), TemplateSimplifier::TokenAndName::token(), and TokenList::validateToken().
Referenced by simplifyTemplates().
void TemplateSimplifier::simplifyTemplates | ( | const std::time_t | maxtime | ) |
Simplify templates.
maxtime | time when the simplification should be stopped |
Definition at line 3726 of file templatesimplifier.cpp.
References Tokenizer::calculateScopes(), Standards::cpp, Standards::CPP17, Standards::CPP20, Token::createMutualLinks(), debug, Settings::debugnormal, Settings::debugtemplate, Settings::debugwarnings, Token::deleteNext(), Token::deleteThis(), eraseTokens(), Token::eraseTokens(), Token::findClosingBracket(), fixForwardDeclaredDefaultArgumentValues(), TokenList::front(), TemplateSimplifier::TokenAndName::fullName(), TokenList::getFiles(), getFunctionArguments(), getPartialSpecializations(), getSpecializations(), getTemplateDeclarations(), getTemplateInstantiations(), isConstMethod(), isFalse(), TemplateSimplifier::TokenAndName::isFunction(), Token::isName(), Token::link(), Tokenizer::list, Token::Match(), mChanged, mDump, mErrorLogger, mExplicitInstantiationsToDelete, mInstantiatedTemplates, mMemberFunctionsToDelete, mSettings, mTemplateDeclarations, mTemplateForwardDeclarations, mTemplateForwardDeclarationsMap, mTemplateInstantiations, mTemplateNamePos, mTemplatePartialSpecializationMap, mTemplateSpecializationMap, mTokenizer, mTokenList, TemplateSimplifier::TokenAndName::nameToken(), Token::next(), normal, Token::previous(), Token::printOut(), printOut(), removeTemplate(), ErrorLogger::reportErr(), Token::simpleMatch(), simplifyTemplateAliases(), simplifyTemplateInstantiations(), Tokenizer::simplifyUsing(), skipRequires(), Settings::standards, Token::str(), Token::tokAt(), and useDefaultArgumentValues().
Referenced by Tokenizer::simplifyTemplates().
|
staticprivate |
Syntax error.
Definition at line 4030 of file templatesimplifier.cpp.
References InternalError::SYNTAX.
Referenced by checkComplicatedSyntaxErrorsInTemplates(), getTemplateDeclarations(), getTemplateNamePosition(), and templateParameters().
|
static |
is the token pointing at a template parameters block < int , 3 > => yes
tok | start token that must point at "<" |
Definition at line 386 of file templatesimplifier.cpp.
References Token::eChar, Token::eString, Token::findClosingBracket(), Token::isName(), Token::isNumber(), Token::isOp(), Token::link(), Token::Match(), Token::next(), Token::previous(), Token::simpleMatch(), Token::str(), syntaxError(), Token::tokAt(), and Token::tokType().
Referenced by expandTemplate(), getNewName(), getTemplateInstantiations(), instantiateMatch(), matchSpecialization(), setVarIdParseDeclaration(), setVarIdStructMembers(), simplifyTemplateArgs(), Tokenizer::simplifyVarDecl(), Tokenizer::splitTemplateRightAngleBrackets(), and useDefaultArgumentValues().
|
private |
simplify template instantiations (use default argument values)
Definition at line 1032 of file templatesimplifier.cpp.
References mTemplateDeclarations, and mTemplateForwardDeclarations.
Referenced by simplifyTemplates().
|
private |
simplify template instantiations (use default argument values)
declaration | template declaration or forward declaration |
Definition at line 1041 of file templatesimplifier.cpp.
References Token::createMutualLinks(), debug, Settings::debugwarnings, Token::deleteThis(), eraseTokens(), Token::findClosingBracket(), TemplateSimplifier::TokenAndName::fullName(), Token::insertToken(), TemplateSimplifier::TokenAndName::isAlias(), SimpleEnableGroup< T >::isEnabled(), TemplateSimplifier::TokenAndName::isFriend(), TemplateSimplifier::TokenAndName::isSpecialization(), Token::link(), Tokenizer::list, Token::Match(), mErrorLogger, mSettings, mTemplateInstantiations, mTokenizer, TemplateSimplifier::TokenAndName::name(), Token::next(), normal, TemplateSimplifier::TokenAndName::paramEnd(), Token::previous(), ErrorLogger::reportErr(), Settings::severity, Token::simpleMatch(), simplifyTemplateArgs(), Token::str(), Token::strAt(), templateParameters(), Token::tokAt(), and TemplateSimplifier::TokenAndName::token().
|
friend |
Definition at line 47 of file templatesimplifier.h.
|
private |
Definition at line 498 of file templatesimplifier.h.
Referenced by simplifyTemplateAliases(), simplifyTemplateInstantiations(), and simplifyTemplates().
|
private |
Definition at line 511 of file templatesimplifier.h.
Referenced by simplifyTemplates().
|
private |
Definition at line 497 of file templatesimplifier.h.
Referenced by simplifyTemplateInstantiations(), simplifyTemplates(), and useDefaultArgumentValues().
|
private |
Definition at line 508 of file templatesimplifier.h.
Referenced by expandTemplate(), and simplifyTemplates().
|
private |
Definition at line 506 of file templatesimplifier.h.
Referenced by simplifyTemplates().
|
private |
Definition at line 507 of file templatesimplifier.h.
Referenced by expandTemplate(), and simplifyTemplates().
|
private |
Definition at line 496 of file templatesimplifier.h.
Referenced by getTemplateNamePosition(), simplifyTemplateInstantiations(), simplifyTemplates(), and useDefaultArgumentValues().
|
private |
Definition at line 500 of file templatesimplifier.h.
Referenced by expandTemplate(), fixForwardDeclaredDefaultArgumentValues(), getPartialSpecializations(), getSpecializations(), getTemplateDeclarations(), getTemplateInstantiations(), printOut(), simplifyTemplateAliases(), simplifyTemplates(), and useDefaultArgumentValues().
|
private |
Definition at line 501 of file templatesimplifier.h.
Referenced by expandTemplate(), fixForwardDeclaredDefaultArgumentValues(), getPartialSpecializations(), getSpecializations(), getTemplateDeclarations(), getTemplateInstantiations(), printOut(), simplifyTemplates(), and useDefaultArgumentValues().
Definition at line 502 of file templatesimplifier.h.
Referenced by expandTemplate(), fixForwardDeclaredDefaultArgumentValues(), printOut(), and simplifyTemplates().
|
private |
Definition at line 505 of file templatesimplifier.h.
Referenced by addInstantiation(), expandTemplate(), printOut(), replaceTemplateUsage(), simplifyTemplateAliases(), simplifyTemplateInstantiations(), simplifyTemplates(), and useDefaultArgumentValues().
|
private |
Definition at line 510 of file templatesimplifier.h.
Referenced by getTemplateNamePosition(), replaceTemplateUsage(), and simplifyTemplates().
Definition at line 504 of file templatesimplifier.h.
Referenced by getPartialSpecializations(), printOut(), and simplifyTemplates().
Definition at line 503 of file templatesimplifier.h.
Referenced by expandTemplate(), getSpecializations(), printOut(), and simplifyTemplates().
|
private |
Definition at line 494 of file templatesimplifier.h.
Referenced by simplifyTemplateArgs(), simplifyTemplateInstantiations(), simplifyTemplates(), and useDefaultArgumentValues().
|
private |
Definition at line 495 of file templatesimplifier.h.
Referenced by addNamespace(), checkComplicatedSyntaxErrorsInTemplates(), expandTemplate(), getTemplateDeclarations(), getTemplateInstantiations(), printOut(), replaceTemplateUsage(), simplifyCalculations(), simplifyTemplateAliases(), simplifyTemplateArgs(), simplifyTemplateInstantiations(), and simplifyTemplates().
|
private |
Definition at line 509 of file templatesimplifier.h.
Referenced by expandTemplate(), getNewName(), and simplifyTemplateInstantiations().