fixed "Redundant elaborated type specifier" Rider warnings (#5517)
This commit is contained in:
parent
3ba53c6b6a
commit
a22c181553
|
@ -188,7 +188,7 @@ static std::string addFiles2(std::map<std::string, std::size_t> &files,
|
||||||
std::string new_path = path;
|
std::string new_path = path;
|
||||||
new_path += '/';
|
new_path += '/';
|
||||||
|
|
||||||
while (const struct dirent* dir_result = readdir(dir)) {
|
while (const dirent* dir_result = readdir(dir)) {
|
||||||
if ((std::strcmp(dir_result->d_name, ".") == 0) ||
|
if ((std::strcmp(dir_result->d_name, ".") == 0) ||
|
||||||
(std::strcmp(dir_result->d_name, "..") == 0))
|
(std::strcmp(dir_result->d_name, "..") == 0))
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -307,7 +307,7 @@ unsigned int ProcessExecutor::check()
|
||||||
FD_ZERO(&rfds);
|
FD_ZERO(&rfds);
|
||||||
for (std::list<int>::const_iterator rp = rpipes.cbegin(); rp != rpipes.cend(); ++rp)
|
for (std::list<int>::const_iterator rp = rpipes.cbegin(); rp != rpipes.cend(); ++rp)
|
||||||
FD_SET(*rp, &rfds);
|
FD_SET(*rp, &rfds);
|
||||||
struct timeval tv; // for every second polling of load average condition
|
timeval tv; // for every second polling of load average condition
|
||||||
tv.tv_sec = 1;
|
tv.tv_sec = 1;
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
const int r = select(*std::max_element(rpipes.cbegin(), rpipes.cend()) + 1, &rfds, nullptr, nullptr, &tv);
|
const int r = select(*std::max_element(rpipes.cbegin(), rpipes.cend()) + 1, &rfds, nullptr, nullptr, &tv);
|
||||||
|
|
|
@ -82,7 +82,7 @@ static CppcheckLibraryData::Container loadContainer(QXmlStreamReader &xmlReader)
|
||||||
break;
|
break;
|
||||||
if (type != QXmlStreamReader::StartElement)
|
if (type != QXmlStreamReader::StartElement)
|
||||||
continue;
|
continue;
|
||||||
struct CppcheckLibraryData::Container::Function function;
|
CppcheckLibraryData::Container::Function function;
|
||||||
function.name = xmlReader.attributes().value("name").toString();
|
function.name = xmlReader.attributes().value("name").toString();
|
||||||
function.action = xmlReader.attributes().value("action").toString();
|
function.action = xmlReader.attributes().value("action").toString();
|
||||||
function.yields = xmlReader.attributes().value("yields").toString();
|
function.yields = xmlReader.attributes().value("yields").toString();
|
||||||
|
@ -91,7 +91,7 @@ static CppcheckLibraryData::Container loadContainer(QXmlStreamReader &xmlReader)
|
||||||
else if (elementName == "access")
|
else if (elementName == "access")
|
||||||
container.accessFunctions.append(function);
|
container.accessFunctions.append(function);
|
||||||
else if (elementName == "rangeItemRecordType") {
|
else if (elementName == "rangeItemRecordType") {
|
||||||
struct CppcheckLibraryData::Container::RangeItemRecordType rangeItemRecordType;
|
CppcheckLibraryData::Container::RangeItemRecordType rangeItemRecordType;
|
||||||
rangeItemRecordType.name = xmlReader.attributes().value("name").toString();
|
rangeItemRecordType.name = xmlReader.attributes().value("name").toString();
|
||||||
rangeItemRecordType.templateParameter = xmlReader.attributes().value("templateParameter").toString();
|
rangeItemRecordType.templateParameter = xmlReader.attributes().value("templateParameter").toString();
|
||||||
container.rangeItemRecordTypeList.append(rangeItemRecordType);
|
container.rangeItemRecordTypeList.append(rangeItemRecordType);
|
||||||
|
@ -518,7 +518,7 @@ QString CppcheckLibraryData::open(QIODevice &file)
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void writeContainerFunctions(QXmlStreamWriter &xmlWriter, const QString &name, int extra, const QList<struct CppcheckLibraryData::Container::Function> &functions)
|
static void writeContainerFunctions(QXmlStreamWriter &xmlWriter, const QString &name, int extra, const QList<CppcheckLibraryData::Container::Function> &functions)
|
||||||
{
|
{
|
||||||
if (functions.isEmpty() && extra < 0)
|
if (functions.isEmpty() && extra < 0)
|
||||||
return;
|
return;
|
||||||
|
@ -541,7 +541,7 @@ static void writeContainerFunctions(QXmlStreamWriter &xmlWriter, const QString &
|
||||||
xmlWriter.writeEndElement();
|
xmlWriter.writeEndElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void writeContainerRangeItemRecords(QXmlStreamWriter &xmlWriter, const QList<struct CppcheckLibraryData::Container::RangeItemRecordType> &rangeItemRecords)
|
static void writeContainerRangeItemRecords(QXmlStreamWriter &xmlWriter, const QList<CppcheckLibraryData::Container::RangeItemRecordType> &rangeItemRecords)
|
||||||
{
|
{
|
||||||
if (rangeItemRecords.isEmpty())
|
if (rangeItemRecords.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -58,10 +58,10 @@ public:
|
||||||
QString yields;
|
QString yields;
|
||||||
QString action;
|
QString action;
|
||||||
};
|
};
|
||||||
QList<struct Function> accessFunctions;
|
QList<Function> accessFunctions;
|
||||||
QList<struct Function> otherFunctions;
|
QList<Function> otherFunctions;
|
||||||
QList<struct Function> sizeFunctions;
|
QList<Function> sizeFunctions;
|
||||||
QList<struct RangeItemRecordType> rangeItemRecordTypeList;
|
QList<RangeItemRecordType> rangeItemRecordTypeList;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Define {
|
struct Define {
|
||||||
|
@ -106,13 +106,13 @@ public:
|
||||||
QString arg;
|
QString arg;
|
||||||
QString arg2;
|
QString arg2;
|
||||||
};
|
};
|
||||||
QList<struct MinSize> minsizes;
|
QList<MinSize> minsizes;
|
||||||
struct Iterator {
|
struct Iterator {
|
||||||
int container = -1;
|
int container = -1;
|
||||||
QString type;
|
QString type;
|
||||||
} iterator;
|
} iterator;
|
||||||
};
|
};
|
||||||
QList<struct Arg> args;
|
QList<Arg> args;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
QString severity;
|
QString severity;
|
||||||
|
@ -149,8 +149,8 @@ public:
|
||||||
QString name;
|
QString name;
|
||||||
};
|
};
|
||||||
|
|
||||||
QList<struct Alloc> alloc;
|
QList<Alloc> alloc;
|
||||||
QList<struct Dealloc> dealloc;
|
QList<Dealloc> dealloc;
|
||||||
QStringList use;
|
QStringList use;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ public:
|
||||||
QString name;
|
QString name;
|
||||||
};
|
};
|
||||||
|
|
||||||
QList<struct Call> calls;
|
QList<Call> calls;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Markup {
|
struct Markup {
|
||||||
|
@ -244,18 +244,18 @@ public:
|
||||||
QString open(QIODevice &file);
|
QString open(QIODevice &file);
|
||||||
QString toString() const;
|
QString toString() const;
|
||||||
|
|
||||||
QList<struct Container> containers;
|
QList<Container> containers;
|
||||||
QList<struct Define> defines;
|
QList<Define> defines;
|
||||||
QList<struct Function> functions;
|
QList<Function> functions;
|
||||||
QList<struct MemoryResource> memoryresource;
|
QList<MemoryResource> memoryresource;
|
||||||
QList<struct PodType> podtypes;
|
QList<PodType> podtypes;
|
||||||
QList<TypeChecks> typeChecks;
|
QList<TypeChecks> typeChecks;
|
||||||
QList<struct PlatformType> platformTypes;
|
QList<PlatformType> platformTypes;
|
||||||
QStringList undefines;
|
QStringList undefines;
|
||||||
QList<struct SmartPointer> smartPointers;
|
QList<SmartPointer> smartPointers;
|
||||||
QList<struct Reflection> reflections;
|
QList<Reflection> reflections;
|
||||||
QList<struct Markup> markups;
|
QList<Markup> markups;
|
||||||
QList<struct Entrypoint> entrypoints;
|
QList<Entrypoint> entrypoints;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CPPCHECKLIBRARYDATA_H
|
#endif // CPPCHECKLIBRARYDATA_H
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
// CWE ids used
|
// CWE ids used
|
||||||
static const struct CWE CWE398(398U); // Indicator of Poor Code Quality
|
static const CWE CWE398(398U); // Indicator of Poor Code Quality
|
||||||
static const struct CWE CWE758(758U); // Reliance on Undefined, Unspecified, or Implementation-Defined Behavior
|
static const CWE CWE758(758U); // Reliance on Undefined, Unspecified, or Implementation-Defined Behavior
|
||||||
|
|
||||||
// Register this check class (by creating a static instance of it)
|
// Register this check class (by creating a static instance of it)
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
// CWE ids used
|
// CWE ids used
|
||||||
static const struct CWE CWE398(398U); // Indicator of Poor Code Quality
|
static const CWE CWE398(398U); // Indicator of Poor Code Quality
|
||||||
|
|
||||||
// Register this check class (by creating a static instance of it)
|
// Register this check class (by creating a static instance of it)
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -2154,7 +2154,7 @@ void CheckClass::checkConst()
|
||||||
if (!scope->definedType->derivedFrom.empty() && func.isImplicitlyVirtual(true))
|
if (!scope->definedType->derivedFrom.empty() && func.isImplicitlyVirtual(true))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
enum MemberAccess memberAccessed = MemberAccess::NONE;
|
MemberAccess memberAccessed = MemberAccess::NONE;
|
||||||
// if nothing non-const was found. write error..
|
// if nothing non-const was found. write error..
|
||||||
if (!checkConstFunc(scope, &func, memberAccessed))
|
if (!checkConstFunc(scope, &func, memberAccessed))
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -43,10 +43,10 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// CWE ids used
|
// CWE ids used
|
||||||
static const struct CWE uncheckedErrorConditionCWE(391U);
|
static const CWE uncheckedErrorConditionCWE(391U);
|
||||||
static const struct CWE CWE398(398U); // Indicator of Poor Code Quality
|
static const CWE CWE398(398U); // Indicator of Poor Code Quality
|
||||||
static const struct CWE CWE570(570U); // Expression is Always False
|
static const CWE CWE570(570U); // Expression is Always False
|
||||||
static const struct CWE CWE571(571U); // Expression is Always True
|
static const CWE CWE571(571U); // Expression is Always True
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,9 @@ namespace {
|
||||||
CheckExceptionSafety instance;
|
CheckExceptionSafety instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct CWE CWE398(398U); // Indicator of Poor Code Quality
|
static const CWE CWE398(398U); // Indicator of Poor Code Quality
|
||||||
static const struct CWE CWE703(703U); // Improper Check or Handling of Exceptional Conditions
|
static const CWE CWE703(703U); // Improper Check or Handling of Exceptional Conditions
|
||||||
static const struct CWE CWE480(480U); // Use of Incorrect Operator
|
static const CWE CWE480(480U); // Use of Incorrect Operator
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,8 @@
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
// CWE ids used:
|
// CWE ids used:
|
||||||
static const struct CWE CWE_NULL_POINTER_DEREFERENCE(476U);
|
static const CWE CWE_NULL_POINTER_DEREFERENCE(476U);
|
||||||
static const struct CWE CWE_INCORRECT_CALCULATION(682U);
|
static const CWE CWE_INCORRECT_CALCULATION(682U);
|
||||||
|
|
||||||
// Register this check class (by creating a static instance of it)
|
// Register this check class (by creating a static instance of it)
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -50,24 +50,24 @@ namespace {
|
||||||
CheckOther instance;
|
CheckOther instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct CWE CWE128(128U); // Wrap-around Error
|
static const CWE CWE128(128U); // Wrap-around Error
|
||||||
static const struct CWE CWE131(131U); // Incorrect Calculation of Buffer Size
|
static const CWE CWE131(131U); // Incorrect Calculation of Buffer Size
|
||||||
static const struct CWE CWE197(197U); // Numeric Truncation Error
|
static const CWE CWE197(197U); // Numeric Truncation Error
|
||||||
static const struct CWE CWE362(362U); // Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
|
static const CWE CWE362(362U); // Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
|
||||||
static const struct CWE CWE369(369U); // Divide By Zero
|
static const CWE CWE369(369U); // Divide By Zero
|
||||||
static const struct CWE CWE398(398U); // Indicator of Poor Code Quality
|
static const CWE CWE398(398U); // Indicator of Poor Code Quality
|
||||||
static const struct CWE CWE475(475U); // Undefined Behavior for Input to API
|
static const CWE CWE475(475U); // Undefined Behavior for Input to API
|
||||||
static const struct CWE CWE561(561U); // Dead Code
|
static const CWE CWE561(561U); // Dead Code
|
||||||
static const struct CWE CWE563(563U); // Assignment to Variable without Use ('Unused Variable')
|
static const CWE CWE563(563U); // Assignment to Variable without Use ('Unused Variable')
|
||||||
static const struct CWE CWE570(570U); // Expression is Always False
|
static const CWE CWE570(570U); // Expression is Always False
|
||||||
static const struct CWE CWE571(571U); // Expression is Always True
|
static const CWE CWE571(571U); // Expression is Always True
|
||||||
static const struct CWE CWE672(672U); // Operation on a Resource after Expiration or Release
|
static const CWE CWE672(672U); // Operation on a Resource after Expiration or Release
|
||||||
static const struct CWE CWE628(628U); // Function Call with Incorrectly Specified Arguments
|
static const CWE CWE628(628U); // Function Call with Incorrectly Specified Arguments
|
||||||
static const struct CWE CWE683(683U); // Function Call With Incorrect Order of Arguments
|
static const CWE CWE683(683U); // Function Call With Incorrect Order of Arguments
|
||||||
static const struct CWE CWE704(704U); // Incorrect Type Conversion or Cast
|
static const CWE CWE704(704U); // Incorrect Type Conversion or Cast
|
||||||
static const struct CWE CWE758(758U); // Reliance on Undefined, Unspecified, or Implementation-Defined Behavior
|
static const CWE CWE758(758U); // Reliance on Undefined, Unspecified, or Implementation-Defined Behavior
|
||||||
static const struct CWE CWE768(768U); // Incorrect Short Circuit Evaluation
|
static const CWE CWE768(768U); // Incorrect Short Circuit Evaluation
|
||||||
static const struct CWE CWE783(783U); // Operator Precedence Logic Error
|
static const CWE CWE783(783U); // Operator Precedence Logic Error
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// The return value of fgetc(), getc(), ungetc(), getchar() etc. is an integer value.
|
// The return value of fgetc(), getc(), ungetc(), getchar() etc. is an integer value.
|
||||||
|
@ -2793,7 +2793,7 @@ void CheckOther::checkComparisonFunctionIsAlwaysTrueOrFalse()
|
||||||
void CheckOther::checkComparisonFunctionIsAlwaysTrueOrFalseError(const Token* tok, const std::string &functionName, const std::string &varName, const bool result)
|
void CheckOther::checkComparisonFunctionIsAlwaysTrueOrFalseError(const Token* tok, const std::string &functionName, const std::string &varName, const bool result)
|
||||||
{
|
{
|
||||||
const std::string strResult = bool_to_string(result);
|
const std::string strResult = bool_to_string(result);
|
||||||
const struct CWE cweResult = result ? CWE571 : CWE570;
|
const CWE cweResult = result ? CWE571 : CWE570;
|
||||||
|
|
||||||
reportError(tok, Severity::warning, "comparisonFunctionIsAlwaysTrueOrFalse",
|
reportError(tok, Severity::warning, "comparisonFunctionIsAlwaysTrueOrFalse",
|
||||||
"$symbol:" + functionName + "\n"
|
"$symbol:" + functionName + "\n"
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace {
|
||||||
|
|
||||||
|
|
||||||
// CWE ids used
|
// CWE ids used
|
||||||
static const struct CWE CWE398(398U); // Indicator of Poor Code Quality
|
static const CWE CWE398(398U); // Indicator of Poor Code Quality
|
||||||
|
|
||||||
|
|
||||||
void CheckPostfixOperator::postfixOperator()
|
void CheckPostfixOperator::postfixOperator()
|
||||||
|
|
|
@ -40,9 +40,9 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CWE IDs used:
|
// CWE IDs used:
|
||||||
static const struct CWE CWE398(398U); // Indicator of Poor Code Quality
|
static const CWE CWE398(398U); // Indicator of Poor Code Quality
|
||||||
static const struct CWE CWE467(467U); // Use of sizeof() on a Pointer Type
|
static const CWE CWE467(467U); // Use of sizeof() on a Pointer Type
|
||||||
static const struct CWE CWE682(682U); // Incorrect Calculation
|
static const CWE CWE682(682U); // Incorrect Calculation
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
void CheckSizeof::checkSizeofForNumericParameter()
|
void CheckSizeof::checkSizeofForNumericParameter()
|
||||||
|
|
|
@ -52,18 +52,18 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CWE IDs used:
|
// CWE IDs used:
|
||||||
static const struct CWE CWE398(398U); // Indicator of Poor Code Quality
|
static const CWE CWE398(398U); // Indicator of Poor Code Quality
|
||||||
static const struct CWE CWE597(597U); // Use of Wrong Operator in String Comparison
|
static const CWE CWE597(597U); // Use of Wrong Operator in String Comparison
|
||||||
static const struct CWE CWE628(628U); // Function Call with Incorrectly Specified Arguments
|
static const CWE CWE628(628U); // Function Call with Incorrectly Specified Arguments
|
||||||
static const struct CWE CWE664(664U); // Improper Control of a Resource Through its Lifetime
|
static const CWE CWE664(664U); // Improper Control of a Resource Through its Lifetime
|
||||||
static const struct CWE CWE667(667U); // Improper Locking
|
static const CWE CWE667(667U); // Improper Locking
|
||||||
static const struct CWE CWE704(704U); // Incorrect Type Conversion or Cast
|
static const CWE CWE704(704U); // Incorrect Type Conversion or Cast
|
||||||
static const struct CWE CWE762(762U); // Mismatched Memory Management Routines
|
static const CWE CWE762(762U); // Mismatched Memory Management Routines
|
||||||
static const struct CWE CWE786(786U); // Access of Memory Location Before Start of Buffer
|
static const CWE CWE786(786U); // Access of Memory Location Before Start of Buffer
|
||||||
static const struct CWE CWE788(788U); // Access of Memory Location After End of Buffer
|
static const CWE CWE788(788U); // Access of Memory Location After End of Buffer
|
||||||
static const struct CWE CWE825(825U); // Expired Pointer Dereference
|
static const CWE CWE825(825U); // Expired Pointer Dereference
|
||||||
static const struct CWE CWE833(833U); // Deadlock
|
static const CWE CWE833(833U); // Deadlock
|
||||||
static const struct CWE CWE834(834U); // Excessive Iteration
|
static const CWE CWE834(834U); // Excessive Iteration
|
||||||
|
|
||||||
static bool isElementAccessYield(Library::Container::Yield yield)
|
static bool isElementAccessYield(Library::Container::Yield yield)
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,12 +42,12 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CWE ids used:
|
// CWE ids used:
|
||||||
static const struct CWE CWE570(570U); // Expression is Always False
|
static const CWE CWE570(570U); // Expression is Always False
|
||||||
static const struct CWE CWE571(571U); // Expression is Always True
|
static const CWE CWE571(571U); // Expression is Always True
|
||||||
static const struct CWE CWE595(595U); // Comparison of Object References Instead of Object Contents
|
static const CWE CWE595(595U); // Comparison of Object References Instead of Object Contents
|
||||||
static const struct CWE CWE628(628U); // Function Call with Incorrectly Specified Arguments
|
static const CWE CWE628(628U); // Function Call with Incorrectly Specified Arguments
|
||||||
static const struct CWE CWE665(665U); // Improper Initialization
|
static const CWE CWE665(665U); // Improper Initialization
|
||||||
static const struct CWE CWE758(758U); // Reliance on Undefined, Unspecified, or Implementation-Defined Behavior
|
static const CWE CWE758(758U); // Reliance on Undefined, Unspecified, or Implementation-Defined Behavior
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// Writing string literal is UB
|
// Writing string literal is UB
|
||||||
|
|
|
@ -48,10 +48,10 @@ namespace {
|
||||||
//
|
//
|
||||||
|
|
||||||
// CWE ids used:
|
// CWE ids used:
|
||||||
static const struct CWE CWE195(195U); // Signed to Unsigned Conversion Error
|
static const CWE CWE195(195U); // Signed to Unsigned Conversion Error
|
||||||
static const struct CWE CWE197(197U); // Numeric Truncation Error
|
static const CWE CWE197(197U); // Numeric Truncation Error
|
||||||
static const struct CWE CWE758(758U); // Reliance on Undefined, Unspecified, or Implementation-Defined Behavior
|
static const CWE CWE758(758U); // Reliance on Undefined, Unspecified, or Implementation-Defined Behavior
|
||||||
static const struct CWE CWE190(190U); // Integer Overflow or Wraparound
|
static const CWE CWE190(190U); // Integer Overflow or Wraparound
|
||||||
|
|
||||||
|
|
||||||
void CheckType::checkTooBigBitwiseShift()
|
void CheckType::checkTooBigBitwiseShift()
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace tinyxml2 {
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
// CWE ids used:
|
// CWE ids used:
|
||||||
static const struct CWE CWE_USE_OF_UNINITIALIZED_VARIABLE(457U);
|
static const CWE CWE_USE_OF_UNINITIALIZED_VARIABLE(457U);
|
||||||
|
|
||||||
// Register this check class (by creating a static instance of it)
|
// Register this check class (by creating a static instance of it)
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace {
|
||||||
CheckUnusedFunctions instance;
|
CheckUnusedFunctions instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct CWE CWE561(561U); // Dead Code
|
static const CWE CWE561(561U); // Dead Code
|
||||||
|
|
||||||
static std::string stripTemplateParameters(const std::string& funcName) {
|
static std::string stripTemplateParameters(const std::string& funcName) {
|
||||||
std::string name = funcName;
|
std::string name = funcName;
|
||||||
|
|
|
@ -45,8 +45,8 @@ namespace {
|
||||||
CheckUnusedVar instance;
|
CheckUnusedVar instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct CWE CWE563(563U); // Assignment to Variable without Use ('Unused Variable')
|
static const CWE CWE563(563U); // Assignment to Variable without Use ('Unused Variable')
|
||||||
static const struct CWE CWE665(665U); // Improper Initialization
|
static const CWE CWE665(665U); // Improper Initialization
|
||||||
|
|
||||||
/** Is scope a raii class scope */
|
/** Is scope a raii class scope */
|
||||||
static bool isRaiiClassScope(const Scope *classScope)
|
static bool isRaiiClassScope(const Scope *classScope)
|
||||||
|
|
|
@ -41,9 +41,9 @@ namespace {
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
// CWE ids used:
|
// CWE ids used:
|
||||||
static const struct CWE CWE664(664U); // Improper Control of a Resource Through its Lifetime
|
static const CWE CWE664(664U); // Improper Control of a Resource Through its Lifetime
|
||||||
static const struct CWE CWE688(688U); // Function Call With Incorrect Variable or Reference as Argument
|
static const CWE CWE688(688U); // Function Call With Incorrect Variable or Reference as Argument
|
||||||
static const struct CWE CWE758(758U); // Reliance on Undefined, Unspecified, or Implementation-Defined Behavior
|
static const CWE CWE758(758U); // Reliance on Undefined, Unspecified, or Implementation-Defined Behavior
|
||||||
|
|
||||||
void CheckVaarg::va_start_argument()
|
void CheckVaarg::va_start_argument()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1503,7 +1503,7 @@ void CppCheck::executeAddons(const std::vector<std::string>& files)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const std::string &addon : mSettings.addons) {
|
for (const std::string &addon : mSettings.addons) {
|
||||||
struct AddonInfo addonInfo;
|
AddonInfo addonInfo;
|
||||||
const std::string &failedToGetAddonInfo = addonInfo.getAddonInfo(addon, mSettings.exename);
|
const std::string &failedToGetAddonInfo = addonInfo.getAddonInfo(addon, mSettings.exename);
|
||||||
if (!failedToGetAddonInfo.empty()) {
|
if (!failedToGetAddonInfo.empty()) {
|
||||||
reportOut(failedToGetAddonInfo, Color::FgRed);
|
reportOut(failedToGetAddonInfo, Color::FgRed);
|
||||||
|
|
|
@ -93,7 +93,7 @@ static bool hasVolatileCastOrVar(const Token *expr)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FwdAnalysis::Result FwdAnalysis::checkRecursive(const Token *expr, const Token *startToken, const Token *endToken, const std::set<nonneg int> &exprVarIds, bool local, bool inInnerClass, int depth)
|
FwdAnalysis::Result FwdAnalysis::checkRecursive(const Token *expr, const Token *startToken, const Token *endToken, const std::set<nonneg int> &exprVarIds, bool local, bool inInnerClass, int depth)
|
||||||
{
|
{
|
||||||
// Parse the given tokens
|
// Parse the given tokens
|
||||||
if (++depth > 1000)
|
if (++depth > 1000)
|
||||||
|
@ -182,7 +182,7 @@ struct FwdAnalysis::Result FwdAnalysis::checkRecursive(const Token *expr, const
|
||||||
}
|
}
|
||||||
|
|
||||||
// check loop body again..
|
// check loop body again..
|
||||||
const struct FwdAnalysis::Result &result = checkRecursive(expr, tok->link(), tok, exprVarIds, local, inInnerClass, depth);
|
const FwdAnalysis::Result &result = checkRecursive(expr, tok->link(), tok, exprVarIds, local, inInnerClass, depth);
|
||||||
if (result.type == Result::Type::BAILOUT || result.type == Result::Type::READ)
|
if (result.type == Result::Type::BAILOUT || result.type == Result::Type::READ)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,8 +79,8 @@ private:
|
||||||
const Token* token{};
|
const Token* token{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Result check(const Token *expr, const Token *startToken, const Token *endToken);
|
Result check(const Token *expr, const Token *startToken, const Token *endToken);
|
||||||
struct Result checkRecursive(const Token *expr, const Token *startToken, const Token *endToken, const std::set<nonneg int> &exprVarIds, bool local, bool inInnerClass, int depth=0);
|
Result checkRecursive(const Token *expr, const Token *startToken, const Token *endToken, const std::set<nonneg int> &exprVarIds, bool local, bool inInnerClass, int depth=0);
|
||||||
|
|
||||||
// Is expression a l-value global data?
|
// Is expression a l-value global data?
|
||||||
bool isGlobalData(const Token *expr) const;
|
bool isGlobalData(const Token *expr) const;
|
||||||
|
|
|
@ -397,7 +397,7 @@ bool ImportProject::importCompileCommands(std::istream &istr)
|
||||||
if (!Path::acceptFile(file))
|
if (!Path::acceptFile(file))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
struct FileSettings fs;
|
FileSettings fs;
|
||||||
if (Path::isAbsolute(file))
|
if (Path::isAbsolute(file))
|
||||||
fs.filename = Path::simplifyPath(file);
|
fs.filename = Path::simplifyPath(file);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
|
@ -511,7 +511,7 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
|
||||||
for (const tinyxml2::XMLElement* memberNode = node->FirstChildElement(); memberNode; memberNode = memberNode->NextSiblingElement()) {
|
for (const tinyxml2::XMLElement* memberNode = node->FirstChildElement(); memberNode; memberNode = memberNode->NextSiblingElement()) {
|
||||||
const char *memberName = memberNode->Attribute("name");
|
const char *memberName = memberNode->Attribute("name");
|
||||||
const char *memberTemplateParameter = memberNode->Attribute("templateParameter");
|
const char *memberTemplateParameter = memberNode->Attribute("templateParameter");
|
||||||
struct Container::RangeItemRecordTypeItem member;
|
Container::RangeItemRecordTypeItem member;
|
||||||
member.name = memberName ? memberName : "";
|
member.name = memberName ? memberName : "";
|
||||||
member.templateParameter = memberTemplateParameter ? strToInt<int>(memberTemplateParameter) : -1;
|
member.templateParameter = memberTemplateParameter ? strToInt<int>(memberTemplateParameter) : -1;
|
||||||
container.rangeItemRecordType.emplace_back(std::move(member));
|
container.rangeItemRecordType.emplace_back(std::move(member));
|
||||||
|
|
|
@ -439,8 +439,8 @@ public:
|
||||||
char sign;
|
char sign;
|
||||||
enum class Type { NO, BOOL, CHAR, SHORT, INT, LONG, LONGLONG } stdtype;
|
enum class Type { NO, BOOL, CHAR, SHORT, INT, LONG, LONGLONG } stdtype;
|
||||||
};
|
};
|
||||||
const struct PodType *podtype(const std::string &name) const {
|
const PodType *podtype(const std::string &name) const {
|
||||||
const std::unordered_map<std::string, struct PodType>::const_iterator it = mPodTypes.find(name);
|
const std::unordered_map<std::string, PodType>::const_iterator it = mPodTypes.find(name);
|
||||||
return (it != mPodTypes.end()) ? &(it->second) : nullptr;
|
return (it != mPodTypes.end()) ? &(it->second) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,7 +468,7 @@ public:
|
||||||
|
|
||||||
struct Platform {
|
struct Platform {
|
||||||
const PlatformType *platform_type(const std::string &name) const {
|
const PlatformType *platform_type(const std::string &name) const {
|
||||||
const std::map<std::string, struct PlatformType>::const_iterator it = mPlatformTypes.find(name);
|
const std::map<std::string, PlatformType>::const_iterator it = mPlatformTypes.find(name);
|
||||||
return (it != mPlatformTypes.end()) ? &(it->second) : nullptr;
|
return (it != mPlatformTypes.end()) ? &(it->second) : nullptr;
|
||||||
}
|
}
|
||||||
std::map<std::string, PlatformType> mPlatformTypes;
|
std::map<std::string, PlatformType> mPlatformTypes;
|
||||||
|
@ -579,7 +579,7 @@ private:
|
||||||
std::map<std::string, ExportedFunctions> mExporters; // keywords that export variables/functions to libraries (meta-code/macros)
|
std::map<std::string, ExportedFunctions> mExporters; // keywords that export variables/functions to libraries (meta-code/macros)
|
||||||
std::map<std::string, std::set<std::string>> mImporters; // keywords that import variables/functions
|
std::map<std::string, std::set<std::string>> mImporters; // keywords that import variables/functions
|
||||||
std::map<std::string, int> mReflection; // invocation of reflection
|
std::map<std::string, int> mReflection; // invocation of reflection
|
||||||
std::unordered_map<std::string, struct PodType> mPodTypes; // pod types
|
std::unordered_map<std::string, PodType> mPodTypes; // pod types
|
||||||
std::map<std::string, PlatformType> mPlatformTypes; // platform independent typedefs
|
std::map<std::string, PlatformType> mPlatformTypes; // platform independent typedefs
|
||||||
std::map<std::string, Platform> mPlatforms; // platform dependent typedefs
|
std::map<std::string, Platform> mPlatforms; // platform dependent typedefs
|
||||||
std::map<std::pair<std::string,std::string>, TypeCheck> mTypeChecks;
|
std::map<std::pair<std::string,std::string>, TypeCheck> mTypeChecks;
|
||||||
|
|
|
@ -1251,18 +1251,18 @@ public:
|
||||||
ErrorPath debugPath; ///< debug path to the type
|
ErrorPath debugPath; ///< debug path to the type
|
||||||
|
|
||||||
ValueType() = default;
|
ValueType() = default;
|
||||||
ValueType(enum Sign s, enum Type t, nonneg int p)
|
ValueType(Sign s, Type t, nonneg int p)
|
||||||
: sign(s),
|
: sign(s),
|
||||||
type(t),
|
type(t),
|
||||||
pointer(p)
|
pointer(p)
|
||||||
{}
|
{}
|
||||||
ValueType(enum Sign s, enum Type t, nonneg int p, nonneg int c)
|
ValueType(Sign s, Type t, nonneg int p, nonneg int c)
|
||||||
: sign(s),
|
: sign(s),
|
||||||
type(t),
|
type(t),
|
||||||
pointer(p),
|
pointer(p),
|
||||||
constness(c)
|
constness(c)
|
||||||
{}
|
{}
|
||||||
ValueType(enum Sign s, enum Type t, nonneg int p, nonneg int c, std::string otn)
|
ValueType(Sign s, Type t, nonneg int p, nonneg int c, std::string otn)
|
||||||
: sign(s),
|
: sign(s),
|
||||||
type(t),
|
type(t),
|
||||||
pointer(p),
|
pointer(p),
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
using dataElementType = std::pair<std::string, struct TimerResultsData>;
|
using dataElementType = std::pair<std::string, TimerResultsData>;
|
||||||
bool more_second_sec(const dataElementType& lhs, const dataElementType& rhs)
|
bool more_second_sec(const dataElementType& lhs, const dataElementType& rhs)
|
||||||
{
|
{
|
||||||
return lhs.second.seconds() > rhs.second.seconds();
|
return lhs.second.seconds() > rhs.second.seconds();
|
||||||
|
|
|
@ -63,7 +63,7 @@ public:
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<std::string, struct TimerResultsData> mResults;
|
std::map<std::string, TimerResultsData> mResults;
|
||||||
mutable std::mutex mResultsSync;
|
mutable std::mutex mResultsSync;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2558,7 +2558,7 @@ TokenImpl::~TokenImpl()
|
||||||
delete mTemplateSimplifierPointers;
|
delete mTemplateSimplifierPointers;
|
||||||
|
|
||||||
while (mCppcheckAttributes) {
|
while (mCppcheckAttributes) {
|
||||||
struct CppcheckAttributes *c = mCppcheckAttributes;
|
CppcheckAttributes *c = mCppcheckAttributes;
|
||||||
mCppcheckAttributes = mCppcheckAttributes->next;
|
mCppcheckAttributes = mCppcheckAttributes->next;
|
||||||
delete c;
|
delete c;
|
||||||
}
|
}
|
||||||
|
@ -2566,7 +2566,7 @@ TokenImpl::~TokenImpl()
|
||||||
|
|
||||||
void TokenImpl::setCppcheckAttribute(TokenImpl::CppcheckAttributes::Type type, MathLib::bigint value)
|
void TokenImpl::setCppcheckAttribute(TokenImpl::CppcheckAttributes::Type type, MathLib::bigint value)
|
||||||
{
|
{
|
||||||
struct CppcheckAttributes *attr = mCppcheckAttributes;
|
CppcheckAttributes *attr = mCppcheckAttributes;
|
||||||
while (attr && attr->type != type)
|
while (attr && attr->type != type)
|
||||||
attr = attr->next;
|
attr = attr->next;
|
||||||
if (attr)
|
if (attr)
|
||||||
|
@ -2582,7 +2582,7 @@ void TokenImpl::setCppcheckAttribute(TokenImpl::CppcheckAttributes::Type type, M
|
||||||
|
|
||||||
bool TokenImpl::getCppcheckAttribute(TokenImpl::CppcheckAttributes::Type type, MathLib::bigint &value) const
|
bool TokenImpl::getCppcheckAttribute(TokenImpl::CppcheckAttributes::Type type, MathLib::bigint &value) const
|
||||||
{
|
{
|
||||||
struct CppcheckAttributes *attr = mCppcheckAttributes;
|
CppcheckAttributes *attr = mCppcheckAttributes;
|
||||||
while (attr && attr->type != type)
|
while (attr && attr->type != type)
|
||||||
attr = attr->next;
|
attr = attr->next;
|
||||||
if (attr)
|
if (attr)
|
||||||
|
|
|
@ -10298,7 +10298,7 @@ void Tokenizer::setPodTypes()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// pod type
|
// pod type
|
||||||
const struct Library::PodType *podType = mSettings->library.podtype(tok->str());
|
const Library::PodType *podType = mSettings->library.podtype(tok->str());
|
||||||
if (podType) {
|
if (podType) {
|
||||||
const Token *prev = tok->previous();
|
const Token *prev = tok->previous();
|
||||||
while (prev && prev->isName())
|
while (prev && prev->isName())
|
||||||
|
|
|
@ -748,7 +748,7 @@ private:
|
||||||
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
||||||
// s8
|
// s8
|
||||||
{
|
{
|
||||||
const struct Library::PodType * const type = library.podtype("s8");
|
const Library::PodType * const type = library.podtype("s8");
|
||||||
ASSERT_EQUALS(true, type != nullptr);
|
ASSERT_EQUALS(true, type != nullptr);
|
||||||
if (type) {
|
if (type) {
|
||||||
ASSERT_EQUALS(1U, type->size);
|
ASSERT_EQUALS(1U, type->size);
|
||||||
|
@ -757,7 +757,7 @@ private:
|
||||||
}
|
}
|
||||||
// u8
|
// u8
|
||||||
{
|
{
|
||||||
const struct Library::PodType * const type = library.podtype("u8");
|
const Library::PodType * const type = library.podtype("u8");
|
||||||
ASSERT_EQUALS(true, type != nullptr);
|
ASSERT_EQUALS(true, type != nullptr);
|
||||||
if (type) {
|
if (type) {
|
||||||
ASSERT_EQUALS(1U, type->size);
|
ASSERT_EQUALS(1U, type->size);
|
||||||
|
@ -766,7 +766,7 @@ private:
|
||||||
}
|
}
|
||||||
// u16
|
// u16
|
||||||
{
|
{
|
||||||
const struct Library::PodType * const type = library.podtype("u16");
|
const Library::PodType * const type = library.podtype("u16");
|
||||||
ASSERT_EQUALS(true, type != nullptr);
|
ASSERT_EQUALS(true, type != nullptr);
|
||||||
if (type) {
|
if (type) {
|
||||||
ASSERT_EQUALS(2U, type->size);
|
ASSERT_EQUALS(2U, type->size);
|
||||||
|
@ -775,7 +775,7 @@ private:
|
||||||
}
|
}
|
||||||
// s16
|
// s16
|
||||||
{
|
{
|
||||||
const struct Library::PodType * const type = library.podtype("s16");
|
const Library::PodType * const type = library.podtype("s16");
|
||||||
ASSERT_EQUALS(true, type != nullptr);
|
ASSERT_EQUALS(true, type != nullptr);
|
||||||
if (type) {
|
if (type) {
|
||||||
ASSERT_EQUALS(2U, type->size);
|
ASSERT_EQUALS(2U, type->size);
|
||||||
|
@ -784,7 +784,7 @@ private:
|
||||||
}
|
}
|
||||||
// robustness test: provide cfg without PodType
|
// robustness test: provide cfg without PodType
|
||||||
{
|
{
|
||||||
const struct Library::PodType * const type = library.podtype("nonExistingPodType");
|
const Library::PodType * const type = library.podtype("nonExistingPodType");
|
||||||
ASSERT_EQUALS(true, type == nullptr);
|
ASSERT_EQUALS(true, type == nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue