Skip to content

Commit c214761

Browse files
committed
Fix CI failures
1 parent 2733865 commit c214761

2 files changed

Lines changed: 35 additions & 35 deletions

File tree

‎lib/templatesimplifier.cpp‎

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -796,41 +796,39 @@ static bool isTemplateInstantion(const Token* tok)
796796
return Token::Match(tok->tokAt(-2), "(|{|}|;|=|<<|:|.|*|&|return|<|,|!|[ :: %name% ::|<|(");
797797
}
798798

799-
namespace {
800799
// A function template parameter with a form that is supported by type deduction:
801800
// "T", "T &", "const T &", "T *", "const T *" or a concrete single token type
802-
struct ParameterShape {
803-
const Token* typeTok = nullptr;
804-
int templateParameterIndex = -1; // -1 => a concrete type, nothing is deduced
805-
bool isConst = false;
806-
bool isPointer = false;
807-
bool isReference = false;
808-
};
801+
struct ParameterShape {
802+
const Token* typeTok = nullptr;
803+
int templateParameterIndex = -1; // -1 => a concrete type, nothing is deduced
804+
bool isConst = false;
805+
bool isPointer = false;
806+
bool isReference = false;
807+
};
809808

810809
// The type deduced for a template parameter from a function call argument
811-
struct DeducedType {
812-
std::string typeStr; // base type, e.g. "int" or "MyClass"
813-
std::vector<std::string> qualification; // enclosing scopes for record types, outermost first
814-
unsigned int constness = 0; // bit 0 = data const, bit 1 = first '*' const, ..
815-
unsigned int pointer = 0; // number of '*'
816-
bool isUnsigned = false;
817-
bool isLong = false;
818-
819-
bool operator==(const DeducedType& other) const
820-
{
821-
return typeStr == other.typeStr && qualification == other.qualification && constness == other.constness &&
822-
pointer == other.pointer && isUnsigned == other.isUnsigned && isLong == other.isLong;
823-
}
824-
};
810+
struct DeducedType {
811+
std::string typeStr; // base type, e.g. "int" or "MyClass"
812+
std::vector<std::string> qualification; // enclosing scopes for record types, outermost first
813+
unsigned int constness = 0; // bit 0 = data const, bit 1 = first '*' const, ..
814+
unsigned int pointer = 0; // number of '*'
815+
bool isUnsigned = false;
816+
bool isLong = false;
817+
818+
bool operator==(const DeducedType& other) const
819+
{
820+
return typeStr == other.typeStr && qualification == other.qualification && constness == other.constness &&
821+
pointer == other.pointer && isUnsigned == other.isUnsigned && isLong == other.isLong;
822+
}
823+
};
825824

826825
// A parsed function template declaration that type deduction supports. Invalid
827826
// (typeParameters is empty) when the declaration is not supported.
828-
struct DeductionCandidate {
829-
std::vector<const Token*> typeParameters;
830-
std::vector<ParameterShape> parameterShapes;
831-
std::string signature;
832-
};
833-
} // namespace
827+
struct DeductionCandidate {
828+
std::vector<const Token*> typeParameters;
829+
std::vector<ParameterShape> parameterShapes;
830+
std::string signature;
831+
};
834832

835833
// Parse a function parameter of a template declaration. The returned shape has no
836834
// typeTok when the parameter does not have a supported form.

‎test/testsimplifytemplate.cpp‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
#include "tokenize.h"
2828
#include "tokenlist.h"
2929

30+
#include <algorithm>
3031
#include <cstring>
32+
#include <iterator>
3133
#include <set>
3234
#include <sstream>
3335
#include <string>
@@ -421,11 +423,10 @@ class TestSimplifyTemplate : public TestFixture {
421423
const Scope* scope = tokenizer.getSymbolDatabase()->findScopeByName(scopeName);
422424
if (!scope)
423425
return nullptr;
424-
for (const Function& function : scope->functionList) {
425-
if (function.name() == functionName)
426-
return &function;
427-
}
428-
return nullptr;
426+
const auto it = std::find_if(scope->functionList.cbegin(), scope->functionList.cend(), [&](const Function& function) {
427+
return function.name() == functionName;
428+
});
429+
return it == scope->functionList.cend() ? nullptr : &*it;
429430
}
430431

431432
// is the token in the token list of the tokenizer?
@@ -7155,8 +7156,9 @@ class TestSimplifyTemplate : public TestFixture {
71557156

71567157
// every variable in the symbol table belongs to a scope of the database
71577158
std::set<const Scope*> scopes;
7158-
for (const Scope& scope : symbolDatabase->scopeList)
7159-
scopes.insert(&scope);
7159+
std::transform(symbolDatabase->scopeList.cbegin(), symbolDatabase->scopeList.cend(), std::inserter(scopes, scopes.end()), [](const Scope& scope) {
7160+
return &scope;
7161+
});
71607162
for (const Variable* var : symbolDatabase->variableList()) {
71617163
if (var && var->scope())
71627164
ASSERT(scopes.count(var->scope()) != 0);

0 commit comments

Comments
 (0)