Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed duplicated ErrorPath* aliases #6763

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,7 @@ ValueFlow::Value ValueFlow::getLifetimeObjValue(const Token *tok, bool inconclus
template<class Predicate>
static std::vector<ValueFlow::LifetimeToken> getLifetimeTokens(const Token* tok,
bool escape,
ValueFlow::Value::ErrorPath errorPath,
ErrorPath errorPath,
Predicate pred,
const Settings& settings,
int depth = 20)
Expand Down Expand Up @@ -2120,7 +2120,7 @@ static std::vector<ValueFlow::LifetimeToken> getLifetimeTokens(const Token* tok,
return {{tok, std::move(errorPath)}};
}

std::vector<ValueFlow::LifetimeToken> ValueFlow::getLifetimeTokens(const Token* tok, const Settings& settings, bool escape, ValueFlow::Value::ErrorPath errorPath)
std::vector<ValueFlow::LifetimeToken> ValueFlow::getLifetimeTokens(const Token* tok, const Settings& settings, bool escape, ErrorPath errorPath)
{
return getLifetimeTokens(tok, escape, std::move(errorPath), [](const Token*) {
return false;
Expand All @@ -2130,14 +2130,14 @@ std::vector<ValueFlow::LifetimeToken> ValueFlow::getLifetimeTokens(const Token*
bool ValueFlow::hasLifetimeToken(const Token* tok, const Token* lifetime, const Settings& settings)
{
bool result = false;
getLifetimeTokens(tok, false, ValueFlow::Value::ErrorPath{}, [&](const Token* tok2) {
getLifetimeTokens(tok, false, ErrorPath{}, [&](const Token* tok2) {
result = tok2->exprId() == lifetime->exprId();
return result;
}, settings);
return result;
}

static const Token* getLifetimeToken(const Token* tok, ValueFlow::Value::ErrorPath& errorPath, const Settings& settings, bool* addressOf = nullptr)
static const Token* getLifetimeToken(const Token* tok, ErrorPath& errorPath, const Settings& settings, bool* addressOf = nullptr)
{
std::vector<ValueFlow::LifetimeToken> lts = ValueFlow::getLifetimeTokens(tok, settings);
if (lts.size() != 1)
Expand All @@ -2150,7 +2150,7 @@ static const Token* getLifetimeToken(const Token* tok, ValueFlow::Value::ErrorPa
return lts.front().token;
}

const Variable* ValueFlow::getLifetimeVariable(const Token* tok, ValueFlow::Value::ErrorPath& errorPath, const Settings& settings, bool* addressOf)
const Variable* ValueFlow::getLifetimeVariable(const Token* tok, ErrorPath& errorPath, const Settings& settings, bool* addressOf)
{
const Token* tok2 = getLifetimeToken(tok, errorPath, settings, addressOf);
if (tok2 && tok2->variable())
Expand All @@ -2160,7 +2160,7 @@ const Variable* ValueFlow::getLifetimeVariable(const Token* tok, ValueFlow::Valu

const Variable* ValueFlow::getLifetimeVariable(const Token* tok, const Settings& settings)
{
ValueFlow::Value::ErrorPath errorPath;
ErrorPath errorPath;
return getLifetimeVariable(tok, errorPath, settings, nullptr);
}

Expand Down
12 changes: 6 additions & 6 deletions lib/valueflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ namespace ValueFlow {

struct LifetimeToken {
const Token* token{};
Value::ErrorPath errorPath;
ErrorPath errorPath;
bool addressOf{};
bool inconclusive{};

LifetimeToken() = default;

LifetimeToken(const Token* token, Value::ErrorPath errorPath)
LifetimeToken(const Token* token, ErrorPath errorPath)
: token(token), errorPath(std::move(errorPath))
{}

LifetimeToken(const Token* token, bool addressOf, Value::ErrorPath errorPath)
LifetimeToken(const Token* token, bool addressOf, ErrorPath errorPath)
: token(token), errorPath(std::move(errorPath)), addressOf(addressOf)
{}

Expand Down Expand Up @@ -112,17 +112,17 @@ namespace ValueFlow {
std::vector<LifetimeToken> getLifetimeTokens(const Token* tok,
const Settings& settings,
bool escape = false,
Value::ErrorPath errorPath = Value::ErrorPath{});
ErrorPath errorPath = ErrorPath{});

bool hasLifetimeToken(const Token* tok, const Token* lifetime, const Settings& settings);

const Variable* getLifetimeVariable(const Token* tok, Value::ErrorPath& errorPath, const Settings& settings, bool* addressOf = nullptr);
const Variable* getLifetimeVariable(const Token* tok, ErrorPath& errorPath, const Settings& settings, bool* addressOf = nullptr);

const Variable* getLifetimeVariable(const Token* tok, const Settings& settings);

bool isLifetimeBorrowed(const Token *tok, const Settings &settings);

std::string lifetimeMessage(const Token *tok, const Value *val, Value::ErrorPath &errorPath);
std::string lifetimeMessage(const Token *tok, const Value *val, ErrorPath &errorPath);

CPPCHECKLIB Value getLifetimeObjValue(const Token *tok, bool inconclusive = false);

Expand Down
4 changes: 1 addition & 3 deletions lib/vfvalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
//---------------------------------------------------------------------------

#include "config.h"
#include "errortypes.h"
#include "mathlib.h"

#include <cassert>
#include <cmath>
#include <cstdint>
#include <functional>
#include <list>
#include <string>
#include <type_traits>
#include <utility>
Expand All @@ -40,8 +40,6 @@ namespace ValueFlow
{
class CPPCHECKLIB Value {
public:
using ErrorPathItem = std::pair<const Token *, std::string>;
using ErrorPath = std::list<ErrorPathItem>;
enum class Bound : std::uint8_t { Upper, Lower, Point };

explicit Value(long long val = 0, Bound b = Bound::Point) :
Expand Down
2 changes: 1 addition & 1 deletion test/testvalueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ class TestValueFlow : public TestFixture {

std::ostringstream ostr;
for (const ValueFlow::Value &v : tok->values()) {
for (const ValueFlow::Value::ErrorPathItem &ep : v.errorPath) {
for (const ErrorPathItem &ep : v.errorPath) {
const Token *eptok = ep.first;
const std::string &msg = ep.second;
ostr << eptok->linenr() << ',' << msg << '\n';
Expand Down
Loading