Skip to content

Commit 123782d

Browse files
Merge branch 'main' into chr_14632
2 parents 873cfdd + bb5f483 commit 123782d

21 files changed

Lines changed: 144 additions & 119 deletions

gui/cppcheck_ja.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,12 +1098,12 @@ Parameters: -l(line) (file)</translation>
10981098
<message>
10991099
<location filename="mainwindow.ui" line="1046"/>
11001100
<source>Thread Details</source>
1101-
<translation type="unfinished"></translation>
1101+
<translation>スレッド詳細</translation>
11021102
</message>
11031103
<message>
11041104
<location filename="mainwindow.ui" line="1049"/>
11051105
<source>Show thread details</source>
1106-
<translation type="unfinished"></translation>
1106+
<translation>スレッド詳細を表示</translation>
11071107
</message>
11081108
<message>
11091109
<location filename="mainwindow.cpp" line="461"/>
@@ -1186,12 +1186,6 @@ Do you want to load this project file instead?</source>
11861186
<source>Unknown element</source>
11871187
<translation>不明な要素</translation>
11881188
</message>
1189-
<message>
1190-
<location filename="mainwindow.cpp" line="1019"/>
1191-
<source>Unknown element</source>
1192-
<oldsource>Unknown issue</oldsource>
1193-
<translation type="unfinished">不明な課題</translation>
1194-
</message>
11951189
<message>
11961190
<location filename="mainwindow.cpp" line="1024"/>
11971191
<source>Failed to load the selected library &apos;%1&apos;.
@@ -1891,7 +1885,7 @@ Options:
18911885
<message>
18921886
<location filename="projectfile.ui" line="972"/>
18931887
<source>Safety profiles (defined in C++ core guidelines)</source>
1894-
<translation type="unfinished"></translation>
1888+
<translation>安全性プロファイル(C++コアガイドラインで定義)</translation>
18951889
</message>
18961890
<message>
18971891
<location filename="projectfile.ui" line="982"/>
@@ -3254,7 +3248,7 @@ To toggle what kind of errors are shown, open view menu.</source>
32543248
<message>
32553249
<location filename="threaddetails.ui" line="14"/>
32563250
<source>Thread Details</source>
3257-
<translation type="unfinished"></translation>
3251+
<translation>スレッド詳細</translation>
32583252
</message>
32593253
</context>
32603254
<context>

gui/cppchecklibrarydata.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
#ifndef CPPCHECKLIBRARYDATA_H
2020
#define CPPCHECKLIBRARYDATA_H
2121

22-
#include "config.h"
23-
2422
#include <cstdint>
2523
#include <utility>
2624

@@ -230,7 +228,7 @@ class CppcheckLibraryData {
230228
entrypoints.clear();
231229
}
232230

233-
void swap(CppcheckLibraryData &other) NOEXCEPT {
231+
void swap(CppcheckLibraryData &other) noexcept {
234232
containers.swap(other.containers);
235233
defines.swap(other.defines);
236234
undefines.swap(other.undefines);

lib/checkleakautovar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class CPPCHECKLIB VarInfo {
7575
referenced.erase(varid);
7676
}
7777

78-
void swap(VarInfo &other) NOEXCEPT {
78+
void swap(VarInfo &other) noexcept {
7979
alloctype.swap(other.alloctype);
8080
possibleUsage.swap(other.possibleUsage);
8181
conditionalAlloc.swap(other.conditionalAlloc);

lib/checknullpointer.cpp

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,13 @@ static bool checkNullpointerFunctionCallPlausibility(const Function* func, unsig
5959
return !func || (func->argCount() >= arg && func->getArgumentVar(arg - 1) && func->getArgumentVar(arg - 1)->isPointer());
6060
}
6161

62-
/**
63-
* @brief parse a function call and extract information about variable usage
64-
* @param tok first token
65-
* @param var variables that the function read / write.
66-
* @param library --library files data
67-
* @param checkNullArg perform isnullargbad check for each argument?
68-
*/
69-
void CheckNullPointer::parseFunctionCall(const Token &tok, std::list<const Token *> &var, const Library &library, bool checkNullArg)
62+
std::list<const Token*> CheckNullPointer::parseFunctionCall(const Token &tok, const Library &library, bool checkNullArg)
7063
{
7164
if (Token::Match(&tok, "%name% ( )") || !tok.tokAt(2))
72-
return;
65+
return {};
7366

7467
const std::vector<const Token *> args = getArguments(&tok);
75-
68+
std::list<const Token*> var;
7669
for (int argnr = 1; argnr <= args.size(); ++argnr) {
7770
const Token *param = args[argnr - 1];
7871
if ((!checkNullArg || library.isnullargbad(&tok, argnr)) && checkNullpointerFunctionCallPlausibility(tok.function(), argnr))
@@ -87,14 +80,14 @@ void CheckNullPointer::parseFunctionCall(const Token &tok, std::list<const Token
8780
if (library.formatstr_function(&tok)) {
8881
const int formatStringArgNr = library.formatstr_argno(&tok);
8982
if (formatStringArgNr < 0 || formatStringArgNr >= args.size())
90-
return;
83+
return var;
9184

9285
// 1st parameter..
9386
if (Token::Match(&tok, "snprintf|vsnprintf|fnprintf|vfnprintf") && args.size() > 1 && !(args[1] && args[1]->hasKnownIntValue() && args[1]->getKnownIntValue() == 0)) // Only if length (second parameter) is not zero
9487
var.push_back(args[0]);
9588

9689
if (args[formatStringArgNr]->tokType() != Token::eString)
97-
return;
90+
return var;
9891
const std::string &formatString = args[formatStringArgNr]->strValue();
9992
int argnr = formatStringArgNr + 1;
10093
const bool scan = library.formatstr_scan(&tok);
@@ -116,7 +109,7 @@ void CheckNullPointer::parseFunctionCall(const Token &tok, std::list<const Token
116109
}
117110
++i;
118111
if (i == formatString.end())
119-
return;
112+
return var;
120113
}
121114
if (_continue)
122115
continue;
@@ -129,6 +122,7 @@ void CheckNullPointer::parseFunctionCall(const Token &tok, std::list<const Token
129122
}
130123
}
131124
}
125+
return var;
132126
}
133127

134128
namespace {
@@ -166,8 +160,7 @@ bool CheckNullPointer::isPointerDeRef(const Token *tok, bool &unknown, const Set
166160
ftok = ftok->previous();
167161
}
168162
if (ftok && ftok->previous()) {
169-
std::list<const Token *> varlist;
170-
parseFunctionCall(*ftok->previous(), varlist, settings.library, checkNullArg);
163+
const std::list<const Token *> varlist = parseFunctionCall(*ftok->previous(), settings.library, checkNullArg);
171164
if (std::find(varlist.cbegin(), varlist.cend(), tok) != varlist.cend()) {
172165
return true;
173166
}
@@ -376,8 +369,7 @@ void CheckNullPointer::nullConstantDereference()
376369
if (var && !var->isPointer() && !var->isArray() && var->isStlStringType())
377370
nullPointerError(tok);
378371
} else { // function call
379-
std::list<const Token *> var;
380-
parseFunctionCall(*tok, var, mSettings->library);
372+
const std::list<const Token *> var = parseFunctionCall(*tok, mSettings->library);
381373

382374
// is one of the var items a NULL pointer?
383375
for (const Token *vartok : var) {
@@ -456,6 +448,8 @@ void CheckNullPointer::nullPointerError(const Token *tok, const std::string &var
456448
reportError(tok, Severity::warning, "nullPointerOutOfResources", "Null pointer dereference", CWE_NULL_POINTER_DEREFERENCE, Certainty::normal);
457449
return;
458450
}
451+
if (diag(tok))
452+
return;
459453

460454
if (!value) {
461455
reportError(tok, Severity::error, "nullPointer", "Null pointer dereference", CWE_NULL_POINTER_DEREFERENCE, inconclusive ? Certainty::inconclusive : Certainty::normal);

lib/checknullpointer.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "config.h"
2727

2828
#include <list>
29+
#include <set>
2930
#include <string>
3031

3132
class ErrorLogger;
@@ -69,12 +70,11 @@ class CPPCHECKLIB CheckNullPointer : public Check {
6970
/**
7071
* @brief parse a function call and extract information about variable usage
7172
* @param tok first token
72-
* @param var variables that the function read / write.
7373
* @param library --library files data
74+
* @param checkNullArg perform isnullargbad check for each argument?
75+
* @return list of variables that the function reads / writes.
7476
*/
75-
static void parseFunctionCall(const Token &tok,
76-
std::list<const Token *> &var,
77-
const Library &library, bool checkNullArg = true);
77+
static std::list<const Token*> parseFunctionCall(const Token &tok, const Library &library, bool checkNullArg = true);
7878

7979
/** @brief This constructor is used when running checks. */
8080
CheckNullPointer(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
@@ -125,6 +125,12 @@ class CPPCHECKLIB CheckNullPointer : public Check {
125125
void arithmetic();
126126
void pointerArithmeticError(const Token* tok, const ValueFlow::Value *value, bool inconclusive);
127127
void redundantConditionWarning(const Token* tok, const ValueFlow::Value *value, const Token *condition, bool inconclusive);
128+
129+
bool diag(const Token* tok) {
130+
return !mDiag.emplace(tok).second;
131+
}
132+
133+
std::set<const Token*> mDiag;
128134
};
129135
/// @}
130136
//---------------------------------------------------------------------------

lib/config.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,6 @@
5252
#define __has_feature(x) 0
5353
#endif
5454

55-
// C++11 noexcept
56-
#if defined(__cpp_noexcept_function_type) || \
57-
(defined(__GNUC__) && (__GNUC__ >= 5)) \
58-
|| defined(__clang__) \
59-
|| defined(__CPPCHECK__)
60-
# define NOEXCEPT noexcept
61-
#else
62-
# define NOEXCEPT
63-
#endif
64-
6555
// C++11 noreturn
6656
#if __has_cpp_attribute (noreturn) \
6757
|| (defined(__GNUC__) && (__GNUC__ >= 5)) \

lib/programmemory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ void ProgramMemory::erase_if(const std::function<bool(const ExprIdToken&)>& pred
205205
}
206206
}
207207

208-
void ProgramMemory::swap(ProgramMemory &pm) NOEXCEPT
208+
void ProgramMemory::swap(ProgramMemory &pm) noexcept
209209
{
210210
mValues.swap(pm.mValues);
211211
}

lib/programmemory.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ struct ExprIdToken {
7979
return !(lhs < rhs);
8080
}
8181

82-
const Token& operator*() const NOEXCEPT {
82+
const Token& operator*() const noexcept {
8383
return *tok;
8484
}
8585

86-
const Token* operator->() const NOEXCEPT {
86+
const Token* operator->() const noexcept {
8787
return tok;
8888
}
8989

@@ -128,7 +128,7 @@ struct CPPCHECKLIB ProgramMemory {
128128

129129
void erase_if(const std::function<bool(const ExprIdToken&)>& pred);
130130

131-
void swap(ProgramMemory &pm) NOEXCEPT;
131+
void swap(ProgramMemory &pm) noexcept;
132132

133133
void clear();
134134

lib/symboldatabase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6430,7 +6430,7 @@ const Function* SymbolDatabase::findFunction(const Token* const tok) const
64306430
}
64316431
}
64326432
// Check for constructor
6433-
if (Token::Match(tok, "%name% (|{")) {
6433+
if (!Token::simpleMatch(tok->tokAt(-2), "this .") && Token::Match(tok, "%name% (|{")) {
64346434
ValueType vt = ValueType::parseDecl(tok, mSettings);
64356435
if (vt.typeScope)
64366436
return vt.typeScope->findFunction(tok, false);

lib/tokenlist.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class CPPCHECKLIB TokenList {
5656
TokenList(const TokenList &) = delete;
5757
TokenList &operator=(const TokenList &) = delete;
5858

59-
TokenList(TokenList&& other) NOEXCEPT = default;
59+
TokenList(TokenList&& other) noexcept = default;
6060

6161
/** @return the source file path. e.g. "file.cpp" */
6262
const std::string& getSourceFilePath() const;

0 commit comments

Comments
 (0)