Skip to content

Commit 6839929

Browse files
authored
refs #12232/#7772 - added script to detect missing --errorlist entries and test coverage / added some missing --errorlist entries (#7439)
1 parent 0f066b5 commit 6839929

17 files changed

+84
-10
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ $(libcppdir)/clangimport.o: lib/clangimport.cpp lib/addoninfo.h lib/checkers.h l
564564
$(libcppdir)/color.o: lib/color.cpp lib/color.h lib/config.h
565565
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/color.cpp
566566

567-
$(libcppdir)/cppcheck.o: lib/cppcheck.cpp externals/picojson/picojson.h externals/simplecpp/simplecpp.h externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/checkers.h lib/checkunusedfunctions.h lib/clangimport.h lib/color.h lib/config.h lib/cppcheck.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/json.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/version.h lib/vfvalue.h lib/xml.h
567+
$(libcppdir)/cppcheck.o: lib/cppcheck.cpp externals/picojson/picojson.h externals/simplecpp/simplecpp.h externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/checkers.h lib/checkunusedfunctions.h lib/clangimport.h lib/color.h lib/config.h lib/cppcheck.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/json.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/version.h lib/vfvalue.h lib/xml.h
568568
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/cppcheck.cpp
569569

570570
$(libcppdir)/ctu.o: lib/ctu.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/astutils.h lib/check.h lib/checkers.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h

lib/checkbufferoverrun.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,4 +1235,7 @@ void CheckBufferOverrun::getErrorMessages(ErrorLogger *errorLogger, const Settin
12351235
c.argumentSizeError(nullptr, "function", 1, "buffer", nullptr, nullptr);
12361236
c.negativeMemoryAllocationSizeError(nullptr, nullptr);
12371237
c.negativeArraySizeError(nullptr);
1238+
c.terminateStrncpyError(nullptr, "var_name");
1239+
// TODO: ctuArrayIndex
1240+
// TODO: ctuPointerArith
12381241
}

lib/checkclass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3887,4 +3887,5 @@ void CheckClass::getErrorMessages(ErrorLogger *errorLogger, const Settings *sett
38873887
c.virtualFunctionCallInConstructorError(nullptr, std::list<const Token *>(), "f");
38883888
c.thisUseAfterFree(nullptr, nullptr, nullptr);
38893889
c.unsafeClassRefMemberError(nullptr, "UnsafeClass::var");
3890+
// TODO: ctuOneDefinitionRuleViolation
38903891
}

lib/checkfunctions.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,7 @@ void CheckFunctions::getErrorMessages(ErrorLogger *errorLogger, const Settings *
865865
c.invalidFunctionArgBoolError(nullptr, "func_name", 1);
866866
c.invalidFunctionArgStrError(nullptr, "func_name", 1);
867867
c.ignoredReturnValueError(nullptr, "malloc");
868+
c.ignoredReturnErrorCode(nullptr, "func_name");
868869
c.mathfunctionCallWarning(nullptr);
869870
c.mathfunctionCallWarning(nullptr, "1 - erf(x)", "erfc(x)");
870871
c.memsetZeroBytesError(nullptr);
@@ -873,4 +874,5 @@ void CheckFunctions::getErrorMessages(ErrorLogger *errorLogger, const Settings *
873874
c.missingReturnError(nullptr);
874875
c.copyElisionError(nullptr);
875876
c.useStandardLibraryError(nullptr, "memcpy");
877+
// TODO: allocaCalled, <funcname>Called
876878
}

lib/checknullpointer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,5 +720,9 @@ void CheckNullPointer::getErrorMessages(ErrorLogger *errorLogger, const Settings
720720
CheckNullPointer c(nullptr, settings, errorLogger);
721721
c.nullPointerError(nullptr, "pointer", nullptr, false);
722722
c.pointerArithmeticError(nullptr, nullptr, false);
723+
// TODO: nullPointerArithmeticOutOfMemory
723724
c.redundantConditionWarning(nullptr, nullptr, nullptr, false);
725+
// TODO: ctunullpointer
726+
// TODO: ctunullpointerOutOfMemory
727+
// TODO: ctunullpointerOutOfResources
724728
}

lib/checkother.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4583,6 +4583,8 @@ void CheckOther::getErrorMessages(ErrorLogger *errorLogger, const Settings *sett
45834583
c.intToPointerCastError(nullptr, "decimal");
45844584
c.suspiciousFloatingPointCastError(nullptr);
45854585
c.passedByValueError(nullptr, false);
4586+
// TODO: iterateByValue
4587+
// TODO: passedByValueCallback
45864588
c.constVariableError(nullptr, nullptr);
45874589
c.constStatementError(nullptr, "type", false);
45884590
c.signedCharArrayIndexError(nullptr);
@@ -4626,8 +4628,10 @@ void CheckOther::getErrorMessages(ErrorLogger *errorLogger, const Settings *sett
46264628
c.knownArgumentError(nullptr, nullptr, nullptr, "x", false);
46274629
c.knownPointerToBoolError(nullptr, nullptr);
46284630
c.comparePointersError(nullptr, nullptr, nullptr);
4631+
// TODO: subtractPointers
46294632
c.redundantAssignmentError(nullptr, nullptr, "var", false);
46304633
c.redundantInitializationError(nullptr, nullptr, "var", false);
4634+
c.redundantContinueError(nullptr);
46314635

46324636
const std::vector<const Token *> nullvec;
46334637
c.funcArgOrderDifferent("function", nullptr, nullptr, nullvec, nullvec);

lib/checkstl.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2350,7 +2350,8 @@ void CheckStl::uselessCallsSubstrError(const Token *tok, SubstrErrorType type)
23502350

23512351
void CheckStl::uselessCallsConstructorError(const Token *tok)
23522352
{
2353-
const std::string msg = "Inefficient constructor call: container '" + tok->str() + "' is assigned a partial copy of itself. Use erase() or resize() instead.";
2353+
const std::string container = tok ? tok->str() : "";
2354+
const std::string msg = "Inefficient constructor call: container '" + container + "' is assigned a partial copy of itself. Use erase() or resize() instead.";
23542355
reportError(tok, Severity::performance, "uselessCallsConstructor", msg, CWE398, Certainty::normal);
23552356
}
23562357

@@ -3456,6 +3457,7 @@ void CheckStl::getErrorMessages(ErrorLogger* errorLogger, const Settings* settin
34563457
c.iteratorsError(nullptr, nullptr, "container");
34573458
c.invalidContainerLoopError(nullptr, nullptr, ErrorPath{});
34583459
c.invalidContainerError(nullptr, nullptr, nullptr, ErrorPath{});
3460+
c.invalidContainerReferenceError(nullptr, nullptr, ErrorPath{});
34593461
c.mismatchingContainerIteratorError(nullptr, nullptr, nullptr);
34603462
c.mismatchingContainersError(nullptr, nullptr);
34613463
c.mismatchingContainerExpressionError(nullptr, nullptr);
@@ -3470,19 +3472,26 @@ void CheckStl::getErrorMessages(ErrorLogger* errorLogger, const Settings* settin
34703472
c.string_c_strError(nullptr);
34713473
c.string_c_strReturn(nullptr);
34723474
c.string_c_strParam(nullptr, 0);
3475+
c.string_c_strConstructor(nullptr);
3476+
c.string_c_strAssignment(nullptr);
3477+
c.string_c_strConcat(nullptr);
3478+
c.string_c_strStream(nullptr);
34733479
c.string_c_strThrowError(nullptr);
34743480
c.sizeError(nullptr);
34753481
c.missingComparisonError(nullptr, nullptr);
34763482
c.redundantIfRemoveError(nullptr);
34773483
c.uselessCallsReturnValueError(nullptr, "str", "find");
34783484
c.uselessCallsSwapError(nullptr, "str");
34793485
c.uselessCallsSubstrError(nullptr, SubstrErrorType::COPY);
3486+
c.uselessCallsConstructorError(nullptr);
34803487
c.uselessCallsEmptyError(nullptr);
34813488
c.uselessCallsRemoveError(nullptr, "remove");
34823489
c.dereferenceInvalidIteratorError(nullptr, "i");
3490+
// TODO: derefInvalidIteratorRedundantCheck
34833491
c.eraseIteratorOutOfBoundsError(nullptr, nullptr);
34843492
c.useStlAlgorithmError(nullptr, "");
34853493
c.knownEmptyContainerError(nullptr, "");
34863494
c.globalLockGuardError(nullptr);
34873495
c.localMutexError(nullptr);
3496+
c.outOfBoundsIndexExpressionError(nullptr, nullptr);
34883497
}

lib/checktype.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,9 @@ void CheckType::getErrorMessages(ErrorLogger *errorLogger, const Settings *setti
544544
c.tooBigBitwiseShiftError(nullptr, 32, ValueFlow::Value(64));
545545
c.tooBigSignedBitwiseShiftError(nullptr, 31, ValueFlow::Value(31));
546546
c.integerOverflowError(nullptr, ValueFlow::Value(1LL<<32));
547+
// TODO: integerOverflowCond
547548
c.signConversionError(nullptr, nullptr, false);
549+
// TODO: signConversionCond
548550
c.longCastAssignError(nullptr);
549551
c.longCastReturnError(nullptr);
550552
ValueFlow::Value f;

lib/checkuninitvar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1814,7 +1814,7 @@ void CheckUninitVar::getErrorMessages(ErrorLogger* errorLogger, const Settings*
18141814

18151815
ValueFlow::Value v{};
18161816

1817-
c.uninitvarError(nullptr, v);
1817+
c.uninitvarError(nullptr, v); // TODO: does not produce any output
18181818
c.uninitdataError(nullptr, "varname");
18191819
c.uninitStructMemberError(nullptr, "a.b");
18201820
}

lib/checkunusedfunctions.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,9 @@ static bool isOperatorFunction(const std::string & funcName)
341341
return std::find(additionalOperators.cbegin(), additionalOperators.cend(), funcName.substr(operatorPrefix.length())) != additionalOperators.cend();
342342
}
343343

344-
static void staticFunctionError(ErrorLogger& errorLogger,
345-
const std::string &filename,
346-
nonneg int fileIndex,
347-
nonneg int lineNumber,
348-
nonneg int column,
349-
const std::string &funcname)
344+
void CheckUnusedFunctions::staticFunctionError(ErrorLogger& errorLogger,
345+
const std::string &filename, nonneg int fileIndex, nonneg int lineNumber, nonneg int column,
346+
const std::string &funcname)
350347
{
351348
std::list<ErrorMessage::FileLocation> locationList;
352349
if (!filename.empty()) {

0 commit comments

Comments
 (0)