Skip to content

Commit be14866

Browse files
authored
Run valueFlowSubfunction in reverse order of functions (#3540)
1 parent 04ecf53 commit be14866

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

lib/valueflow.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6261,10 +6261,31 @@ static void valueFlowLibraryFunction(Token *tok, const std::string &returnValue,
62616261
});
62626262
}
62636263

6264+
template<class Iterator>
6265+
struct IteratorRange
6266+
{
6267+
Iterator mBegin;
6268+
Iterator mEnd;
6269+
6270+
Iterator begin() const {
6271+
return mBegin;
6272+
}
6273+
6274+
Iterator end() const {
6275+
return mEnd;
6276+
}
6277+
};
6278+
6279+
template<class Iterator>
6280+
IteratorRange<Iterator> MakeIteratorRange(Iterator start, Iterator last)
6281+
{
6282+
return {start, last};
6283+
}
6284+
62646285
static void valueFlowSubFunction(TokenList* tokenlist, SymbolDatabase* symboldatabase, ErrorLogger* errorLogger, const Settings* settings)
62656286
{
62666287
int id = 0;
6267-
for (const Scope* scope : symboldatabase->functionScopes) {
6288+
for (const Scope* scope : MakeIteratorRange(symboldatabase->functionScopes.rbegin(), symboldatabase->functionScopes.rend())) {
62686289
const Function* function = scope->function;
62696290
if (!function)
62706291
continue;

0 commit comments

Comments
 (0)