Run valueFlowSubfunction in reverse order of functions (#3540)

This commit is contained in:
Paul Fultz II 2021-11-01 13:21:03 -05:00 committed by GitHub
parent 04ecf53a07
commit be14866095
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 1 deletions

View File

@ -6261,10 +6261,31 @@ static void valueFlowLibraryFunction(Token *tok, const std::string &returnValue,
});
}
template<class Iterator>
struct IteratorRange
{
Iterator mBegin;
Iterator mEnd;
Iterator begin() const {
return mBegin;
}
Iterator end() const {
return mEnd;
}
};
template<class Iterator>
IteratorRange<Iterator> MakeIteratorRange(Iterator start, Iterator last)
{
return {start, last};
}
static void valueFlowSubFunction(TokenList* tokenlist, SymbolDatabase* symboldatabase, ErrorLogger* errorLogger, const Settings* settings)
{
int id = 0;
for (const Scope* scope : symboldatabase->functionScopes) {
for (const Scope* scope : MakeIteratorRange(symboldatabase->functionScopes.rbegin(), symboldatabase->functionScopes.rend())) {
const Function* function = scope->function;
if (!function)
continue;