From efeb7deb7acc7b144894eeeaa1a4d69834b58c2a Mon Sep 17 00:00:00 2001 From: amai2012 Date: Sun, 16 Feb 2020 19:58:09 +0100 Subject: [PATCH] Run dmake and astyle --- Makefile | 2 +- lib/programmemory.cpp | 4 ++-- lib/valueflow.cpp | 34 +++++++++++++++------------------- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 25df2c138..0fde1b5fa 100644 --- a/Makefile +++ b/Makefile @@ -513,7 +513,7 @@ $(libcppdir)/mathlib.o: lib/mathlib.cpp lib/config.h lib/errorlogger.h lib/mathl $(libcppdir)/path.o: lib/path.cpp externals/simplecpp/simplecpp.h lib/config.h lib/path.h lib/utils.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CPPFILESDIR) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o $(libcppdir)/path.o $(libcppdir)/path.cpp -$(libcppdir)/pathanalysis.o: lib/pathanalysis.cpp lib/config.h lib/errorlogger.h lib/importproject.h lib/library.h lib/mathlib.h lib/pathanalysis.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/utils.h lib/valueflow.h +$(libcppdir)/pathanalysis.o: lib/pathanalysis.cpp lib/astutils.h lib/config.h lib/errorlogger.h lib/importproject.h lib/library.h lib/mathlib.h lib/pathanalysis.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/utils.h lib/valueflow.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CPPFILESDIR) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o $(libcppdir)/pathanalysis.o $(libcppdir)/pathanalysis.cpp $(libcppdir)/pathmatch.o: lib/pathmatch.cpp lib/config.h lib/path.h lib/pathmatch.h lib/utils.h diff --git a/lib/programmemory.cpp b/lib/programmemory.cpp index 98d1fc228..040fa4bf8 100644 --- a/lib/programmemory.cpp +++ b/lib/programmemory.cpp @@ -249,14 +249,14 @@ static ProgramMemory getInitialProgramState(const Token* tok, ProgramMemory getProgramMemory(const Token *tok, const std::unordered_map& vars) { ProgramMemory programMemory; - for(const auto& p:vars) { + for (const auto& p:vars) { const ValueFlow::Value &value = p.second; programMemory.replace(getInitialProgramState(tok, value.tokvalue)); programMemory.replace(getInitialProgramState(tok, value.condition)); } fillProgramMemoryFromConditions(programMemory, tok, nullptr); ProgramMemory state; - for(const auto& p:vars) { + for (const auto& p:vars) { nonneg int varid = p.first; const ValueFlow::Value &value = p.second; programMemory.setValue(varid, value); diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index ab60d67f0..8a064730f 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -2144,11 +2144,9 @@ static bool bifurcate(const Token* tok, const std::set& varids, cons return false; } -struct SelectMapKeys -{ +struct SelectMapKeys { template - typename Pair::first_type operator()(const Pair& p) const - { + typename Pair::first_type operator()(const Pair& p) const { return p.first; } }; @@ -2157,11 +2155,11 @@ struct ValueFlowForwardAnalyzer : ForwardAnalyzer { const TokenList* tokenlist; ValueFlowForwardAnalyzer() - : tokenlist(nullptr) + : tokenlist(nullptr) {} ValueFlowForwardAnalyzer(const TokenList* t) - : tokenlist(t) + : tokenlist(t) {} virtual int getIndirect() const = 0; @@ -2276,11 +2274,11 @@ struct SingleValueFlowForwardAnalyzer : ValueFlowForwardAnalyzer { ValueFlow::Value value; SingleValueFlowForwardAnalyzer() - : ValueFlowForwardAnalyzer() + : ValueFlowForwardAnalyzer() {} SingleValueFlowForwardAnalyzer(const ValueFlow::Value& v, const TokenList* t) - : ValueFlowForwardAnalyzer(t), value(v) + : ValueFlowForwardAnalyzer(t), value(v) {} virtual const std::unordered_map& getVars() const = 0; @@ -2292,7 +2290,7 @@ struct SingleValueFlowForwardAnalyzer : ValueFlowForwardAnalyzer { virtual bool isAlias(const Token* tok) const OVERRIDE { if (value.isLifetimeValue()) return false; - for(const auto& p:getVars()) { + for (const auto& p:getVars()) { nonneg int varid = p.first; const Variable* var = p.second; if (tok->varId() == varid) @@ -2308,7 +2306,7 @@ struct SingleValueFlowForwardAnalyzer : ValueFlowForwardAnalyzer { } virtual bool isGlobal() const OVERRIDE { - for(const auto&p:getVars()) { + for (const auto&p:getVars()) { const Variable* var = p.second; if (var->isGlobal() && !var->isConst()) return true; @@ -2400,11 +2398,11 @@ struct VariableForwardAnalyzer : SingleValueFlowForwardAnalyzer { std::unordered_map varids; VariableForwardAnalyzer() - : SingleValueFlowForwardAnalyzer(), var(nullptr), varids() + : SingleValueFlowForwardAnalyzer(), var(nullptr), varids() {} VariableForwardAnalyzer(const Variable* v, const ValueFlow::Value& val, const TokenList* t) - : SingleValueFlowForwardAnalyzer(val, t), var(v), varids() { + : SingleValueFlowForwardAnalyzer(val, t), var(v), varids() { varids[var->declarationId()] = var; } @@ -2448,22 +2446,20 @@ struct ExpressionForwardAnalyzer : SingleValueFlowForwardAnalyzer { bool unknown; ExpressionForwardAnalyzer() - : SingleValueFlowForwardAnalyzer(), expr(nullptr), varids(), local(true), unknown(false) + : SingleValueFlowForwardAnalyzer(), expr(nullptr), varids(), local(true), unknown(false) {} ExpressionForwardAnalyzer(const Token* e, const ValueFlow::Value& val, const TokenList* t) - : SingleValueFlowForwardAnalyzer(val, t), expr(e), varids(), local(true), unknown(false) { + : SingleValueFlowForwardAnalyzer(val, t), expr(e), varids(), local(true), unknown(false) { setupExprVarIds(); } - static bool nonLocal(const Variable* var, bool deref) - { + static bool nonLocal(const Variable* var, bool deref) { return !var || (!var->isLocal() && !var->isArgument()) || (deref && var->isArgument() && var->isPointer()) || var->isStatic() || var->isReference() || var->isExtern(); } - void setupExprVarIds() - { + void setupExprVarIds() { visitAstNodes(expr, [&](const Token *tok) { if (tok->varId() == 0 && tok->isName() && tok->previous()->str() != ".") { @@ -2492,7 +2488,7 @@ struct ExpressionForwardAnalyzer : SingleValueFlowForwardAnalyzer { virtual std::vector evaluate(const Token* tok) const OVERRIDE { if (tok->hasKnownIntValue()) return {static_cast(tok->values().front().intvalue)}; - return std::vector{}; + return std::vector {}; } virtual const std::unordered_map& getVars() const OVERRIDE {