astyle formatting
This commit is contained in:
parent
829c543331
commit
7182da5c8e
|
@ -44,41 +44,63 @@ struct Analyzer {
|
||||||
Idempotent = (1 << 5),
|
Idempotent = (1 << 5),
|
||||||
};
|
};
|
||||||
|
|
||||||
void set(unsigned int f, bool state = true) { mFlag = state ? mFlag | f : mFlag & ~f; }
|
void set(unsigned int f, bool state = true) {
|
||||||
|
mFlag = state ? mFlag | f : mFlag & ~f;
|
||||||
|
}
|
||||||
|
|
||||||
bool get(unsigned int f) const { return ((mFlag & f) != 0); }
|
bool get(unsigned int f) const {
|
||||||
|
return ((mFlag & f) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
bool isRead() const { return get(Read); }
|
bool isRead() const {
|
||||||
|
return get(Read);
|
||||||
|
}
|
||||||
|
|
||||||
bool isWrite() const { return get(Write); }
|
bool isWrite() const {
|
||||||
|
return get(Write);
|
||||||
|
}
|
||||||
|
|
||||||
bool isInvalid() const { return get(Invalid); }
|
bool isInvalid() const {
|
||||||
|
return get(Invalid);
|
||||||
|
}
|
||||||
|
|
||||||
bool isInconclusive() const { return get(Inconclusive); }
|
bool isInconclusive() const {
|
||||||
|
return get(Inconclusive);
|
||||||
|
}
|
||||||
|
|
||||||
bool isNone() const { return mFlag == None; }
|
bool isNone() const {
|
||||||
|
return mFlag == None;
|
||||||
|
}
|
||||||
|
|
||||||
bool isModified() const { return isWrite() || isInvalid(); }
|
bool isModified() const {
|
||||||
|
return isWrite() || isInvalid();
|
||||||
|
}
|
||||||
|
|
||||||
bool isIdempotent() const { return get(Idempotent); }
|
bool isIdempotent() const {
|
||||||
|
return get(Idempotent);
|
||||||
|
}
|
||||||
|
|
||||||
bool matches() const { return get(Match); }
|
bool matches() const {
|
||||||
|
return get(Match);
|
||||||
|
}
|
||||||
|
|
||||||
Action& operator|=(Action a)
|
Action& operator|=(Action a) {
|
||||||
{
|
|
||||||
set(a.mFlag);
|
set(a.mFlag);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend Action operator|(Action a, Action b)
|
friend Action operator|(Action a, Action b) {
|
||||||
{
|
|
||||||
a |= b;
|
a |= b;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator==(Action a, Action b) { return a.mFlag == b.mFlag; }
|
friend bool operator==(Action a, Action b) {
|
||||||
|
return a.mFlag == b.mFlag;
|
||||||
|
}
|
||||||
|
|
||||||
friend bool operator!=(Action a, Action b) { return a.mFlag != b.mFlag; }
|
friend bool operator!=(Action a, Action b) {
|
||||||
|
return a.mFlag != b.mFlag;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned int mFlag;
|
unsigned int mFlag;
|
||||||
|
|
|
@ -315,8 +315,14 @@ static T* previousBeforeAstLeftmostLeafGeneric(T* tok)
|
||||||
return leftmostLeaf->previous();
|
return leftmostLeaf->previous();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Token* previousBeforeAstLeftmostLeaf(const Token* tok) { return previousBeforeAstLeftmostLeafGeneric(tok); }
|
const Token* previousBeforeAstLeftmostLeaf(const Token* tok)
|
||||||
Token* previousBeforeAstLeftmostLeaf(Token* tok) { return previousBeforeAstLeftmostLeafGeneric(tok); }
|
{
|
||||||
|
return previousBeforeAstLeftmostLeafGeneric(tok);
|
||||||
|
}
|
||||||
|
Token* previousBeforeAstLeftmostLeaf(Token* tok)
|
||||||
|
{
|
||||||
|
return previousBeforeAstLeftmostLeafGeneric(tok);
|
||||||
|
}
|
||||||
|
|
||||||
template <class T, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*>)>
|
template <class T, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*>)>
|
||||||
static T* nextAfterAstRightmostLeafGeneric(T* tok)
|
static T* nextAfterAstRightmostLeafGeneric(T* tok)
|
||||||
|
|
|
@ -26,8 +26,12 @@ struct ForwardTraversal {
|
||||||
std::pair<bool, bool> evalCond(const Token* tok) {
|
std::pair<bool, bool> evalCond(const Token* tok) {
|
||||||
std::vector<int> result = analyzer->evaluate(tok);
|
std::vector<int> result = analyzer->evaluate(tok);
|
||||||
// TODO: We should convert to bool
|
// TODO: We should convert to bool
|
||||||
bool checkThen = std::any_of(result.begin(), result.end(), [](int x) { return x == 1; });
|
bool checkThen = std::any_of(result.begin(), result.end(), [](int x) {
|
||||||
bool checkElse = std::any_of(result.begin(), result.end(), [](int x) { return x == 0; });
|
return x == 1;
|
||||||
|
});
|
||||||
|
bool checkElse = std::any_of(result.begin(), result.end(), [](int x) {
|
||||||
|
return x == 0;
|
||||||
|
});
|
||||||
return std::make_pair(checkThen, checkElse);
|
return std::make_pair(checkThen, checkElse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,8 +154,7 @@ struct ForwardTraversal {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
T* findRange(T* start, const Token* end, std::function<bool(Analyzer::Action)> pred)
|
T* findRange(T* start, const Token* end, std::function<bool(Analyzer::Action)> pred) {
|
||||||
{
|
|
||||||
for (T* tok = start; tok && tok != end; tok = tok->next()) {
|
for (T* tok = start; tok && tok != end; tok = tok->next()) {
|
||||||
Analyzer::Action action = analyzer->analyze(tok, Analyzer::Direction::Forward);
|
Analyzer::Action action = analyzer->analyze(tok, Analyzer::Direction::Forward);
|
||||||
if (pred(action))
|
if (pred(action))
|
||||||
|
@ -160,8 +163,7 @@ struct ForwardTraversal {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Analyzer::Action analyzeRecursive(const Token* start)
|
Analyzer::Action analyzeRecursive(const Token* start) {
|
||||||
{
|
|
||||||
Analyzer::Action result = Analyzer::Action::None;
|
Analyzer::Action result = Analyzer::Action::None;
|
||||||
std::function<Progress(const Token*)> f = [&](const Token* tok) {
|
std::function<Progress(const Token*)> f = [&](const Token* tok) {
|
||||||
result = analyzer->analyze(tok, Analyzer::Direction::Forward);
|
result = analyzer->analyze(tok, Analyzer::Direction::Forward);
|
||||||
|
@ -173,8 +175,7 @@ struct ForwardTraversal {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Analyzer::Action analyzeRange(const Token* start, const Token* end)
|
Analyzer::Action analyzeRange(const Token* start, const Token* end) {
|
||||||
{
|
|
||||||
Analyzer::Action result = Analyzer::Action::None;
|
Analyzer::Action result = Analyzer::Action::None;
|
||||||
for (const Token* tok = start; tok && tok != end; tok = tok->next()) {
|
for (const Token* tok = start; tok && tok != end; tok = tok->next()) {
|
||||||
Analyzer::Action action = analyzer->analyze(tok, Analyzer::Direction::Forward);
|
Analyzer::Action action = analyzer->analyze(tok, Analyzer::Direction::Forward);
|
||||||
|
@ -211,17 +212,17 @@ struct ForwardTraversal {
|
||||||
Inconclusive,
|
Inconclusive,
|
||||||
};
|
};
|
||||||
|
|
||||||
Analyzer::Action analyzeScope(const Token* endBlock) { return analyzeRange(endBlock->link(), endBlock); }
|
Analyzer::Action analyzeScope(const Token* endBlock) {
|
||||||
|
return analyzeRange(endBlock->link(), endBlock);
|
||||||
|
}
|
||||||
|
|
||||||
Analyzer::Action checkScope(Token* endBlock)
|
Analyzer::Action checkScope(Token* endBlock) {
|
||||||
{
|
|
||||||
Analyzer::Action a = analyzeScope(endBlock);
|
Analyzer::Action a = analyzeScope(endBlock);
|
||||||
forkScope(endBlock, a.isModified());
|
forkScope(endBlock, a.isModified());
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
Analyzer::Action checkScope(const Token* endBlock)
|
Analyzer::Action checkScope(const Token* endBlock) {
|
||||||
{
|
|
||||||
Analyzer::Action a = analyzeScope(endBlock);
|
Analyzer::Action a = analyzeScope(endBlock);
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,17 +17,19 @@ struct ReverseTraversal {
|
||||||
ValuePtr<Analyzer> analyzer;
|
ValuePtr<Analyzer> analyzer;
|
||||||
const Settings* settings;
|
const Settings* settings;
|
||||||
|
|
||||||
std::pair<bool, bool> evalCond(const Token* tok)
|
std::pair<bool, bool> evalCond(const Token* tok) {
|
||||||
{
|
|
||||||
std::vector<int> result = analyzer->evaluate(tok);
|
std::vector<int> result = analyzer->evaluate(tok);
|
||||||
// TODO: We should convert to bool
|
// TODO: We should convert to bool
|
||||||
bool checkThen = std::any_of(result.begin(), result.end(), [](int x) { return x == 1; });
|
bool checkThen = std::any_of(result.begin(), result.end(), [](int x) {
|
||||||
bool checkElse = std::any_of(result.begin(), result.end(), [](int x) { return x == 0; });
|
return x == 1;
|
||||||
|
});
|
||||||
|
bool checkElse = std::any_of(result.begin(), result.end(), [](int x) {
|
||||||
|
return x == 0;
|
||||||
|
});
|
||||||
return std::make_pair(checkThen, checkElse);
|
return std::make_pair(checkThen, checkElse);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool update(Token* tok)
|
bool update(Token* tok) {
|
||||||
{
|
|
||||||
Analyzer::Action action = analyzer->analyze(tok, Analyzer::Direction::Reverse);
|
Analyzer::Action action = analyzer->analyze(tok, Analyzer::Direction::Reverse);
|
||||||
if (!action.isNone())
|
if (!action.isNone())
|
||||||
analyzer->update(tok, action, Analyzer::Direction::Reverse);
|
analyzer->update(tok, action, Analyzer::Direction::Reverse);
|
||||||
|
@ -38,8 +40,7 @@ struct ReverseTraversal {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool updateRecursive(Token* start)
|
bool updateRecursive(Token* start) {
|
||||||
{
|
|
||||||
bool continueB = true;
|
bool continueB = true;
|
||||||
visitAstNodes(start, [&](Token* tok) {
|
visitAstNodes(start, [&](Token* tok) {
|
||||||
continueB &= update(tok);
|
continueB &= update(tok);
|
||||||
|
@ -51,8 +52,7 @@ struct ReverseTraversal {
|
||||||
return continueB;
|
return continueB;
|
||||||
}
|
}
|
||||||
|
|
||||||
Analyzer::Action analyzeRecursive(const Token* start)
|
Analyzer::Action analyzeRecursive(const Token* start) {
|
||||||
{
|
|
||||||
Analyzer::Action result = Analyzer::Action::None;
|
Analyzer::Action result = Analyzer::Action::None;
|
||||||
visitAstNodes(start, [&](const Token* tok) {
|
visitAstNodes(start, [&](const Token* tok) {
|
||||||
result |= analyzer->analyze(tok, Analyzer::Direction::Reverse);
|
result |= analyzer->analyze(tok, Analyzer::Direction::Reverse);
|
||||||
|
@ -63,8 +63,7 @@ struct ReverseTraversal {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Analyzer::Action analyzeRange(const Token* start, const Token* end)
|
Analyzer::Action analyzeRange(const Token* start, const Token* end) {
|
||||||
{
|
|
||||||
Analyzer::Action result = Analyzer::Action::None;
|
Analyzer::Action result = Analyzer::Action::None;
|
||||||
for (const Token* tok = start; tok && tok != end; tok = tok->next()) {
|
for (const Token* tok = start; tok && tok != end; tok = tok->next()) {
|
||||||
Analyzer::Action action = analyzer->analyze(tok, Analyzer::Direction::Reverse);
|
Analyzer::Action action = analyzer->analyze(tok, Analyzer::Direction::Reverse);
|
||||||
|
@ -75,8 +74,7 @@ struct ReverseTraversal {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Token* isDeadCode(Token* tok)
|
Token* isDeadCode(Token* tok) {
|
||||||
{
|
|
||||||
int opSide = 0;
|
int opSide = 0;
|
||||||
for (; tok && tok->astParent(); tok = tok->astParent()) {
|
for (; tok && tok->astParent(); tok = tok->astParent()) {
|
||||||
Token* parent = tok->astParent();
|
Token* parent = tok->astParent();
|
||||||
|
@ -118,8 +116,7 @@ struct ReverseTraversal {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void traverse(Token* start)
|
void traverse(Token* start) {
|
||||||
{
|
|
||||||
for (Token* tok = start->previous(); tok; tok = tok->previous()) {
|
for (Token* tok = start->previous(); tok; tok = tok->previous()) {
|
||||||
if (tok == start || (tok->str() == "{" && (tok->scope()->type == Scope::ScopeType::eFunction ||
|
if (tok == start || (tok->str() == "{" && (tok->scope()->type == Scope::ScopeType::eFunction ||
|
||||||
tok->scope()->type == Scope::ScopeType::eLambda))) {
|
tok->scope()->type == Scope::ScopeType::eLambda))) {
|
||||||
|
@ -256,8 +253,7 @@ struct ReverseTraversal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Token* assignExpr(Token* tok)
|
static Token* assignExpr(Token* tok) {
|
||||||
{
|
|
||||||
while (tok->astParent() && (astIsRHS(tok) || !tok->astParent()->isBinaryOp())) {
|
while (tok->astParent() && (astIsRHS(tok) || !tok->astParent()->isBinaryOp())) {
|
||||||
if (tok->astParent()->isAssignmentOp())
|
if (tok->astParent()->isAssignmentOp())
|
||||||
return tok->astParent();
|
return tok->astParent();
|
||||||
|
@ -266,8 +262,7 @@ struct ReverseTraversal {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Token* isUnevaluated(Token* tok)
|
static Token* isUnevaluated(Token* tok) {
|
||||||
{
|
|
||||||
if (Token::Match(tok, ")|>") && tok->link()) {
|
if (Token::Match(tok, ")|>") && tok->link()) {
|
||||||
Token* start = tok->link();
|
Token* start = tok->link();
|
||||||
if (Token::Match(start->previous(), "sizeof|decltype ("))
|
if (Token::Match(start->previous(), "sizeof|decltype ("))
|
||||||
|
|
|
@ -1908,7 +1908,8 @@ static void valueFlowAST(Token *tok, nonneg int varid, const ValueFlow::Value &v
|
||||||
static const std::string& invertAssign(const std::string& assign)
|
static const std::string& invertAssign(const std::string& assign)
|
||||||
{
|
{
|
||||||
static std::unordered_map<std::string, std::string> lookup = {
|
static std::unordered_map<std::string, std::string> lookup = {
|
||||||
{"+=", "-="}, {"-=", "+="}, {"*=", "/="}, {"/=", "*="}, {"<<=", ">>="}, {">>=", "<<="}, {"^=", "^="}};
|
{"+=", "-="}, {"-=", "+="}, {"*=", "/="}, {"/=", "*="}, {"<<=", ">>="}, {">>=", "<<="}, {"^=", "^="}
|
||||||
|
};
|
||||||
static std::string empty = "";
|
static std::string empty = "";
|
||||||
auto it = lookup.find(assign);
|
auto it = lookup.find(assign);
|
||||||
if (it == lookup.end())
|
if (it == lookup.end())
|
||||||
|
@ -2142,8 +2143,7 @@ struct ValueFlowAnalyzer : Analyzer {
|
||||||
return Action::None;
|
return Action::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Action isWritable(const Token* tok, Direction d) const
|
virtual Action isWritable(const Token* tok, Direction d) const {
|
||||||
{
|
|
||||||
const ValueFlow::Value* value = getValue(tok);
|
const ValueFlow::Value* value = getValue(tok);
|
||||||
if (!value)
|
if (!value)
|
||||||
return Action::None;
|
return Action::None;
|
||||||
|
@ -2179,16 +2179,14 @@ struct ValueFlowAnalyzer : Analyzer {
|
||||||
return Action::None;
|
return Action::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const std::string& getAssign(const Token* tok, Direction d)
|
static const std::string& getAssign(const Token* tok, Direction d) {
|
||||||
{
|
|
||||||
if (d == Direction::Forward)
|
if (d == Direction::Forward)
|
||||||
return tok->str();
|
return tok->str();
|
||||||
else
|
else
|
||||||
return invertAssign(tok->str());
|
return invertAssign(tok->str());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void writeValue(ValueFlow::Value* value, const Token* tok, Direction d) const
|
virtual void writeValue(ValueFlow::Value* value, const Token* tok, Direction d) const {
|
||||||
{
|
|
||||||
if (!value)
|
if (!value)
|
||||||
return;
|
return;
|
||||||
if (!tok->astParent())
|
if (!tok->astParent())
|
||||||
|
@ -2218,8 +2216,7 @@ struct ValueFlowAnalyzer : Analyzer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Action analyze(const Token* tok, Direction d) const OVERRIDE
|
virtual Action analyze(const Token* tok, Direction d) const OVERRIDE {
|
||||||
{
|
|
||||||
if (invalid())
|
if (invalid())
|
||||||
return Action::Invalid;
|
return Action::Invalid;
|
||||||
bool inconclusive = false;
|
bool inconclusive = false;
|
||||||
|
@ -2306,8 +2303,7 @@ struct ValueFlowAnalyzer : Analyzer {
|
||||||
makeConditional();
|
makeConditional();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void update(Token* tok, Action a, Direction d) OVERRIDE
|
virtual void update(Token* tok, Action a, Direction d) OVERRIDE {
|
||||||
{
|
|
||||||
ValueFlow::Value* value = getValue(tok);
|
ValueFlow::Value* value = getValue(tok);
|
||||||
if (!value)
|
if (!value)
|
||||||
return;
|
return;
|
||||||
|
@ -2324,7 +2320,9 @@ struct ValueFlowAnalyzer : Analyzer {
|
||||||
setTokenValue(tok, *value, getSettings());
|
setTokenValue(tok, *value, getSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ValuePtr<Analyzer> reanalyze(Token*, const std::string&) const OVERRIDE { return {}; }
|
virtual ValuePtr<Analyzer> reanalyze(Token*, const std::string&) const OVERRIDE {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ValuePtr<Analyzer> makeAnalyzer(Token* exprTok, const ValueFlow::Value& value, const TokenList* tokenlist);
|
ValuePtr<Analyzer> makeAnalyzer(Token* exprTok, const ValueFlow::Value& value, const TokenList* tokenlist);
|
||||||
|
@ -2432,8 +2430,7 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ValuePtr<Analyzer> reanalyze(Token* tok, const std::string& msg) const OVERRIDE
|
virtual ValuePtr<Analyzer> reanalyze(Token* tok, const std::string& msg) const OVERRIDE {
|
||||||
{
|
|
||||||
ValueFlow::Value newValue = value;
|
ValueFlow::Value newValue = value;
|
||||||
newValue.errorPath.emplace_back(tok, msg);
|
newValue.errorPath.emplace_back(tok, msg);
|
||||||
return makeAnalyzer(tok, newValue, tokenlist);
|
return makeAnalyzer(tok, newValue, tokenlist);
|
||||||
|
@ -2449,8 +2446,7 @@ struct VariableAnalyzer : SingleValueFlowAnalyzer {
|
||||||
const ValueFlow::Value& val,
|
const ValueFlow::Value& val,
|
||||||
std::vector<const Variable*> paliases,
|
std::vector<const Variable*> paliases,
|
||||||
const TokenList* t)
|
const TokenList* t)
|
||||||
: SingleValueFlowAnalyzer(val, t), var(v)
|
: SingleValueFlowAnalyzer(val, t), var(v) {
|
||||||
{
|
|
||||||
varids[var->declarationId()] = var;
|
varids[var->declarationId()] = var;
|
||||||
for (const Variable* av:paliases) {
|
for (const Variable* av:paliases) {
|
||||||
if (!av)
|
if (!av)
|
||||||
|
@ -2550,8 +2546,7 @@ struct ExpressionAnalyzer : SingleValueFlowAnalyzer {
|
||||||
ExpressionAnalyzer() : SingleValueFlowAnalyzer(), expr(nullptr), local(true), unknown(false) {}
|
ExpressionAnalyzer() : SingleValueFlowAnalyzer(), expr(nullptr), local(true), unknown(false) {}
|
||||||
|
|
||||||
ExpressionAnalyzer(const Token* e, const ValueFlow::Value& val, const TokenList* t)
|
ExpressionAnalyzer(const Token* e, const ValueFlow::Value& val, const TokenList* t)
|
||||||
: SingleValueFlowAnalyzer(val, t), expr(e), local(true), unknown(false)
|
: SingleValueFlowAnalyzer(val, t), expr(e), local(true), unknown(false) {
|
||||||
{
|
|
||||||
|
|
||||||
setupExprVarIds();
|
setupExprVarIds();
|
||||||
}
|
}
|
||||||
|
@ -4923,8 +4918,7 @@ struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
|
||||||
MultiValueFlowAnalyzer() : ValueFlowAnalyzer(), values(), vars() {}
|
MultiValueFlowAnalyzer() : ValueFlowAnalyzer(), values(), vars() {}
|
||||||
|
|
||||||
MultiValueFlowAnalyzer(const std::unordered_map<const Variable*, ValueFlow::Value>& args, const TokenList* t)
|
MultiValueFlowAnalyzer(const std::unordered_map<const Variable*, ValueFlow::Value>& args, const TokenList* t)
|
||||||
: ValueFlowAnalyzer(t), values(), vars()
|
: ValueFlowAnalyzer(t), values(), vars() {
|
||||||
{
|
|
||||||
for (const auto& p:args) {
|
for (const auto& p:args) {
|
||||||
values[p.first->declarationId()] = p.second;
|
values[p.first->declarationId()] = p.second;
|
||||||
vars[p.first->declarationId()] = p.first;
|
vars[p.first->declarationId()] = p.first;
|
||||||
|
@ -5774,8 +5768,7 @@ struct ContainerVariableAnalyzer : VariableAnalyzer {
|
||||||
return tok->varId() == var->declarationId() || (astIsIterator(tok) && isAliasOf(tok, var->declarationId()));
|
return tok->varId() == var->declarationId() || (astIsIterator(tok) && isAliasOf(tok, var->declarationId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Action isWritable(const Token* tok, Direction d) const OVERRIDE
|
virtual Action isWritable(const Token* tok, Direction d) const OVERRIDE {
|
||||||
{
|
|
||||||
if (astIsIterator(tok))
|
if (astIsIterator(tok))
|
||||||
return Action::None;
|
return Action::None;
|
||||||
if (d == Direction::Reverse)
|
if (d == Direction::Reverse)
|
||||||
|
@ -5805,8 +5798,7 @@ struct ContainerVariableAnalyzer : VariableAnalyzer {
|
||||||
return Action::None;
|
return Action::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void writeValue(ValueFlow::Value* value, const Token* tok, Direction d) const OVERRIDE
|
virtual void writeValue(ValueFlow::Value* value, const Token* tok, Direction d) const OVERRIDE {
|
||||||
{
|
|
||||||
if (d == Direction::Reverse)
|
if (d == Direction::Reverse)
|
||||||
return;
|
return;
|
||||||
if (!value)
|
if (!value)
|
||||||
|
|
|
@ -56,8 +56,7 @@ namespace ValueFlow {
|
||||||
|
|
||||||
struct equalVisitor {
|
struct equalVisitor {
|
||||||
template <class T, class U>
|
template <class T, class U>
|
||||||
void operator()(bool& result, T x, U y) const
|
void operator()(bool& result, T x, U y) const {
|
||||||
{
|
|
||||||
result = !(x > y || x < y);
|
result = !(x > y || x < y);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -122,8 +121,7 @@ namespace ValueFlow {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class F>
|
template <class T, class F>
|
||||||
static void visitValue(T& self, F f)
|
static void visitValue(T& self, F f) {
|
||||||
{
|
|
||||||
switch (self.valueType) {
|
switch (self.valueType) {
|
||||||
case ValueType::INT:
|
case ValueType::INT:
|
||||||
case ValueType::BUFFER_SIZE:
|
case ValueType::BUFFER_SIZE:
|
||||||
|
@ -163,8 +161,7 @@ namespace ValueFlow {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, REQUIRES("T must be an arithmetic type", std::is_arithmetic<T>)>
|
template <class T, REQUIRES("T must be an arithmetic type", std::is_arithmetic<T>)>
|
||||||
bool equalTo(const T& x) const
|
bool equalTo(const T& x) const {
|
||||||
{
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
visitValue(*this, std::bind(equalVisitor{}, std::ref(result), x, std::placeholders::_1));
|
visitValue(*this, std::bind(equalVisitor{}, std::ref(result), x, std::placeholders::_1));
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -1899,8 +1899,7 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void nullpointer61()
|
void nullpointer61() {
|
||||||
{
|
|
||||||
check("struct a {\n"
|
check("struct a {\n"
|
||||||
" int *e;\n"
|
" int *e;\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
@ -1933,8 +1932,7 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void nullpointer62()
|
void nullpointer62() {
|
||||||
{
|
|
||||||
check("struct A {\n"
|
check("struct A {\n"
|
||||||
" bool f()() const;\n"
|
" bool f()() const;\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
@ -1964,8 +1962,7 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void nullpointer63()
|
void nullpointer63() {
|
||||||
{
|
|
||||||
check("struct A {\n"
|
check("struct A {\n"
|
||||||
" A* a() const;\n"
|
" A* a() const;\n"
|
||||||
" A* b() const;\n"
|
" A* b() const;\n"
|
||||||
|
@ -1979,8 +1976,7 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void nullpointer64()
|
void nullpointer64() {
|
||||||
{
|
|
||||||
check("struct A {\n"
|
check("struct A {\n"
|
||||||
" A* f() const;\n"
|
" A* f() const;\n"
|
||||||
" int g() const;\n"
|
" int g() const;\n"
|
||||||
|
|
Loading…
Reference in New Issue