Skip to content

Commit c19a9c2

Browse files
committed
GUI: Only edit contract for non-bailout warnings
1 parent dae009c commit c19a9c2

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

gui/resultstree.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@
5252
static const unsigned int COLUMN_SINCE_DATE = 6;
5353
static const unsigned int COLUMN_TAGS = 7;
5454

55+
static QString getFunction(QStandardItem *item)
56+
{
57+
return item->data().toMap().value("function").toString();
58+
}
59+
5560
ResultsTree::ResultsTree(QWidget * parent) :
5661
QTreeView(parent),
5762
mSettings(nullptr),
@@ -613,7 +618,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
613618

614619
const bool bughunting = !multipleSelection && mContextItem->data().toMap().value("id").toString().startsWith("bughunting");
615620

616-
if (bughunting) {
621+
if (bughunting && !getFunction(mContextItem).isEmpty()) {
617622
QAction *editContract = new QAction(tr("Edit contract.."), &menu);
618623
connect(editContract, &QAction::triggered, this, &ResultsTree::editContract);
619624
menu.addAction(editContract);
@@ -1035,8 +1040,7 @@ void ResultsTree::openContainingFolder()
10351040

10361041
void ResultsTree::editContract()
10371042
{
1038-
QString function = mContextItem->data().toMap().value("function").toString();
1039-
emit editFunctionContract(function);
1043+
emit editFunctionContract(getFunction(mContextItem));
10401044
}
10411045

10421046
void ResultsTree::tagSelectedItems(const QString &tag)

lib/exprengine.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1855,7 +1855,8 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer,
18551855
std::list<const Token*> callstack{settings->clang ? tok : tok->astParent()};
18561856
const char * const id = (tok->valueType() && tok->valueType()->isFloat()) ? "bughuntingDivByZeroFloat" : "bughuntingDivByZero";
18571857
ErrorLogger::ErrorMessage errmsg(callstack, &tokenizer->list, Severity::SeverityType::error, id, "There is division, cannot determine that there can't be a division by zero.", CWE(369), false);
1858-
errmsg.function = dataBase->currentFunction;
1858+
if (value.type != ExprEngine::ValueType::BailoutValue)
1859+
errmsg.function = dataBase->currentFunction;
18591860
errorLogger->reportErr(errmsg);
18601861
}
18611862
};

0 commit comments

Comments
 (0)