Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Aug 5, 2023
2 parents 3c71a4f + de8b415 commit 50ec8f5
Show file tree
Hide file tree
Showing 40 changed files with 741 additions and 624 deletions.
2 changes: 1 addition & 1 deletion cfg/posix.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3362,7 +3362,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
<use-retval/>
<returnValue type="int"/>
<noreturn>false</noreturn>
<arg nr="1" direction="in">
<arg nr="1">
<not-null/>
<not-uninit/>
</arg>
Expand Down
3 changes: 2 additions & 1 deletion cfg/qt.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,12 @@
<!-- QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = ...) -->
<!-- QAction *QMenu::addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut = ...) -->
<!-- QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut = 0) -->
<!-- void QWidget::addAction(QAction *action) -->
<function name="QMenu::addAction">
<noreturn>false</noreturn>
<returnValue type="QAction *"/>
<leak-ignore/>
<arg nr="1" direction="in">
<arg nr="1">
<not-uninit/>
<not-bool/>
</arg>
Expand Down
22 changes: 11 additions & 11 deletions cfg/std.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,7 @@
<returnValue type="int"/>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1" direction="in">
<arg nr="1">
<not-null/>
<not-uninit/>
</arg>
Expand All @@ -1595,7 +1595,7 @@
<returnValue type="int"/>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1" direction="in">
<arg nr="1">
<not-null/>
<not-uninit/>
</arg>
Expand Down Expand Up @@ -2290,7 +2290,7 @@
<returnValue type="int"/>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1" direction="in">
<arg nr="1">
<not-null/>
<not-uninit/>
</arg>
Expand Down Expand Up @@ -3815,7 +3815,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<returnValue type="void *"/>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1" direction="in">
<arg nr="1">
<not-null/>
<not-uninit/>
<minsize type="argvalue" arg="3"/>
Expand All @@ -3838,7 +3838,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<returnValue type="wchar_t *"/>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1" direction="in">
<arg nr="1">
<not-null/>
<not-uninit/>
<minsize type="argvalue" arg="3"/>
Expand Down Expand Up @@ -4851,7 +4851,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<valid>0:255</valid>
</arg>
</function>
<!-- wchar_t wcschr(const wchar_t *cs, wchar_t c); -->
<!-- wchar_t* wcschr(const wchar_t *cs, wchar_t c); -->
<function name="wcschr,std::wcschr">
<use-retval/>
<returnValue type="wchar_t"/>
Expand Down Expand Up @@ -5154,7 +5154,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<returnValue type="char *"/>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1" direction="in">
<arg nr="1">
<not-null/>
<not-uninit/>
<strz/>
Expand All @@ -5172,7 +5172,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<returnValue type="wchar_t *"/>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1" direction="in">
<arg nr="1">
<not-null/>
<not-uninit/>
<strz/>
Expand Down Expand Up @@ -5429,7 +5429,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<returnValue type="wchar_t *"/>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1" direction="in">
<arg nr="1">
<not-null/>
<not-uninit/>
<strz/>
Expand Down Expand Up @@ -8263,7 +8263,7 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init
<noreturn>false</noreturn>
<returnValue type="void"/>
<leak-ignore/>
<arg nr="1" direction="in">
<arg nr="1">
<not-null/>
<not-uninit/>
<not-bool/>
Expand All @@ -8274,7 +8274,7 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init
<noreturn>false</noreturn>
<returnValue type="char *"/>
<use-retval/>
<arg nr="1">
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>
<not-bool/>
Expand Down
14 changes: 7 additions & 7 deletions cfg/windows.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1749,7 +1749,7 @@
<function name="CloseHandle">
<noreturn>false</noreturn>
<returnValue type="BOOL"/>
<arg nr="1" direction="in">
<arg nr="1">
<not-uninit/>
</arg>
</function>
Expand Down Expand Up @@ -3901,7 +3901,7 @@ HFONT CreateFont(
<not-uninit/>
<not-null/>
</arg>
<arg nr="4" direction="in">
<arg nr="4">
<not-uninit/>
</arg>
<arg nr="5" direction="in">
Expand Down Expand Up @@ -4772,7 +4772,7 @@ HFONT CreateFont(
<function name="FreeLibrary">
<noreturn>false</noreturn>
<returnValue type="BOOL"/>
<arg nr="1" direction="in">
<arg nr="1">
<not-uninit/>
<not-bool/>
</arg>
Expand Down Expand Up @@ -4884,7 +4884,7 @@ HFONT CreateFont(
<returnValue type="FARPROC"/>
<use-retval/>
<leak-ignore/>
<arg nr="1" direction="in">
<arg nr="1">
<not-uninit/>
<not-bool/>
<not-null/>
Expand Down Expand Up @@ -4971,7 +4971,7 @@ HFONT CreateFont(
<noreturn>false</noreturn>
<returnValue type="BOOL"/>
<leak-ignore/>
<arg nr="1" direction="in">
<arg nr="1">
<not-null/>
<not-uninit/>
</arg>
Expand Down Expand Up @@ -5364,7 +5364,7 @@ HFONT CreateFont(
<returnValue type="BOOL"/>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1" direction="in">
<arg nr="1">
<not-uninit/>
<not-bool/>
</arg>
Expand Down Expand Up @@ -6324,7 +6324,7 @@ HFONT CreateFont(
<function name="LocalFree">
<noreturn>false</noreturn>
<returnValue type="HLOCAL"/>
<arg nr="1" direction="in">
<arg nr="1">
<not-bool/>
</arg>
</function>
Expand Down
4 changes: 2 additions & 2 deletions cfg/wxwidgets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6820,7 +6820,7 @@
<noreturn>false</noreturn>
<leak-ignore/>
<returnValue type="wxSizerItem*"/>
<arg nr="1" direction="in">
<arg nr="1">
<!-- <not-null/> Deactivated due to FPs with overloaded function: wxSizerItem * Add (int width, int height, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL) -->
<not-uninit/>
</arg>
Expand Down Expand Up @@ -7309,7 +7309,7 @@
<noreturn>false</noreturn>
<leak-ignore/>
<returnValue type="void"/>
<arg nr="1" direction="in">
<arg nr="1">
<not-null/>
<not-uninit/>
</arg>
Expand Down
8 changes: 7 additions & 1 deletion cli/cmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,14 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
}

else if (std::strncmp(argv[i], "--cppcheck-build-dir=", 21) == 0) {
// TODO: bail out when the folder does not exist? will silently do nothing
mSettings.buildDir = Path::fromNativeSeparators(argv[i] + 21);
if (endsWith(mSettings.buildDir, '/'))
mSettings.buildDir.pop_back();

if (!Path::directoryExists(mSettings.buildDir)) {
printError("Directory '" + mSettings.buildDir + "' specified by --cppcheck-build-dir argument has to be existent.");
return false;
}
}

// Show --debug output after the first simplifications
Expand Down Expand Up @@ -1282,6 +1286,7 @@ void CmdLineParser::printHelp()
" the configuration cppcheck should check.\n"
" For example: '--project-configuration=Release|Win32'\n"
" -q, --quiet Do not show progress reports.\n"
" Note that this option is not mutually exclusive with --verbose.\n"
" -rp=<paths>, --relative-paths=<paths>\n"
" Use relative paths in output. When given, <paths> are\n"
" used as base. You can separate multiple paths by ';'.\n"
Expand Down Expand Up @@ -1366,6 +1371,7 @@ void CmdLineParser::printHelp()
" hide certain #ifdef <ID> code paths from checking.\n"
" Example: '-UDEBUG'\n"
" -v, --verbose Output more detailed error information.\n"
" Note that this option is not mutually exclusive with --quiet.\n"
" --version Print out version number.\n"
" --xml Write results in xml format to error stream (stderr).\n"
"\n"
Expand Down
4 changes: 2 additions & 2 deletions gui/codeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ CodeEditor::CodeEditor(QWidget *parent) :
QShortcut *copyText = new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_C),this);
QShortcut *allText = new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_A),this);
#else
QShortcut *copyText = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_C),this);
QShortcut *allText = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_A),this);
const QShortcut *copyText = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_C),this);
const QShortcut *allText = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_A),this);
#endif

connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
Expand Down
2 changes: 1 addition & 1 deletion gui/resultstree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
mContextItem = mModel.itemFromIndex(index);
if (mContextItem && mApplications->getApplicationCount() > 0 && mContextItem->parent()) {
//Disconnect all signals
for (QAction* action : actions) {
for (const QAction* action : actions) {
disconnect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
}

Expand Down
19 changes: 13 additions & 6 deletions lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1650,13 +1650,20 @@ void CheckOther::checkConstPointer()
if (Token::simpleMatch(parent, "=") && parent->astOperand1() == tok)
continue;
if (const Token* ftok = getTokenArgumentFunction(tok, argn)) {
if (ftok->function() && !parent->isCast()) {
const Variable* argVar = ftok->function()->getArgumentVar(argn);
if (argVar && argVar->valueType() && argVar->valueType()->isConst(vt->pointer)) {
bool inconclusive{};
if (!isVariableChangedByFunctionCall(ftok, vt->pointer, var->declarationId(), mSettings, &inconclusive) && !inconclusive)
continue;
if (ftok->function()) {
const bool isCastArg = parent->isCast() && !ftok->function()->getOverloadedFunctions().empty(); // assume that cast changes the called function
if (!isCastArg) {
const Variable* argVar = ftok->function()->getArgumentVar(argn);
if (argVar && argVar->valueType() && argVar->valueType()->isConst(vt->pointer)) {
bool inconclusive{};
if (!isVariableChangedByFunctionCall(ftok, vt->pointer, var->declarationId(), mSettings, &inconclusive) && !inconclusive)
continue;
}
}
} else {
const auto dir = mSettings->library.getArgDirection(ftok, argn + 1);
if (dir == Library::ArgumentChecks::Direction::DIR_IN)
continue;
}
}
else if (Token::simpleMatch(parent, "(")) {
Expand Down
2 changes: 1 addition & 1 deletion lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ unsigned int CppCheck::check(const std::string &path)
Tokenizer tokenizer(&mSettings, this);
tokenizer.list.appendFileIfNew(path);
clangimport::parseClangAstDump(&tokenizer, ast);
ValueFlow::setValues(&tokenizer.list,
ValueFlow::setValues(tokenizer.list,
const_cast<SymbolDatabase*>(tokenizer.getSymbolDatabase()),
this,
&mSettings,
Expand Down
8 changes: 8 additions & 0 deletions lib/path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <algorithm>
#include <cstdlib>
#include <fstream>
#include <sys/stat.h>
#include <utility>

#include <simplecpp.h>
Expand Down Expand Up @@ -266,6 +267,13 @@ bool Path::fileExists(const std::string &file)
return f.is_open();
}


bool Path::directoryExists(const std::string &path)
{
struct stat info;
return stat(path.c_str(), &info) == 0 && (info.st_mode & S_IFDIR);
}

std::string Path::join(std::string path1, std::string path2) {
if (path1.empty() || path2.empty())
return path1 + path2;
Expand Down
7 changes: 7 additions & 0 deletions lib/path.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ class CPPCHECKLIB Path {
*/
static bool fileExists(const std::string &file);

/**
* @brief Checks if a directory exists
* @param path Path to be checked
* @return true if given path is a directory
*/
static bool directoryExists(const std::string &path);

/**
* join 2 paths with '/' separators
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4362,7 +4362,7 @@ std::vector<const Function*> Function::getOverloadedFunctions() const
it != scope->functionMap.end() && it->first == tokenDef->str();
++it) {
const Function* func = it->second;
if (isMemberFunction == func->isStatic())
if (isMemberFunction && isMemberFunction == func->isStatic())
continue;
result.push_back(func);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3361,9 +3361,9 @@ bool Tokenizer::simplifyTokens1(const std::string &configuration)
if (doValueFlow) {
if (mTimerResults) {
Timer t("Tokenizer::simplifyTokens1::ValueFlow", mSettings->showtime, mTimerResults);
ValueFlow::setValues(&list, mSymbolDatabase, mErrorLogger, mSettings, mTimerResults);
ValueFlow::setValues(list, mSymbolDatabase, mErrorLogger, mSettings, mTimerResults);
} else {
ValueFlow::setValues(&list, mSymbolDatabase, mErrorLogger, mSettings, mTimerResults);
ValueFlow::setValues(list, mSymbolDatabase, mErrorLogger, mSettings, mTimerResults);
}
}

Expand Down
Loading

0 comments on commit 50ec8f5

Please sign in to comment.