Minor refactoring: use nullptr (instead of 0/NULL), change signature of Tokenizer::createTokens
This commit is contained in:
parent
5d5886b464
commit
eba1b0881d
|
@ -68,11 +68,11 @@ private:
|
||||||
void returnPointerError(const Token *tok);
|
void returnPointerError(const Token *tok);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
Check64BitPortability c(0, settings, errorLogger);
|
Check64BitPortability c(nullptr, settings, errorLogger);
|
||||||
c.assignmentAddressToIntegerError(0);
|
c.assignmentAddressToIntegerError(nullptr);
|
||||||
c.assignmentIntegerToAddressError(0);
|
c.assignmentIntegerToAddressError(nullptr);
|
||||||
c.returnIntegerError(0);
|
c.returnIntegerError(nullptr);
|
||||||
c.returnPointerError(0);
|
c.returnPointerError(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
|
@ -57,9 +57,9 @@ private:
|
||||||
void assignmentInAssertError(const Token *tok, const std::string &varname);
|
void assignmentInAssertError(const Token *tok, const std::string &varname);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckAssert c(0, settings, errorLogger);
|
CheckAssert c(nullptr, settings, errorLogger);
|
||||||
c.sideEffectInAssertError(0, "function");
|
c.sideEffectInAssertError(nullptr, "function");
|
||||||
c.assignmentInAssertError(0, "var");
|
c.assignmentInAssertError(nullptr, "var");
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
|
@ -92,16 +92,16 @@ private:
|
||||||
void errorUselessAssignmentPtrArg(const Token *tok);
|
void errorUselessAssignmentPtrArg(const Token *tok);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckAutoVariables c(0,settings,errorLogger);
|
CheckAutoVariables c(nullptr,settings,errorLogger);
|
||||||
c.errorAutoVariableAssignment(0, false);
|
c.errorAutoVariableAssignment(nullptr, false);
|
||||||
c.errorReturnAddressToAutoVariable(0);
|
c.errorReturnAddressToAutoVariable(nullptr);
|
||||||
c.errorReturnPointerToLocalArray(0);
|
c.errorReturnPointerToLocalArray(nullptr);
|
||||||
c.errorReturnReference(0);
|
c.errorReturnReference(nullptr);
|
||||||
c.errorReturnTempReference(0);
|
c.errorReturnTempReference(nullptr);
|
||||||
c.errorInvalidDeallocation(0);
|
c.errorInvalidDeallocation(nullptr);
|
||||||
c.errorReturnAddressOfFunctionParameter(0, "parameter");
|
c.errorReturnAddressOfFunctionParameter(nullptr, "parameter");
|
||||||
c.errorUselessAssignmentArg(0);
|
c.errorUselessAssignmentArg(nullptr);
|
||||||
c.errorUselessAssignmentPtrArg(0);
|
c.errorUselessAssignmentPtrArg(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
|
@ -110,17 +110,17 @@ private:
|
||||||
void pointerArithBoolError(const Token *tok);
|
void pointerArithBoolError(const Token *tok);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckBool c(0, settings, errorLogger);
|
CheckBool c(nullptr, settings, errorLogger);
|
||||||
|
|
||||||
c.assignBoolToPointerError(0);
|
c.assignBoolToPointerError(nullptr);
|
||||||
c.assignBoolToFloatError(0);
|
c.assignBoolToFloatError(nullptr);
|
||||||
c.comparisonOfFuncReturningBoolError(0, "func_name");
|
c.comparisonOfFuncReturningBoolError(nullptr, "func_name");
|
||||||
c.comparisonOfTwoFuncsReturningBoolError(0, "func_name1", "func_name2");
|
c.comparisonOfTwoFuncsReturningBoolError(nullptr, "func_name1", "func_name2");
|
||||||
c.comparisonOfBoolWithBoolError(0, "var_name");
|
c.comparisonOfBoolWithBoolError(nullptr, "var_name");
|
||||||
c.incrementBooleanError(0);
|
c.incrementBooleanError(nullptr);
|
||||||
c.bitwiseOnBooleanError(0, "varname", "&&");
|
c.bitwiseOnBooleanError(nullptr, "varname", "&&");
|
||||||
c.comparisonOfBoolExpressionWithIntError(0, true);
|
c.comparisonOfBoolExpressionWithIntError(nullptr, true);
|
||||||
c.pointerArithBoolError(0);
|
c.pointerArithBoolError(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
|
@ -243,23 +243,23 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckBufferOverrun c(0, settings, errorLogger);
|
CheckBufferOverrun c(nullptr, settings, errorLogger);
|
||||||
const std::vector<MathLib::bigint> indexes(2, 1);
|
const std::vector<MathLib::bigint> indexes(2, 1);
|
||||||
c.arrayIndexOutOfBoundsError(0, ArrayInfo(0, "array", 1, 2), indexes);
|
c.arrayIndexOutOfBoundsError(nullptr, ArrayInfo(0, "array", 1, 2), indexes);
|
||||||
c.bufferOverrunError(0, std::string("buffer"));
|
c.bufferOverrunError(nullptr, std::string("buffer"));
|
||||||
c.strncatUsageError(0);
|
c.strncatUsageError(nullptr);
|
||||||
c.outOfBoundsError(0, "index", true, 2, 1);
|
c.outOfBoundsError(nullptr, "index", true, 2, 1);
|
||||||
c.sizeArgumentAsCharError(0);
|
c.sizeArgumentAsCharError(nullptr);
|
||||||
c.terminateStrncpyError(0, "buffer");
|
c.terminateStrncpyError(nullptr, "buffer");
|
||||||
c.bufferNotZeroTerminatedError(0, "buffer", "strncpy");
|
c.bufferNotZeroTerminatedError(nullptr, "buffer", "strncpy");
|
||||||
c.negativeIndexError(0, -1);
|
c.negativeIndexError(nullptr, -1);
|
||||||
c.cmdLineArgsError(0);
|
c.cmdLineArgsError(nullptr);
|
||||||
c.pointerOutOfBoundsError(nullptr, nullptr, 0);
|
c.pointerOutOfBoundsError(nullptr, nullptr, 0);
|
||||||
c.arrayIndexThenCheckError(0, "index");
|
c.arrayIndexThenCheckError(nullptr, "index");
|
||||||
c.possibleBufferOverrunError(0, "source", "destination", false);
|
c.possibleBufferOverrunError(nullptr, "source", "destination", false);
|
||||||
c.argumentSizeError(0, "function", "array");
|
c.argumentSizeError(nullptr, "function", "array");
|
||||||
c.negativeMemoryAllocationSizeError(0);
|
c.negativeMemoryAllocationSizeError(nullptr);
|
||||||
c.negativeArraySizeError(0);
|
c.negativeArraySizeError(nullptr);
|
||||||
c.reportError(nullptr, Severity::warning, "arrayIndexOutOfBoundsCond", "Array 'x[10]' accessed at index 20, which is out of bounds. Otherwise condition 'y==20' is redundant.", CWE119, false);
|
c.reportError(nullptr, Severity::warning, "arrayIndexOutOfBoundsCond", "Array 'x[10]' accessed at index 20, which is out of bounds. Otherwise condition 'y==20' is redundant.", CWE119, false);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -35,7 +35,7 @@ class Function;
|
||||||
class CPPCHECKLIB CheckClass : public Check {
|
class CPPCHECKLIB CheckClass : public Check {
|
||||||
public:
|
public:
|
||||||
/** @brief This constructor is used when registering the CheckClass */
|
/** @brief This constructor is used when registering the CheckClass */
|
||||||
CheckClass() : Check(myName()), symbolDatabase(NULL) {
|
CheckClass() : Check(myName()), symbolDatabase(nullptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief This constructor is used when running checks. */
|
/** @brief This constructor is used when running checks. */
|
||||||
|
@ -169,33 +169,33 @@ private:
|
||||||
void duplInheritedMembersError(const Token* tok1, const Token* tok2, const std::string &derivedname, const std::string &basename, const std::string &variablename, bool derivedIsStruct, bool baseIsStruct);
|
void duplInheritedMembersError(const Token* tok1, const Token* tok2, const std::string &derivedname, const std::string &basename, const std::string &variablename, bool derivedIsStruct, bool baseIsStruct);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckClass c(0, settings, errorLogger);
|
CheckClass c(nullptr, settings, errorLogger);
|
||||||
c.noConstructorError(0, "classname", false);
|
c.noConstructorError(nullptr, "classname", false);
|
||||||
c.noExplicitConstructorError(0, "classname", false);
|
c.noExplicitConstructorError(nullptr, "classname", false);
|
||||||
//c.copyConstructorMallocError(0, 0, "var");
|
//c.copyConstructorMallocError(nullptr, 0, "var");
|
||||||
c.copyConstructorShallowCopyError(0, "var");
|
c.copyConstructorShallowCopyError(nullptr, "var");
|
||||||
c.noCopyConstructorError(0, "class", false);
|
c.noCopyConstructorError(nullptr, "class", false);
|
||||||
c.uninitVarError(0, "classname", "varname", false);
|
c.uninitVarError(nullptr, "classname", "varname", false);
|
||||||
c.operatorEqVarError(0, "classname", "", false);
|
c.operatorEqVarError(nullptr, "classname", "", false);
|
||||||
c.unusedPrivateFunctionError(0, "classname", "funcname");
|
c.unusedPrivateFunctionError(nullptr, "classname", "funcname");
|
||||||
c.memsetError(0, "memfunc", "classname", "class");
|
c.memsetError(nullptr, "memfunc", "classname", "class");
|
||||||
c.memsetErrorReference(0, "memfunc", "class");
|
c.memsetErrorReference(nullptr, "memfunc", "class");
|
||||||
c.memsetErrorFloat(0, "class");
|
c.memsetErrorFloat(nullptr, "class");
|
||||||
c.mallocOnClassWarning(0, "malloc", 0);
|
c.mallocOnClassWarning(nullptr, "malloc", 0);
|
||||||
c.mallocOnClassError(0, "malloc", 0, "std::string");
|
c.mallocOnClassError(nullptr, "malloc", 0, "std::string");
|
||||||
c.operatorEqReturnError(0, "class");
|
c.operatorEqReturnError(nullptr, "class");
|
||||||
c.virtualDestructorError(0, "Base", "Derived", false);
|
c.virtualDestructorError(nullptr, "Base", "Derived", false);
|
||||||
c.thisSubtractionError(0);
|
c.thisSubtractionError(nullptr);
|
||||||
c.operatorEqRetRefThisError(0);
|
c.operatorEqRetRefThisError(nullptr);
|
||||||
c.operatorEqMissingReturnStatementError(0, true);
|
c.operatorEqMissingReturnStatementError(nullptr, true);
|
||||||
c.operatorEqShouldBeLeftUnimplementedError(0);
|
c.operatorEqShouldBeLeftUnimplementedError(nullptr);
|
||||||
c.operatorEqToSelfError(0);
|
c.operatorEqToSelfError(nullptr);
|
||||||
c.checkConstError(0, "class", "function", false);
|
c.checkConstError(nullptr, "class", "function", false);
|
||||||
c.checkConstError(0, "class", "function", true);
|
c.checkConstError(nullptr, "class", "function", true);
|
||||||
c.initializerListError(0, 0, "class", "variable");
|
c.initializerListError(nullptr, 0, "class", "variable");
|
||||||
c.suggestInitializationList(0, "variable");
|
c.suggestInitializationList(nullptr, "variable");
|
||||||
c.selfInitializationError(0, "var");
|
c.selfInitializationError(nullptr, "var");
|
||||||
c.duplInheritedMembersError(0, 0, "class", "class", "variable", false, false);
|
c.duplInheritedMembersError(nullptr, 0, "class", "class", "variable", false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
|
@ -129,20 +129,20 @@ private:
|
||||||
void invalidTestForOverflow(const Token* tok, bool result);
|
void invalidTestForOverflow(const Token* tok, bool result);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckCondition c(0, settings, errorLogger);
|
CheckCondition c(nullptr, settings, errorLogger);
|
||||||
|
|
||||||
c.assignIfError(0, 0, "", false);
|
c.assignIfError(nullptr, 0, "", false);
|
||||||
c.badBitmaskCheckError(0);
|
c.badBitmaskCheckError(nullptr);
|
||||||
c.comparisonError(0, "&", 6, "==", 1, false);
|
c.comparisonError(nullptr, "&", 6, "==", 1, false);
|
||||||
c.multiConditionError(0,1);
|
c.multiConditionError(nullptr,1);
|
||||||
c.mismatchingBitAndError(0, 0xf0, 0, 1);
|
c.mismatchingBitAndError(nullptr, 0xf0, 0, 1);
|
||||||
c.oppositeInnerConditionError(0, 0);
|
c.oppositeInnerConditionError(nullptr, 0);
|
||||||
c.incorrectLogicOperatorError(0, "foo > 3 && foo < 4", true);
|
c.incorrectLogicOperatorError(nullptr, "foo > 3 && foo < 4", true);
|
||||||
c.redundantConditionError(0, "If x > 11 the condition x > 10 is always true.");
|
c.redundantConditionError(nullptr, "If x > 11 the condition x > 10 is always true.");
|
||||||
c.moduloAlwaysTrueFalseError(0, "1");
|
c.moduloAlwaysTrueFalseError(nullptr, "1");
|
||||||
c.clarifyConditionError(0, true, false);
|
c.clarifyConditionError(nullptr, true, false);
|
||||||
c.alwaysTrueFalseError(0, true);
|
c.alwaysTrueFalseError(nullptr, true);
|
||||||
c.invalidTestForOverflow(0, false);
|
c.invalidTestForOverflow(nullptr, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "check.h"
|
#include "check.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
// CWE ID used:
|
// CWE ID used:
|
||||||
static const struct CWE CWE398(398U); // Indicator of Poor Code Quality
|
static const struct CWE CWE398(398U); // Indicator of Poor Code Quality
|
||||||
|
@ -119,9 +120,7 @@ private:
|
||||||
/** Missing exception specification */
|
/** Missing exception specification */
|
||||||
void unhandledExceptionSpecificationError(const Token * const tok1, const Token * const tok2, const std::string & funcname) {
|
void unhandledExceptionSpecificationError(const Token * const tok1, const Token * const tok2, const std::string & funcname) {
|
||||||
std::string str1(tok1 ? tok1->str() : "foo");
|
std::string str1(tok1 ? tok1->str() : "foo");
|
||||||
std::list<const Token*> locationList;
|
const std::list<const Token*> locationList = make_container< std::list<const Token*> > () << tok1 << tok2;
|
||||||
locationList.push_back(tok1);
|
|
||||||
locationList.push_back(tok2);
|
|
||||||
reportError(locationList, Severity::style, "unhandledExceptionSpecification",
|
reportError(locationList, Severity::style, "unhandledExceptionSpecification",
|
||||||
"Unhandled exception specification when calling function " + str1 + "().\n"
|
"Unhandled exception specification when calling function " + str1 + "().\n"
|
||||||
"Unhandled exception specification when calling function " + str1 + "(). "
|
"Unhandled exception specification when calling function " + str1 + "(). "
|
||||||
|
@ -130,13 +129,13 @@ private:
|
||||||
|
|
||||||
/** Generate all possible errors (for --errorlist) */
|
/** Generate all possible errors (for --errorlist) */
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckExceptionSafety c(0, settings, errorLogger);
|
CheckExceptionSafety c(nullptr, settings, errorLogger);
|
||||||
c.destructorsError(0, "Class");
|
c.destructorsError(nullptr, "Class");
|
||||||
c.deallocThrowError(0, "p");
|
c.deallocThrowError(nullptr, "p");
|
||||||
c.rethrowCopyError(0, "varname");
|
c.rethrowCopyError(nullptr, "varname");
|
||||||
c.catchExceptionByValueError(0);
|
c.catchExceptionByValueError(nullptr);
|
||||||
c.noexceptThrowError(0);
|
c.noexceptThrowError(nullptr);
|
||||||
c.unhandledExceptionSpecificationError(0, 0, "funcname");
|
c.unhandledExceptionSpecificationError(nullptr, 0, "funcname");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Short description of class (for --doc) */
|
/** Short description of class (for --doc) */
|
||||||
|
|
|
@ -95,17 +95,17 @@ private:
|
||||||
void mathfunctionCallWarning(const Token *tok, const std::string& oldexp, const std::string& newexp);
|
void mathfunctionCallWarning(const Token *tok, const std::string& oldexp, const std::string& newexp);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckFunctions c(0, settings, errorLogger);
|
CheckFunctions c(nullptr, settings, errorLogger);
|
||||||
|
|
||||||
for (std::map<std::string, Library::WarnInfo>::const_iterator i = settings->library.functionwarn.cbegin(); i != settings->library.functionwarn.cend(); ++i) {
|
for (std::map<std::string, Library::WarnInfo>::const_iterator i = settings->library.functionwarn.cbegin(); i != settings->library.functionwarn.cend(); ++i) {
|
||||||
c.reportError(0, Severity::style, i->first+"Called", i->second.message);
|
c.reportError(nullptr, Severity::style, i->first+"Called", i->second.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
c.invalidFunctionArgError(0, "func_name", 1, "1-4");
|
c.invalidFunctionArgError(nullptr, "func_name", 1, "1-4");
|
||||||
c.invalidFunctionArgBoolError(0, "func_name", 1);
|
c.invalidFunctionArgBoolError(nullptr, "func_name", 1);
|
||||||
c.ignoredReturnValueError(0, "malloc");
|
c.ignoredReturnValueError(nullptr, "malloc");
|
||||||
c.mathfunctionCallWarning(0);
|
c.mathfunctionCallWarning(nullptr);
|
||||||
c.mathfunctionCallWarning(0, "1 - erf(x)", "erfc(x)");
|
c.mathfunctionCallWarning(nullptr, "1 - erf(x)", "erfc(x)");
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
|
@ -85,15 +85,15 @@ private:
|
||||||
void extraWhitespaceError(const Token *tok, const std::string &pattern, const std::string &funcname);
|
void extraWhitespaceError(const Token *tok, const std::string &pattern, const std::string &funcname);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckInternal c(0, settings, errorLogger);
|
CheckInternal c(nullptr, settings, errorLogger);
|
||||||
c.multiComparePatternError(0, ";|%type%", "Match");
|
c.multiComparePatternError(nullptr, ";|%type%", "Match");
|
||||||
c.simplePatternError(0, "class {", "Match");
|
c.simplePatternError(nullptr, "class {", "Match");
|
||||||
c.complexPatternError(0, "%type% ( )", "Match");
|
c.complexPatternError(nullptr, "%type% ( )", "Match");
|
||||||
c.missingPercentCharacterError(0, "%num", "Match");
|
c.missingPercentCharacterError(nullptr, "%num", "Match");
|
||||||
c.unknownPatternError(0, "%typ");
|
c.unknownPatternError(nullptr, "%typ");
|
||||||
c.redundantNextPreviousError(0, "previous", "next");
|
c.redundantNextPreviousError(nullptr, "previous", "next");
|
||||||
c.orInComplexPattern(0, "||", "Match");
|
c.orInComplexPattern(nullptr, "||", "Match");
|
||||||
c.extraWhitespaceError(0, "%str% ", "Match");
|
c.extraWhitespaceError(nullptr, "%str% ", "Match");
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
|
@ -130,30 +130,30 @@ private:
|
||||||
static void argumentType(std::ostream & s, const ArgumentInfo * argInfo);
|
static void argumentType(std::ostream & s, const ArgumentInfo * argInfo);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckIO c(0, settings, errorLogger);
|
CheckIO c(nullptr, settings, errorLogger);
|
||||||
|
|
||||||
c.coutCerrMisusageError(0, "cout");
|
c.coutCerrMisusageError(nullptr, "cout");
|
||||||
c.fflushOnInputStreamError(0, "stdin");
|
c.fflushOnInputStreamError(nullptr, "stdin");
|
||||||
c.ioWithoutPositioningError(0);
|
c.ioWithoutPositioningError(nullptr);
|
||||||
c.readWriteOnlyFileError(0);
|
c.readWriteOnlyFileError(nullptr);
|
||||||
c.writeReadOnlyFileError(0);
|
c.writeReadOnlyFileError(nullptr);
|
||||||
c.useClosedFileError(0);
|
c.useClosedFileError(nullptr);
|
||||||
c.seekOnAppendedFileError(0);
|
c.seekOnAppendedFileError(nullptr);
|
||||||
c.invalidScanfError(0);
|
c.invalidScanfError(nullptr);
|
||||||
c.wrongPrintfScanfArgumentsError(0,"printf",3,2);
|
c.wrongPrintfScanfArgumentsError(nullptr, "printf",3,2);
|
||||||
c.invalidScanfArgTypeError_s(0, 1, "s", NULL);
|
c.invalidScanfArgTypeError_s(nullptr, 1, "s", nullptr);
|
||||||
c.invalidScanfArgTypeError_int(0, 1, "d", NULL, false);
|
c.invalidScanfArgTypeError_int(nullptr, 1, "d", nullptr, false);
|
||||||
c.invalidScanfArgTypeError_float(0, 1, "f", NULL);
|
c.invalidScanfArgTypeError_float(nullptr, 1, "f", nullptr);
|
||||||
c.invalidPrintfArgTypeError_s(0, 1, NULL);
|
c.invalidPrintfArgTypeError_s(nullptr, 1, nullptr);
|
||||||
c.invalidPrintfArgTypeError_n(0, 1, NULL);
|
c.invalidPrintfArgTypeError_n(nullptr, 1, nullptr);
|
||||||
c.invalidPrintfArgTypeError_p(0, 1, NULL);
|
c.invalidPrintfArgTypeError_p(nullptr, 1, nullptr);
|
||||||
c.invalidPrintfArgTypeError_int(0, 1, "X", NULL);
|
c.invalidPrintfArgTypeError_int(nullptr, 1, "X", nullptr);
|
||||||
c.invalidPrintfArgTypeError_uint(0, 1, "u", NULL);
|
c.invalidPrintfArgTypeError_uint(nullptr, 1, "u", nullptr);
|
||||||
c.invalidPrintfArgTypeError_sint(0, 1, "i", NULL);
|
c.invalidPrintfArgTypeError_sint(nullptr, 1, "i", nullptr);
|
||||||
c.invalidPrintfArgTypeError_float(0, 1, "f", NULL);
|
c.invalidPrintfArgTypeError_float(nullptr, 1, "f", nullptr);
|
||||||
c.invalidLengthModifierError(0, 1, "I");
|
c.invalidLengthModifierError(nullptr, 1, "I");
|
||||||
c.invalidScanfFormatWidthError(0, 10, 5, NULL);
|
c.invalidScanfFormatWidthError(nullptr, 10, 5, nullptr);
|
||||||
c.wrongPrintfScanfPosixParameterPositionError(0, "printf", 2, 1);
|
c.wrongPrintfScanfPosixParameterPositionError(nullptr, "printf", 2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
|
@ -126,10 +126,10 @@ private:
|
||||||
void configurationInfo(const Token* tok, const std::string &functionName);
|
void configurationInfo(const Token* tok, const std::string &functionName);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckLeakAutoVar c(0, settings, errorLogger);
|
CheckLeakAutoVar c(nullptr, settings, errorLogger);
|
||||||
c.deallocReturnError(0, "p");
|
c.deallocReturnError(nullptr, "p");
|
||||||
c.configurationInfo(0, "f"); // user configuration is needed to complete analysis
|
c.configurationInfo(nullptr, "f"); // user configuration is needed to complete analysis
|
||||||
c.doubleFreeError(0, "varname", 0);
|
c.doubleFreeError(nullptr, "varname", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
|
@ -108,7 +108,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief Get type of allocation at given position
|
* @brief Get type of allocation at given position
|
||||||
*/
|
*/
|
||||||
AllocType getAllocationType(const Token *tok2, unsigned int varid, std::list<const Function*> *callstack = NULL) const;
|
AllocType getAllocationType(const Token *tok2, unsigned int varid, std::list<const Function*> *callstack = nullptr) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get type of reallocation at given position
|
* @brief Get type of reallocation at given position
|
||||||
|
@ -149,7 +149,7 @@ public:
|
||||||
void memleakUponReallocFailureError(const Token *tok, const std::string &varname) const;
|
void memleakUponReallocFailureError(const Token *tok, const std::string &varname) const;
|
||||||
|
|
||||||
/** What type of allocated memory does the given function return? */
|
/** What type of allocated memory does the given function return? */
|
||||||
AllocType functionReturnType(const Function* func, std::list<const Function*> *callstack = NULL) const;
|
AllocType functionReturnType(const Function* func, std::list<const Function*> *callstack = nullptr) const;
|
||||||
|
|
||||||
/** Function allocates pointed-to argument (a la asprintf)? */
|
/** Function allocates pointed-to argument (a la asprintf)? */
|
||||||
const char *functionArgAlloc(const Function *func, unsigned int targetpar, AllocType &allocType) const;
|
const char *functionArgAlloc(const Function *func, unsigned int targetpar, AllocType &allocType) const;
|
||||||
|
@ -176,7 +176,7 @@ public:
|
||||||
class CPPCHECKLIB CheckMemoryLeakInFunction : private Check, public CheckMemoryLeak {
|
class CPPCHECKLIB CheckMemoryLeakInFunction : private Check, public CheckMemoryLeak {
|
||||||
public:
|
public:
|
||||||
/** @brief This constructor is used when registering this class */
|
/** @brief This constructor is used when registering this class */
|
||||||
CheckMemoryLeakInFunction() : Check(myName()), CheckMemoryLeak(0, 0, 0), symbolDatabase(NULL) {
|
CheckMemoryLeakInFunction() : Check(myName()), CheckMemoryLeak(0, 0, 0), symbolDatabase(nullptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief This constructor is used when running checks */
|
/** @brief This constructor is used when running checks */
|
||||||
|
@ -284,17 +284,17 @@ public:
|
||||||
private:
|
private:
|
||||||
/** Report all possible errors (for the --errorlist) */
|
/** Report all possible errors (for the --errorlist) */
|
||||||
void getErrorMessages(ErrorLogger *e, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *e, const Settings *settings) const {
|
||||||
CheckMemoryLeakInFunction c(0, settings, e);
|
CheckMemoryLeakInFunction c(nullptr, settings, e);
|
||||||
|
|
||||||
c.memleakError(0, "varname");
|
c.memleakError(nullptr, "varname");
|
||||||
c.resourceLeakError(0, "varname");
|
c.resourceLeakError(nullptr, "varname");
|
||||||
|
|
||||||
c.deallocDeallocError(0, "varname");
|
c.deallocDeallocError(nullptr, "varname");
|
||||||
c.deallocuseError(0, "varname");
|
c.deallocuseError(nullptr, "varname");
|
||||||
c.mismatchSizeError(0, "sz");
|
c.mismatchSizeError(nullptr, "sz");
|
||||||
std::list<const Token *> callstack;
|
std::list<const Token *> callstack;
|
||||||
c.mismatchAllocDealloc(callstack, "varname");
|
c.mismatchAllocDealloc(callstack, "varname");
|
||||||
c.memleakUponReallocFailureError(0, "varname");
|
c.memleakUponReallocFailureError(nullptr, "varname");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -442,11 +442,11 @@ private:
|
||||||
void unsafeArgAllocError(const Token *tok, const std::string &funcName, const std::string &ptrType, const std::string &objType);
|
void unsafeArgAllocError(const Token *tok, const std::string &funcName, const std::string &ptrType, const std::string &objType);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *e, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *e, const Settings *settings) const {
|
||||||
CheckMemoryLeakNoVar c(0, settings, e);
|
CheckMemoryLeakNoVar c(nullptr, settings, e);
|
||||||
|
|
||||||
c.functionCallLeak(0, "funcName", "funcName");
|
c.functionCallLeak(nullptr, "funcName", "funcName");
|
||||||
c.returnValueNotUsedError(0, "funcName");
|
c.returnValueNotUsedError(nullptr, "funcName");
|
||||||
c.unsafeArgAllocError(0, "funcName", "shared_ptr", "int");
|
c.unsafeArgAllocError(nullptr, "funcName", "shared_ptr", "int");
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
|
@ -92,10 +92,10 @@ private:
|
||||||
|
|
||||||
/** Get error messages. Used by --errorlist */
|
/** Get error messages. Used by --errorlist */
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckNullPointer c(0, settings, errorLogger);
|
CheckNullPointer c(nullptr, settings, errorLogger);
|
||||||
c.nullPointerError(0);
|
c.nullPointerError(nullptr);
|
||||||
c.nullPointerError(0, "pointer", false, true, true);
|
c.nullPointerError(nullptr, "pointer", false, true, true);
|
||||||
c.nullPointerError(0, "pointer", nullptr, false);
|
c.nullPointerError(nullptr, "pointer", nullptr, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Name of check */
|
/** Name of check */
|
||||||
|
|
|
@ -259,61 +259,61 @@ private:
|
||||||
void unknownEvaluationOrder(const Token* tok);
|
void unknownEvaluationOrder(const Token* tok);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckOther c(0, settings, errorLogger);
|
CheckOther c(nullptr, settings, errorLogger);
|
||||||
|
|
||||||
// error
|
// error
|
||||||
c.zerodivError(0, false);
|
c.zerodivError(nullptr, false);
|
||||||
c.zerodivcondError(0,0,false);
|
c.zerodivcondError(nullptr, 0,false);
|
||||||
c.misusedScopeObjectError(NULL, "varname");
|
c.misusedScopeObjectError(nullptr, "varname");
|
||||||
c.invalidPointerCastError(0, "float", "double", false);
|
c.invalidPointerCastError(nullptr, "float", "double", false);
|
||||||
c.negativeBitwiseShiftError(0,1);
|
c.negativeBitwiseShiftError(nullptr, 1);
|
||||||
c.checkPipeParameterSizeError(0, "varname", "dimension");
|
c.checkPipeParameterSizeError(nullptr, "varname", "dimension");
|
||||||
c.raceAfterInterlockedDecrementError(0);
|
c.raceAfterInterlockedDecrementError(nullptr);
|
||||||
|
|
||||||
//performance
|
//performance
|
||||||
c.redundantCopyError(0, "varname");
|
c.redundantCopyError(nullptr, "varname");
|
||||||
c.redundantCopyError(0, 0, "var");
|
c.redundantCopyError(nullptr, 0, "var");
|
||||||
c.redundantAssignmentError(0, 0, "var", false);
|
c.redundantAssignmentError(nullptr, 0, "var", false);
|
||||||
|
|
||||||
// style/warning
|
// style/warning
|
||||||
c.checkComparisonFunctionIsAlwaysTrueOrFalseError(0,"isless","varName",false);
|
c.checkComparisonFunctionIsAlwaysTrueOrFalseError(nullptr, "isless","varName",false);
|
||||||
c.checkCastIntToCharAndBackError(0,"func_name");
|
c.checkCastIntToCharAndBackError(nullptr, "func_name");
|
||||||
c.cstyleCastError(0);
|
c.cstyleCastError(nullptr);
|
||||||
c.passedByValueError(0, "parametername");
|
c.passedByValueError(nullptr, "parametername");
|
||||||
c.constStatementError(0, "type");
|
c.constStatementError(nullptr, "type");
|
||||||
c.signedCharArrayIndexError(0);
|
c.signedCharArrayIndexError(nullptr);
|
||||||
c.unknownSignCharArrayIndexError(0);
|
c.unknownSignCharArrayIndexError(nullptr);
|
||||||
c.charBitOpError(0);
|
c.charBitOpError(nullptr);
|
||||||
c.variableScopeError(0, "varname");
|
c.variableScopeError(nullptr, "varname");
|
||||||
c.redundantAssignmentInSwitchError(0, 0, "var");
|
c.redundantAssignmentInSwitchError(nullptr, 0, "var");
|
||||||
c.redundantCopyInSwitchError(0, 0, "var");
|
c.redundantCopyInSwitchError(nullptr, 0, "var");
|
||||||
c.switchCaseFallThrough(0);
|
c.switchCaseFallThrough(nullptr);
|
||||||
c.suspiciousCaseInSwitchError(0, "||");
|
c.suspiciousCaseInSwitchError(nullptr, "||");
|
||||||
c.suspiciousEqualityComparisonError(0);
|
c.suspiciousEqualityComparisonError(nullptr);
|
||||||
c.selfAssignmentError(0, "varname");
|
c.selfAssignmentError(nullptr, "varname");
|
||||||
c.memsetZeroBytesError(0);
|
c.memsetZeroBytesError(nullptr);
|
||||||
c.memsetFloatError(0, "varname");
|
c.memsetFloatError(nullptr, "varname");
|
||||||
c.memsetValueOutOfRangeError(0, "varname");
|
c.memsetValueOutOfRangeError(nullptr, "varname");
|
||||||
c.clarifyCalculationError(0, "+");
|
c.clarifyCalculationError(nullptr, "+");
|
||||||
c.clarifyStatementError(0);
|
c.clarifyStatementError(nullptr);
|
||||||
c.duplicateBranchError(0, 0);
|
c.duplicateBranchError(nullptr, 0);
|
||||||
c.duplicateExpressionError(0, 0, "&&");
|
c.duplicateExpressionError(nullptr, 0, "&&");
|
||||||
c.duplicateExpressionTernaryError(0);
|
c.duplicateExpressionTernaryError(nullptr);
|
||||||
c.duplicateBreakError(0, false);
|
c.duplicateBreakError(nullptr, false);
|
||||||
c.unreachableCodeError(0, false);
|
c.unreachableCodeError(nullptr, false);
|
||||||
c.unsignedLessThanZeroError(0, "varname", false);
|
c.unsignedLessThanZeroError(nullptr, "varname", false);
|
||||||
c.unsignedPositiveError(0, "varname", false);
|
c.unsignedPositiveError(nullptr, "varname", false);
|
||||||
c.pointerLessThanZeroError(0, false);
|
c.pointerLessThanZeroError(nullptr, false);
|
||||||
c.pointerPositiveError(0, false);
|
c.pointerPositiveError(nullptr, false);
|
||||||
c.SuspiciousSemicolonError(0);
|
c.SuspiciousSemicolonError(nullptr);
|
||||||
c.incompleteArrayFillError(0, "buffer", "memset", false);
|
c.incompleteArrayFillError(nullptr, "buffer", "memset", false);
|
||||||
c.varFuncNullUBError(0);
|
c.varFuncNullUBError(nullptr);
|
||||||
c.nanInArithmeticExpressionError(0);
|
c.nanInArithmeticExpressionError(nullptr);
|
||||||
c.commaSeparatedReturnError(0);
|
c.commaSeparatedReturnError(nullptr);
|
||||||
c.redundantPointerOpError(0, "varname", false);
|
c.redundantPointerOpError(nullptr, "varname", false);
|
||||||
c.unusedLabelError(0, true);
|
c.unusedLabelError(nullptr, true);
|
||||||
c.unusedLabelError(0, false);
|
c.unusedLabelError(nullptr, false);
|
||||||
c.unknownEvaluationOrder(0);
|
c.unknownEvaluationOrder(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
|
@ -59,8 +59,8 @@ private:
|
||||||
void postfixOperatorError(const Token *tok);
|
void postfixOperatorError(const Token *tok);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckPostfixOperator c(0, settings, errorLogger);
|
CheckPostfixOperator c(nullptr, settings, errorLogger);
|
||||||
c.postfixOperatorError(0);
|
c.postfixOperatorError(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
|
@ -99,19 +99,19 @@ private:
|
||||||
void arithOperationsOnVoidPointerError(const Token* tok, const std::string &varname, const std::string &vartype);
|
void arithOperationsOnVoidPointerError(const Token* tok, const std::string &varname, const std::string &vartype);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger* errorLogger, const Settings* settings) const {
|
void getErrorMessages(ErrorLogger* errorLogger, const Settings* settings) const {
|
||||||
CheckSizeof c(0, settings, errorLogger);
|
CheckSizeof c(nullptr, settings, errorLogger);
|
||||||
|
|
||||||
c.sizeofForArrayParameterError(0);
|
c.sizeofForArrayParameterError(nullptr);
|
||||||
c.sizeofForPointerError(0, "varname");
|
c.sizeofForPointerError(nullptr, "varname");
|
||||||
c.divideBySizeofError(0, "memset");
|
c.divideBySizeofError(nullptr, "memset");
|
||||||
c.sizeofForNumericParameterError(0);
|
c.sizeofForNumericParameterError(nullptr);
|
||||||
c.sizeofsizeofError(0);
|
c.sizeofsizeofError(nullptr);
|
||||||
c.sizeofCalculationError(0, false);
|
c.sizeofCalculationError(nullptr, false);
|
||||||
c.multiplySizeofError(0);
|
c.multiplySizeofError(nullptr);
|
||||||
c.divideSizeofError(0);
|
c.divideSizeofError(nullptr);
|
||||||
c.sizeofVoidError(0);
|
c.sizeofVoidError(nullptr);
|
||||||
c.sizeofDereferencedVoidPointerError(0, "varname");
|
c.sizeofDereferencedVoidPointerError(nullptr, "varname");
|
||||||
c.arithOperationsOnVoidPointerError(0, "varname", "vartype");
|
c.arithOperationsOnVoidPointerError(nullptr, "varname", "vartype");
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
|
@ -186,34 +186,34 @@ private:
|
||||||
void readingEmptyStlContainerError(const Token *tok);
|
void readingEmptyStlContainerError(const Token *tok);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckStl c(0, settings, errorLogger);
|
CheckStl c(nullptr, settings, errorLogger);
|
||||||
c.invalidIteratorError(0, "iterator");
|
c.invalidIteratorError(nullptr, "iterator");
|
||||||
c.iteratorsError(0, "container1", "container2");
|
c.iteratorsError(nullptr, "container1", "container2");
|
||||||
c.mismatchingContainersError(0);
|
c.mismatchingContainersError(nullptr);
|
||||||
c.dereferenceErasedError(0, 0, "iter");
|
c.dereferenceErasedError(nullptr, nullptr, "iter");
|
||||||
c.stlOutOfBoundsError(0, "i", "foo", false);
|
c.stlOutOfBoundsError(nullptr, "i", "foo", false);
|
||||||
c.invalidIteratorError(0, "push_back|push_front|insert", "iterator");
|
c.invalidIteratorError(nullptr, "push_back|push_front|insert", "iterator");
|
||||||
c.invalidPointerError(0, "push_back", "pointer");
|
c.invalidPointerError(nullptr, "push_back", "pointer");
|
||||||
c.stlBoundariesError(0);
|
c.stlBoundariesError(nullptr);
|
||||||
c.if_findError(0, false);
|
c.if_findError(nullptr, false);
|
||||||
c.if_findError(0, true);
|
c.if_findError(nullptr, true);
|
||||||
c.string_c_strError(0);
|
c.string_c_strError(nullptr);
|
||||||
c.string_c_strReturn(0);
|
c.string_c_strReturn(nullptr);
|
||||||
c.string_c_strParam(0, 0);
|
c.string_c_strParam(nullptr, 0);
|
||||||
c.sizeError(0);
|
c.sizeError(nullptr);
|
||||||
c.missingComparisonError(0, 0);
|
c.missingComparisonError(nullptr, 0);
|
||||||
c.redundantIfRemoveError(0);
|
c.redundantIfRemoveError(nullptr);
|
||||||
c.autoPointerError(0);
|
c.autoPointerError(nullptr);
|
||||||
c.autoPointerContainerError(0);
|
c.autoPointerContainerError(nullptr);
|
||||||
c.autoPointerArrayError(0);
|
c.autoPointerArrayError(nullptr);
|
||||||
c.autoPointerMallocError(0, "malloc");
|
c.autoPointerMallocError(nullptr, "malloc");
|
||||||
c.uselessCallsReturnValueError(0, "str", "find");
|
c.uselessCallsReturnValueError(nullptr, "str", "find");
|
||||||
c.uselessCallsSwapError(0, "str");
|
c.uselessCallsSwapError(nullptr, "str");
|
||||||
c.uselessCallsSubstrError(0, false);
|
c.uselessCallsSubstrError(nullptr, false);
|
||||||
c.uselessCallsEmptyError(0);
|
c.uselessCallsEmptyError(nullptr);
|
||||||
c.uselessCallsRemoveError(0, "remove");
|
c.uselessCallsRemoveError(nullptr, "remove");
|
||||||
c.dereferenceInvalidIteratorError(0, "i");
|
c.dereferenceInvalidIteratorError(nullptr, "i");
|
||||||
c.readingEmptyStlContainerError(0);
|
c.readingEmptyStlContainerError(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
|
@ -92,17 +92,17 @@ private:
|
||||||
void suspiciousStringCompareError_char(const Token* tok, const std::string& var);
|
void suspiciousStringCompareError_char(const Token* tok, const std::string& var);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckString c(0, settings, errorLogger);
|
CheckString c(nullptr, settings, errorLogger);
|
||||||
|
|
||||||
c.stringLiteralWriteError(0,0);
|
c.stringLiteralWriteError(nullptr,0);
|
||||||
c.sprintfOverlappingDataError(0, "varname");
|
c.sprintfOverlappingDataError(nullptr, "varname");
|
||||||
c.strPlusCharError(0);
|
c.strPlusCharError(nullptr);
|
||||||
c.incorrectStringCompareError(0, "substr", "\"Hello World\"");
|
c.incorrectStringCompareError(nullptr, "substr", "\"Hello World\"");
|
||||||
c.suspiciousStringCompareError(0, "foo");
|
c.suspiciousStringCompareError(nullptr, "foo");
|
||||||
c.suspiciousStringCompareError_char(0, "foo");
|
c.suspiciousStringCompareError_char(nullptr, "foo");
|
||||||
c.incorrectStringBooleanError(0, "\"Hello World\"");
|
c.incorrectStringBooleanError(nullptr, "\"Hello World\"");
|
||||||
c.alwaysTrueFalseStringCompareError(0, "str1", "str2");
|
c.alwaysTrueFalseStringCompareError(nullptr, "str1", "str2");
|
||||||
c.alwaysTrueStringVariableCompareError(0, "varname1", "varname2");
|
c.alwaysTrueStringVariableCompareError(nullptr, "varname1", "varname2");
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
|
@ -80,12 +80,12 @@ private:
|
||||||
void longCastReturnError(const Token *tok);
|
void longCastReturnError(const Token *tok);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckType c(0, settings, errorLogger);
|
CheckType c(nullptr, settings, errorLogger);
|
||||||
c.tooBigBitwiseShiftError(0, 32, ValueFlow::Value(64));
|
c.tooBigBitwiseShiftError(nullptr, 32, ValueFlow::Value(64));
|
||||||
c.integerOverflowError(0, ValueFlow::Value(1LL<<32));
|
c.integerOverflowError(nullptr, ValueFlow::Value(1LL<<32));
|
||||||
c.signConversionError(0, false);
|
c.signConversionError(nullptr, false);
|
||||||
c.longCastAssignError(0);
|
c.longCastAssignError(nullptr);
|
||||||
c.longCastReturnError(0);
|
c.longCastReturnError(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
|
@ -93,14 +93,14 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckUninitVar c(0, settings, errorLogger);
|
CheckUninitVar c(nullptr, settings, errorLogger);
|
||||||
|
|
||||||
// error
|
// error
|
||||||
c.uninitstringError(0, "varname", true);
|
c.uninitstringError(nullptr, "varname", true);
|
||||||
c.uninitdataError(0, "varname");
|
c.uninitdataError(nullptr, "varname");
|
||||||
c.uninitvarError(0, "varname");
|
c.uninitvarError(nullptr, "varname");
|
||||||
c.uninitStructMemberError(0, "a.b");
|
c.uninitStructMemberError(nullptr, "a.b");
|
||||||
c.deadPointerError(0,0);
|
c.deadPointerError(nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
|
@ -58,7 +58,7 @@ public:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckUnusedFunctions c(0, settings, errorLogger);
|
CheckUnusedFunctions c(nullptr, settings, errorLogger);
|
||||||
c.unusedFunctionError(errorLogger, "", 0, "funcName");
|
c.unusedFunctionError(errorLogger, "", 0, "funcName");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,14 +82,14 @@ private:
|
||||||
void unassignedVariableError(const Token *tok, const std::string &varname);
|
void unassignedVariableError(const Token *tok, const std::string &varname);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckUnusedVar c(0, settings, errorLogger);
|
CheckUnusedVar c(nullptr, settings, errorLogger);
|
||||||
|
|
||||||
// style/warning
|
// style/warning
|
||||||
c.unusedVariableError(0, "varname");
|
c.unusedVariableError(nullptr, "varname");
|
||||||
c.allocatedButUnusedVariableError(0, "varname");
|
c.allocatedButUnusedVariableError(nullptr, "varname");
|
||||||
c.unreadVariableError(0, "varname");
|
c.unreadVariableError(nullptr, "varname");
|
||||||
c.unassignedVariableError(0, "varname");
|
c.unassignedVariableError(nullptr, "varname");
|
||||||
c.unusedStructMemberError(0, "structname", "variable");
|
c.unusedStructMemberError(nullptr, "structname", "variable");
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
|
@ -58,12 +58,12 @@ private:
|
||||||
void va_start_subsequentCallsError(const Token *tok, const std::string& varname);
|
void va_start_subsequentCallsError(const Token *tok, const std::string& varname);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckVaarg c(0, settings, errorLogger);
|
CheckVaarg c(nullptr, settings, errorLogger);
|
||||||
c.wrongParameterTo_va_start_error(0, "arg1", "arg2");
|
c.wrongParameterTo_va_start_error(nullptr, "arg1", "arg2");
|
||||||
c.referenceAs_va_start_error(0, "arg1");
|
c.referenceAs_va_start_error(nullptr, "arg1");
|
||||||
c.va_end_missingError(0, "vl");
|
c.va_end_missingError(nullptr, "vl");
|
||||||
c.va_list_usedBeforeStartedError(0, "vl");
|
c.va_list_usedBeforeStartedError(nullptr, "vl");
|
||||||
c.va_start_subsequentCallsError(0, "vl");
|
c.va_start_subsequentCallsError(nullptr, "vl");
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
|
@ -130,7 +130,7 @@ public:
|
||||||
case debug:
|
case debug:
|
||||||
return "debug";
|
return "debug";
|
||||||
};
|
};
|
||||||
throw InternalError(NULL, "Unknown severity");
|
throw InternalError(nullptr, "Unknown severity");
|
||||||
}
|
}
|
||||||
static SeverityType fromString(const std::string &severity) {
|
static SeverityType fromString(const std::string &severity) {
|
||||||
if (severity.empty())
|
if (severity.empty())
|
||||||
|
|
|
@ -748,7 +748,7 @@ public:
|
||||||
if (it->intvalue == val && !it->tokvalue)
|
if (it->intvalue == val && !it->tokvalue)
|
||||||
return &(*it);
|
return &(*it);
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ValueFlow::Value * getMaxValue(bool condition) const {
|
const ValueFlow::Value * getMaxValue(bool condition) const {
|
||||||
|
@ -758,7 +758,7 @@ public:
|
||||||
if (it->tokvalue)
|
if (it->tokvalue)
|
||||||
continue;
|
continue;
|
||||||
if ((!ret || it->intvalue > ret->intvalue) &&
|
if ((!ret || it->intvalue > ret->intvalue) &&
|
||||||
((it->condition != NULL) == condition))
|
((it->condition != nullptr) == condition))
|
||||||
ret = &(*it);
|
ret = &(*it);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -911,7 +911,7 @@ public:
|
||||||
bool isCalculation() const;
|
bool isCalculation() const;
|
||||||
|
|
||||||
void clearAst() {
|
void clearAst() {
|
||||||
_astOperand1 = _astOperand2 = _astParent = NULL;
|
_astOperand1 = _astOperand2 = _astParent = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string astString(const char *sep = "") const {
|
std::string astString(const char *sep = "") const {
|
||||||
|
|
|
@ -1433,8 +1433,7 @@ void Tokenizer::simplifyTypedef()
|
||||||
// This is the case of casting operator.
|
// This is the case of casting operator.
|
||||||
// Name is not available, and () should not be
|
// Name is not available, and () should not be
|
||||||
// inserted
|
// inserted
|
||||||
bool castOperator = inOperator && Token::Match(tok2, "%type% (");
|
const bool castOperator = inOperator && Token::Match(tok2, "%type% (");
|
||||||
|
|
||||||
Token *tok3;
|
Token *tok3;
|
||||||
|
|
||||||
if (!castOperator) {
|
if (!castOperator) {
|
||||||
|
@ -1679,7 +1678,7 @@ void Tokenizer::simplifyMulAndParens()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Tokenizer::createTokens(std::istream &code,
|
bool Tokenizer::createTokens(std::istream &code,
|
||||||
const char FileName[])
|
const std::string& FileName)
|
||||||
{
|
{
|
||||||
// make sure settings specified
|
// make sure settings specified
|
||||||
assert(_settings);
|
assert(_settings);
|
||||||
|
|
|
@ -72,7 +72,7 @@ public:
|
||||||
bool IsScopeNoReturn(const Token *endScopeToken, bool *unknown = nullptr) const;
|
bool IsScopeNoReturn(const Token *endScopeToken, bool *unknown = nullptr) const;
|
||||||
|
|
||||||
bool createTokens(std::istream &code,
|
bool createTokens(std::istream &code,
|
||||||
const char FileName[]);
|
const std::string& FileName);
|
||||||
|
|
||||||
bool simplifyTokens1(const std::string &configuration,
|
bool simplifyTokens1(const std::string &configuration,
|
||||||
bool noSymbolDB_AST = false);
|
bool noSymbolDB_AST = false);
|
||||||
|
|
Loading…
Reference in New Issue