Skip to content
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
1 change: 1 addition & 0 deletions lib/checkbufferoverrun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "tokenlist.h"
#include "utils.h"
#include "valueflow.h"
#include "vfvalue.h"

#include <algorithm>
#include <cstdlib>
Expand Down
6 changes: 5 additions & 1 deletion lib/checkbufferoverrun.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "check.h"
#include "config.h"
#include "ctu.h"
#include "vfvalue.h"

#include <cstdint>
#include <list>
Expand All @@ -41,6 +40,11 @@ class Variable;
struct Dimension;
enum class Certainty : std::uint8_t;

namespace ValueFlow
{
class Value;
}

/// @addtogroup Checks
/// @{

Expand Down
8 changes: 8 additions & 0 deletions lib/checknullpointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "tokenize.h"
#include "tokenlist.h"
#include "valueflow.h"
#include "vfvalue.h"

#include <algorithm>
#include <cctype>
Expand Down Expand Up @@ -433,6 +434,13 @@ void CheckNullPointer::nullConstantDereference()
}
}

void CheckNullPointer::nullPointerError(const Token *tok)
{
ValueFlow::Value v(0);
v.setKnown();
nullPointerError(tok, "", &v, false);
}

void CheckNullPointer::nullPointerError(const Token *tok, const std::string &varname, const ValueFlow::Value *value, bool inconclusive)
{
const std::string errmsgcond("$symbol:" + varname + '\n' + ValueFlow::eitherTheConditionIsRedundant(value ? value->condition : nullptr) + " or there is possible null pointer dereference: $symbol.");
Expand Down
12 changes: 6 additions & 6 deletions lib/checknullpointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

#include "check.h"
#include "config.h"
#include "vfvalue.h"

#include <list>
#include <string>
Expand All @@ -35,6 +34,11 @@ class Settings;
class Token;
class Tokenizer;

namespace ValueFlow
{
class Value;
}

/// @addtogroup Checks
/// @{

Expand Down Expand Up @@ -85,11 +89,7 @@ class CPPCHECKLIB CheckNullPointer : public Check {
/** @brief dereferencing null constant (after Tokenizer::simplifyKnownVariables) */
void nullConstantDereference();

void nullPointerError(const Token *tok) {
ValueFlow::Value v(0);
v.setKnown();
nullPointerError(tok, "", &v, false);
}
void nullPointerError(const Token *tok);
void nullPointerError(const Token *tok, const std::string &varname, const ValueFlow::Value* value, bool inconclusive);

/** @brief Parse current TU and extract file info */
Expand Down
1 change: 1 addition & 0 deletions lib/infer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "errortypes.h"
#include "token.h"
#include "valueptr.h"
#include "vfvalue.h"

#include <cassert>
#include <algorithm>
Expand Down
6 changes: 5 additions & 1 deletion lib/infer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "config.h"
#include "mathlib.h"
#include "vfvalue.h"

#include <list>
#include <string>
Expand All @@ -30,6 +29,11 @@
class Token;
template<class T> class ValuePtr;

namespace ValueFlow
{
class Value;
}

struct InferModel {
virtual bool match(const ValueFlow::Value& value) const = 0;
virtual ValueFlow::Value yield(MathLib::bigint value) const = 0;
Expand Down
1 change: 1 addition & 0 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "tokenlist.h"
#include "utils.h"
#include "valueflow.h"
#include "vfvalue.h"

#include <algorithm>
#include <cassert>
Expand Down
6 changes: 5 additions & 1 deletion lib/valueflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "config.h"
#include "errortypes.h"
#include "mathlib.h"
#include "vfvalue.h"

#include <cstdlib>
#include <functional>
Expand All @@ -43,6 +42,11 @@ class ValueType;
class Variable;
class Scope;

namespace ValueFlow
{
class Value;
}

namespace ValueFlow {
/// Constant folding of expression. This can be used before the full ValueFlow has been executed (ValueFlow::setValues).
const Value * valueFlowConstantFoldAST(Token *expr, const Settings &settings);
Expand Down
1 change: 1 addition & 0 deletions lib/vf_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "symboldatabase.h"
#include "token.h"
#include "valueflow.h"
#include "vfvalue.h"

#include "vf_settokenvalue.h"

Expand Down
6 changes: 5 additions & 1 deletion lib/vf_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "mathlib.h"
#include "sourcelocation.h"
#include "symboldatabase.h"
#include "vfvalue.h"

#include <cstddef>
#include <string>
Expand All @@ -32,6 +31,11 @@ class Token;
class Settings;
class Platform;

namespace ValueFlow
{
class Value;
}

namespace ValueFlow
{
bool getMinMaxValues(const ValueType* vt, const Platform& platform, MathLib::bigint& minValue, MathLib::bigint& maxValue);
Expand Down