astyle formatting

[ci skip]
This commit is contained in:
Daniel Marjamäki 2021-01-12 21:28:56 +01:00
parent 5f21d9d97b
commit 1858465bca
4 changed files with 72 additions and 76 deletions

View File

@ -854,21 +854,18 @@ struct InvalidContainerAnalyzer {
}; };
std::unordered_map<int, Reference> expressions; std::unordered_map<int, Reference> expressions;
ErrorPath errorPath; ErrorPath errorPath;
void add(const std::vector<Reference>& refs) void add(const std::vector<Reference>& refs) {
{
for (const Reference& r : refs) { for (const Reference& r : refs) {
add(r); add(r);
} }
} }
void add(const Reference& r) void add(const Reference& r) {
{
if (!r.tok) if (!r.tok)
return; return;
expressions.insert(std::make_pair(r.tok->exprId(), r)); expressions.insert(std::make_pair(r.tok->exprId(), r));
} }
std::vector<Reference> invalidTokens() const std::vector<Reference> invalidTokens() const {
{
std::vector<Reference> result; std::vector<Reference> result;
std::transform(expressions.begin(), expressions.end(), std::back_inserter(result), SelectMapValues{}); std::transform(expressions.begin(), expressions.end(), std::back_inserter(result), SelectMapValues{});
return result; return result;
@ -876,8 +873,7 @@ struct InvalidContainerAnalyzer {
}; };
std::unordered_map<const Function*, Info> invalidMethods; std::unordered_map<const Function*, Info> invalidMethods;
std::vector<Info::Reference> invalidatesContainer(const Token* tok) const std::vector<Info::Reference> invalidatesContainer(const Token* tok) const {
{
std::vector<Info::Reference> result; std::vector<Info::Reference> result;
if (Token::Match(tok, "%name% (")) { if (Token::Match(tok, "%name% (")) {
const Function* f = tok->function(); const Function* f = tok->function();
@ -927,8 +923,7 @@ struct InvalidContainerAnalyzer {
return result; return result;
} }
void analyze(const SymbolDatabase* symboldatabase) void analyze(const SymbolDatabase* symboldatabase) {
{
for (const Scope* scope : symboldatabase->functionScopes) { for (const Scope* scope : symboldatabase->functionScopes) {
const Function* f = scope->function; const Function* f = scope->function;
if (!f) if (!f)

View File

@ -30,16 +30,14 @@
struct SelectMapKeys { struct SelectMapKeys {
template <class Pair> template <class Pair>
typename Pair::first_type operator()(const Pair& p) const typename Pair::first_type operator()(const Pair& p) const {
{
return p.first; return p.first;
} }
}; };
struct SelectMapValues { struct SelectMapValues {
template <class Pair> template <class Pair>
typename Pair::second_type operator()(const Pair& p) const typename Pair::second_type operator()(const Pair& p) const {
{
return p.second; return p.second;
} }
}; };

View File

@ -353,18 +353,21 @@ static bool isComputableValue(const Token* parent, const ValueFlow::Value& value
} }
template<class T> template<class T>
static bool isEqual(T x, T y) { static bool isEqual(T x, T y)
{
return x == y; return x == y;
} }
template<> template<>
bool isEqual<double>(double x, double y) { bool isEqual<double>(double x, double y)
{
const double diff = (x > y) ? x - y : y - x; const double diff = (x > y) ? x - y : y - x;
return !((diff / 2) < diff); return !((diff / 2) < diff);
} }
template<class T> template<class T>
static bool isZero(T x) { static bool isZero(T x)
{
return isEqual<T>(x, T(0)); return isEqual<T>(x, T(0));
} }