Skip to content

Commit

Permalink
added TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed May 1, 2024
1 parent d65f697 commit 4385cbf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ class CPPCHECKLIB WARN_UNUSED Settings {
/** @brief forced includes given by the user */
std::list<std::string> userIncludes;

// TODO: adjust all options so 0 means "disabled" and -1 "means "unlimited"
struct ValueFlowOptions
{
/** @brief Control if ValueFlow is performed in Tokenizer::simplifyTokens1() */
Expand Down
18 changes: 14 additions & 4 deletions lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1161,8 +1161,10 @@ static size_t bitCeil(size_t x)

static size_t getAlignOf(const ValueType& vt, const Settings& settings, int maxRecursion = 0)
{
if (maxRecursion == settings.vfOptions.maxAlignOfRecursion)
if (maxRecursion == settings.vfOptions.maxAlignOfRecursion) {
// TODO: add bailout message
return 0;
}
if (vt.pointer || vt.reference != Reference::None || vt.isPrimitive()) {
auto align = ValueFlow::getSizeOf(vt, settings);
return align == 0 ? 0 : bitCeil(align);
Expand Down Expand Up @@ -1196,8 +1198,10 @@ static nonneg int getSizeOfType(const Token *typeTok, const Settings &settings)

size_t ValueFlow::getSizeOf(const ValueType &vt, const Settings &settings, int maxRecursion)
{
if (maxRecursion == settings.vfOptions.maxSizeOfRecursion)
if (maxRecursion == settings.vfOptions.maxSizeOfRecursion) {
// TODO: add bailout message
return 0;
}
if (vt.pointer || vt.reference != Reference::None)
return settings.platform.sizeof_pointer;
if (vt.type == ValueType::Type::BOOL || vt.type == ValueType::Type::CHAR)
Expand Down Expand Up @@ -3294,8 +3298,10 @@ struct ExpressionAnalyzer : SingleValueFlowAnalyzer {
}

void setupExprVarIds(const Token* start, int depth = 0) {
if (depth > settings.vfOptions.maxExprVarIdDepth)
if (depth > settings.vfOptions.maxExprVarIdDepth) {
// TODO: add bailout message
return;
}
visitAstNodes(start, [&](const Token* tok) {
const bool top = depth == 0 && tok == start;
const bool ispointer = astIsPointer(tok) || astIsSmartPointer(tok) || astIsIterator(tok);
Expand Down Expand Up @@ -7189,6 +7195,7 @@ static bool valueFlowForLoop2(const Token *tok,
if (!error)
execute(secondExpression, programMemory, &result, &error, settings);
}
// TODO: add bailout message

if (memory1)
memory1->swap(startMemory);
Expand Down Expand Up @@ -7598,6 +7605,7 @@ static bool productParams(const Settings& settings, const std::unordered_map<Key
if (args.size() > max) {
bail = true;
args.resize(max);
// TODO: add bailout message
}

for (const auto& arg:args) {
Expand Down Expand Up @@ -9488,8 +9496,10 @@ struct ValueFlowPassRunner {
bool run(const ValuePtr<ValueFlowPass>& pass) const
{
auto start = Clock::now();
if (start > stop)
if (start > stop) {
// TODO: add bailout message
return true;
}
if (!state.tokenlist.isCPP() && pass->cpp())
return false;
if (timerResults) {
Expand Down

0 comments on commit 4385cbf

Please sign in to comment.