diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index f1b7e6d0e7e..ad625119b99 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -1972,7 +1972,7 @@ ValueFlow::Value ValueFlow::getLifetimeObjValue(const Token *tok, bool inconclus template static std::vector getLifetimeTokens(const Token* tok, bool escape, - ValueFlow::Value::ErrorPath errorPath, + ErrorPath errorPath, Predicate pred, const Settings& settings, int depth = 20) @@ -2120,7 +2120,7 @@ static std::vector getLifetimeTokens(const Token* tok, return {{tok, std::move(errorPath)}}; } -std::vector ValueFlow::getLifetimeTokens(const Token* tok, const Settings& settings, bool escape, ValueFlow::Value::ErrorPath errorPath) +std::vector ValueFlow::getLifetimeTokens(const Token* tok, const Settings& settings, bool escape, ErrorPath errorPath) { return getLifetimeTokens(tok, escape, std::move(errorPath), [](const Token*) { return false; @@ -2130,14 +2130,14 @@ std::vector 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 lts = ValueFlow::getLifetimeTokens(tok, settings); if (lts.size() != 1) @@ -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()) @@ -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); } diff --git a/lib/valueflow.h b/lib/valueflow.h index 01633367461..1f7554048ef 100644 --- a/lib/valueflow.h +++ b/lib/valueflow.h @@ -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) {} @@ -112,17 +112,17 @@ namespace ValueFlow { std::vector 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); diff --git a/lib/vfvalue.h b/lib/vfvalue.h index c39a6a6af68..7671c3e3aed 100644 --- a/lib/vfvalue.h +++ b/lib/vfvalue.h @@ -22,13 +22,13 @@ //--------------------------------------------------------------------------- #include "config.h" +#include "errortypes.h" #include "mathlib.h" #include #include #include #include -#include #include #include #include @@ -40,8 +40,6 @@ namespace ValueFlow { class CPPCHECKLIB Value { public: - using ErrorPathItem = std::pair; - using ErrorPath = std::list; enum class Bound : std::uint8_t { Upper, Lower, Point }; explicit Value(long long val = 0, Bound b = Bound::Point) : diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index bc13f92f112..33eab3b875d 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -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';