diff --git a/lib/checkers.cpp b/lib/checkers.cpp index e8c57d4c467..a5a47b867c2 100644 --- a/lib/checkers.cpp +++ b/lib/checkers.cpp @@ -25,189 +25,189 @@ namespace checkers { const std::map allCheckers{ {"Check64BitPortability::pointerassignment","portability"}, {"CheckAssert::assertWithSideEffects","warning"}, - {"CheckBool::checkIncrementBoolean","style"}, + {"CheckAutoVariables::assignFunctionArg","style,warning"}, + {"CheckAutoVariables::autoVariables",""}, + {"CheckAutoVariables::checkVarLifetime",""}, + {"CheckBool::checkAssignBoolToFloat","style,c++"}, + {"CheckBool::checkAssignBoolToPointer",""}, {"CheckBool::checkBitwiseOnBoolean","style,inconclusive"}, + {"CheckBool::checkComparisonOfBoolExpressionWithInt","warning"}, + {"CheckBool::checkComparisonOfBoolWithBool","style,c++"}, {"CheckBool::checkComparisonOfBoolWithInt","warning,c++"}, {"CheckBool::checkComparisonOfFuncReturningBool","style,c++"}, - {"CheckBool::checkComparisonOfBoolWithBool","style,c++"}, - {"CheckBool::checkAssignBoolToPointer",""}, - {"CheckBool::checkComparisonOfBoolExpressionWithInt","warning"}, + {"CheckBool::checkIncrementBoolean","style"}, {"CheckBool::pointerArithBool",""}, - {"CheckBool::checkAssignBoolToFloat","style,c++"}, {"CheckBool::returnValueOfFunctionReturningBool","style"}, - {"CheckExceptionSafety::destructors","warning"}, - {"CheckExceptionSafety::deallocThrow","warning"}, - {"CheckExceptionSafety::checkRethrowCopy","style"}, + {"CheckBufferOverrun::analyseWholeProgram",""}, + {"CheckBufferOverrun::argumentSize","warning"}, + {"CheckBufferOverrun::arrayIndex",""}, + {"CheckBufferOverrun::arrayIndexThenCheck",""}, + {"CheckBufferOverrun::bufferOverflow",""}, + {"CheckBufferOverrun::negativeArraySize",""}, + {"CheckBufferOverrun::objectIndex",""}, + {"CheckBufferOverrun::pointerArithmetic","portability"}, + {"CheckBufferOverrun::stringNotZeroTerminated","warning,inconclusive"}, + {"CheckClass::analyseWholeProgram",""}, + {"CheckClass::checkConst","style,inconclusive"}, + {"CheckClass::checkConstructors","style,warning"}, + {"CheckClass::checkCopyConstructors","warning"}, + {"CheckClass::checkDuplInheritedMembers","warning"}, + {"CheckClass::checkExplicitConstructors","style"}, + {"CheckClass::checkMemset",""}, + {"CheckClass::checkMissingOverride","style,c++03"}, + {"CheckClass::checkReturnByReference","performance"}, + {"CheckClass::checkSelfInitialization",""}, + {"CheckClass::checkThisUseAfterFree","warning"}, + {"CheckClass::checkUnsafeClassRefMember","warning,safeChecks"}, + {"CheckClass::checkUselessOverride","style"}, + {"CheckClass::checkVirtualFunctionCallInConstructor","warning"}, + {"CheckClass::initializationListUsage","performance"}, + {"CheckClass::initializerListOrder","style,inconclusive"}, + {"CheckClass::operatorEqRetRefThis","style"}, + {"CheckClass::operatorEqToSelf","warning"}, + {"CheckClass::privateFunctions","style"}, + {"CheckClass::thisSubtraction","warning"}, + {"CheckClass::virtualDestructor",""}, + {"CheckCondition::alwaysTrueFalse","style"}, + {"CheckCondition::assignIf","style"}, + {"CheckCondition::checkAssignmentInCondition","style"}, + {"CheckCondition::checkBadBitmaskCheck","style"}, + {"CheckCondition::checkCompareValueOutOfTypeRange","style,platform"}, + {"CheckCondition::checkDuplicateConditionalAssign","style"}, + {"CheckCondition::checkIncorrectLogicOperator","style,warning"}, + {"CheckCondition::checkInvalidTestForOverflow","warning"}, + {"CheckCondition::checkModuloAlwaysTrueFalse","warning"}, + {"CheckCondition::checkPointerAdditionResultNotNull","warning"}, + {"CheckCondition::clarifyCondition","style"}, + {"CheckCondition::comparison","style"}, + {"CheckCondition::duplicateCondition","style"}, + {"CheckCondition::multiCondition","style"}, + {"CheckCondition::multiCondition2","warning"}, {"CheckExceptionSafety::checkCatchExceptionByValue","style"}, + {"CheckExceptionSafety::checkRethrowCopy","style"}, + {"CheckExceptionSafety::deallocThrow","warning"}, + {"CheckExceptionSafety::destructors","warning"}, {"CheckExceptionSafety::nothrowThrows",""}, - {"CheckExceptionSafety::unhandledExceptionSpecification","style,inconclusive"}, {"CheckExceptionSafety::rethrowNoCurrentException",""}, - {"CheckFunctions::checkProhibitedFunctions",""}, - {"CheckFunctions::invalidFunctionUsage",""}, + {"CheckExceptionSafety::unhandledExceptionSpecification","style,inconclusive"}, {"CheckFunctions::checkIgnoredReturnValue","style,warning"}, - {"CheckFunctions::checkMissingReturn",""}, {"CheckFunctions::checkMathFunctions","style,warning,c99,c++11"}, - {"CheckFunctions::memsetZeroBytes","warning"}, + {"CheckFunctions::checkMissingReturn",""}, + {"CheckFunctions::checkProhibitedFunctions",""}, + {"CheckFunctions::invalidFunctionUsage",""}, {"CheckFunctions::memsetInvalid2ndParam","warning,portability"}, + {"CheckFunctions::memsetZeroBytes","warning"}, {"CheckFunctions::returnLocalStdMove","performance,c++11"}, {"CheckFunctions::useStandardLibrary","style"}, {"CheckIO::checkCoutCerrMisusage","c"}, {"CheckIO::checkFileUsage",""}, - {"CheckIO::invalidScanf",""}, {"CheckIO::checkWrongPrintfScanfArguments",""}, - {"CheckMemoryLeakInFunction::checkReallocUsage",""}, + {"CheckIO::invalidScanf",""}, + {"CheckLeakAutoVar::check","notclang"}, {"CheckMemoryLeakInClass::check",""}, - {"CheckMemoryLeakStructMember::check",""}, + {"CheckMemoryLeakInFunction::checkReallocUsage",""}, {"CheckMemoryLeakNoVar::check",""}, {"CheckMemoryLeakNoVar::checkForUnsafeArgAlloc",""}, - {"CheckPostfixOperator::postfixOperator","performance"}, - {"CheckSizeof::checkSizeofForNumericParameter","warning"}, - {"CheckSizeof::checkSizeofForArrayParameter","warning"}, - {"CheckSizeof::checkSizeofForPointerSize","warning"}, - {"CheckSizeof::sizeofsizeof","warning"}, - {"CheckSizeof::sizeofCalculation","warning"}, - {"CheckSizeof::sizeofFunction","warning"}, - {"CheckSizeof::suspiciousSizeofCalculation","warning,inconclusive"}, - {"CheckSizeof::sizeofVoid","portability"}, - {"CheckString::stringLiteralWrite",""}, - {"CheckString::checkAlwaysTrueOrFalseStringCompare","warning"}, - {"CheckString::checkSuspiciousStringCompare","warning"}, - {"CheckString::strPlusChar",""}, - {"CheckString::checkIncorrectStringCompare","warning"}, - {"CheckString::overlappingStrcmp","warning"}, - {"CheckString::sprintfOverlappingData",""}, - {"CheckVaarg::va_start_argument",""}, - {"CheckVaarg::va_list_usage","notclang"}, - {"CheckUnusedFunctions::check","unusedFunction"}, - {"CheckAutoVariables::assignFunctionArg","style,warning"}, - {"CheckAutoVariables::autoVariables",""}, - {"CheckAutoVariables::checkVarLifetime",""}, - {"CheckBufferOverrun::arrayIndex",""}, - {"CheckBufferOverrun::pointerArithmetic","portability"}, - {"CheckBufferOverrun::bufferOverflow",""}, - {"CheckBufferOverrun::arrayIndexThenCheck",""}, - {"CheckBufferOverrun::stringNotZeroTerminated","warning,inconclusive"}, - {"CheckBufferOverrun::argumentSize","warning"}, - {"CheckBufferOverrun::analyseWholeProgram",""}, - {"CheckBufferOverrun::objectIndex",""}, - {"CheckBufferOverrun::negativeArraySize",""}, - {"CheckCondition::assignIf","style"}, - {"CheckCondition::checkBadBitmaskCheck","style"}, - {"CheckCondition::comparison","style"}, - {"CheckCondition::duplicateCondition","style"}, - {"CheckCondition::multiCondition","style"}, - {"CheckCondition::multiCondition2","warning"}, - {"CheckCondition::checkIncorrectLogicOperator","style,warning"}, - {"CheckCondition::checkModuloAlwaysTrueFalse","warning"}, - {"CheckCondition::clarifyCondition","style"}, - {"CheckCondition::alwaysTrueFalse","style"}, - {"CheckCondition::checkInvalidTestForOverflow","warning"}, - {"CheckCondition::checkPointerAdditionResultNotNull","warning"}, - {"CheckCondition::checkDuplicateConditionalAssign","style"}, - {"CheckCondition::checkAssignmentInCondition","style"}, - {"CheckCondition::checkCompareValueOutOfTypeRange","style,platform"}, - {"CheckLeakAutoVar::check","notclang"}, - {"CheckNullPointer::nullPointer",""}, - {"CheckNullPointer::nullConstantDereference",""}, - {"CheckNullPointer::arithmetic",""}, + {"CheckMemoryLeakStructMember::check",""}, {"CheckNullPointer::analyseWholeProgram","unusedfunctions"}, + {"CheckNullPointer::arithmetic",""}, + {"CheckNullPointer::nullConstantDereference",""}, + {"CheckNullPointer::nullPointer",""}, + {"CheckOther::checkAccessOfMovedVariable","c++11,warning"}, {"CheckOther::checkCastIntToCharAndBack","warning"}, - {"CheckOther::clarifyCalculation","style"}, - {"CheckOther::clarifyStatement","warning"}, - {"CheckOther::checkSuspiciousSemicolon","warning,inconclusive"}, - {"CheckOther::warningOldStylePointerCast","style,c++"}, - {"CheckOther::warningDangerousTypeCast","warning,c++"}, - {"CheckOther::warningIntToPointerCast","portability"}, - {"CheckOther::suspiciousFloatingPointCast","style"}, - {"CheckOther::invalidPointerCast","portability"}, - {"CheckOther::checkRedundantAssignment","style"}, - {"CheckOther::redundantBitwiseOperationInSwitch","warning"}, - {"CheckOther::checkSuspiciousCaseInSwitch","warning,inconclusive"}, - {"CheckOther::checkUnreachableCode","style"}, - {"CheckOther::checkVariableScope","style,notclang"}, - {"CheckOther::checkPassByReference","performance,c++"}, - {"CheckOther::checkConstVariable","style,c++"}, - {"CheckOther::checkConstPointer","style"}, {"CheckOther::checkCharVariable","warning,portability"}, - {"CheckOther::checkIncompleteStatement","warning"}, - {"CheckOther::checkZeroDivision",""}, - {"CheckOther::checkNanInArithmeticExpression","style"}, - {"CheckOther::checkMisusedScopedObject","style,c++"}, + {"CheckOther::checkComparePointers",""}, + {"CheckOther::checkComparisonFunctionIsAlwaysTrueOrFalse","warning"}, + {"CheckOther::checkConstPointer","style"}, + {"CheckOther::checkConstVariable","style,c++"}, {"CheckOther::checkDuplicateBranch","style,inconclusive"}, - {"CheckOther::checkInvalidFree",""}, {"CheckOther::checkDuplicateExpression","style,warning"}, - {"CheckOther::checkComparisonFunctionIsAlwaysTrueOrFalse","warning"}, - {"CheckOther::checkSignOfUnsignedVariable","style"}, - {"CheckOther::checkRedundantCopy","c++,performance,inconclusive"}, - {"CheckOther::checkNegativeBitwiseShift",""}, - {"CheckOther::checkIncompleteArrayFill","warning,portability,inconclusive"}, - {"CheckOther::checkVarFuncNullUB","portability"}, - {"CheckOther::checkRedundantPointerOp","style"}, - {"CheckOther::checkInterlockedDecrement","windows-platform"}, - {"CheckOther::checkUnusedLabel","style,warning"}, {"CheckOther::checkEvaluationOrder",""}, - {"CheckOther::checkAccessOfMovedVariable","c++11,warning"}, {"CheckOther::checkFuncArgNamesDifferent","style,warning,inconclusive"}, - {"CheckOther::checkShadowVariables","style"}, + {"CheckOther::checkIncompleteArrayFill","warning,portability,inconclusive"}, + {"CheckOther::checkIncompleteStatement","warning"}, + {"CheckOther::checkInterlockedDecrement","windows-platform"}, + {"CheckOther::checkInvalidFree",""}, {"CheckOther::checkKnownArgument","style"}, {"CheckOther::checkKnownPointerToBool","style"}, - {"CheckOther::checkComparePointers",""}, + {"CheckOther::checkMisusedScopedObject","style,c++"}, {"CheckOther::checkModuloOfOne","style"}, + {"CheckOther::checkNanInArithmeticExpression","style"}, + {"CheckOther::checkNegativeBitwiseShift",""}, {"CheckOther::checkOverlappingWrite",""}, - {"CheckStl::outOfBounds",""}, - {"CheckStl::outOfBoundsIndexExpression",""}, + {"CheckOther::checkPassByReference","performance,c++"}, + {"CheckOther::checkRedundantAssignment","style"}, + {"CheckOther::checkRedundantCopy","c++,performance,inconclusive"}, + {"CheckOther::checkRedundantPointerOp","style"}, + {"CheckOther::checkShadowVariables","style"}, + {"CheckOther::checkSignOfUnsignedVariable","style"}, + {"CheckOther::checkSuspiciousCaseInSwitch","warning,inconclusive"}, + {"CheckOther::checkSuspiciousSemicolon","warning,inconclusive"}, + {"CheckOther::checkUnreachableCode","style"}, + {"CheckOther::checkUnusedLabel","style,warning"}, + {"CheckOther::checkVarFuncNullUB","portability"}, + {"CheckOther::checkVariableScope","style,notclang"}, + {"CheckOther::checkZeroDivision",""}, + {"CheckOther::clarifyCalculation","style"}, + {"CheckOther::clarifyStatement","warning"}, + {"CheckOther::invalidPointerCast","portability"}, + {"CheckOther::redundantBitwiseOperationInSwitch","warning"}, + {"CheckOther::suspiciousFloatingPointCast","style"}, + {"CheckOther::warningDangerousTypeCast","warning,c++"}, + {"CheckOther::warningIntToPointerCast","portability"}, + {"CheckOther::warningOldStylePointerCast","style,c++"}, + {"CheckPostfixOperator::postfixOperator","performance"}, + {"CheckSizeof::checkSizeofForArrayParameter","warning"}, + {"CheckSizeof::checkSizeofForNumericParameter","warning"}, + {"CheckSizeof::checkSizeofForPointerSize","warning"}, + {"CheckSizeof::sizeofCalculation","warning"}, + {"CheckSizeof::sizeofFunction","warning"}, + {"CheckSizeof::sizeofVoid","portability"}, + {"CheckSizeof::sizeofsizeof","warning"}, + {"CheckSizeof::suspiciousSizeofCalculation","warning,inconclusive"}, + {"CheckStl::checkDereferenceInvalidIterator","warning"}, + {"CheckStl::checkDereferenceInvalidIterator2",""}, + {"CheckStl::checkFindInsert","performance"}, + {"CheckStl::checkMutexes","warning"}, + {"CheckStl::erase",""}, + {"CheckStl::eraseIteratorOutOfBounds",""}, + {"CheckStl::if_find","warning,performance"}, + {"CheckStl::invalidContainer",""}, {"CheckStl::iterators",""}, - {"CheckStl::misMatchingContainers",""}, + {"CheckStl::knownEmptyContainer","style"}, {"CheckStl::misMatchingContainerIterator",""}, - {"CheckStl::invalidContainer",""}, - {"CheckStl::stlOutOfBounds",""}, + {"CheckStl::misMatchingContainers",""}, + {"CheckStl::missingComparison","warning"}, {"CheckStl::negativeIndex",""}, - {"CheckStl::erase",""}, - {"CheckStl::stlBoundaries",""}, - {"CheckStl::if_find","warning,performance"}, - {"CheckStl::checkFindInsert","performance"}, - {"CheckStl::size","performance,c++03"}, + {"CheckStl::outOfBounds",""}, + {"CheckStl::outOfBoundsIndexExpression",""}, {"CheckStl::redundantCondition","style"}, - {"CheckStl::missingComparison","warning"}, + {"CheckStl::size","performance,c++03"}, + {"CheckStl::stlBoundaries",""}, + {"CheckStl::stlOutOfBounds",""}, {"CheckStl::string_c_str",""}, - {"CheckStl::uselessCalls","performance,warning"}, - {"CheckStl::checkDereferenceInvalidIterator","warning"}, - {"CheckStl::checkDereferenceInvalidIterator2",""}, {"CheckStl::useStlAlgorithm","style"}, - {"CheckStl::knownEmptyContainer","style"}, - {"CheckStl::eraseIteratorOutOfBounds",""}, - {"CheckStl::checkMutexes","warning"}, - {"CheckType::checkTooBigBitwiseShift","platform"}, + {"CheckStl::uselessCalls","performance,warning"}, + {"CheckString::checkAlwaysTrueOrFalseStringCompare","warning"}, + {"CheckString::checkIncorrectStringCompare","warning"}, + {"CheckString::checkSuspiciousStringCompare","warning"}, + {"CheckString::overlappingStrcmp","warning"}, + {"CheckString::sprintfOverlappingData",""}, + {"CheckString::strPlusChar",""}, + {"CheckString::stringLiteralWrite",""}, + {"CheckType::checkFloatToIntegerOverflow",""}, {"CheckType::checkIntegerOverflow","platform"}, - {"CheckType::checkSignConversion","warning"}, {"CheckType::checkLongCast","style"}, - {"CheckType::checkFloatToIntegerOverflow",""}, + {"CheckType::checkSignConversion","warning"}, + {"CheckType::checkTooBigBitwiseShift","platform"}, + {"CheckUninitVar::analyseWholeProgram",""}, {"CheckUninitVar::check",""}, {"CheckUninitVar::valueFlowUninit",""}, - {"CheckUninitVar::analyseWholeProgram",""}, - {"CheckClass::checkConstructors","style,warning"}, - {"CheckClass::checkExplicitConstructors","style"}, - {"CheckClass::checkCopyConstructors","warning"}, - {"CheckClass::initializationListUsage","performance"}, - {"CheckClass::privateFunctions","style"}, - {"CheckClass::checkMemset",""}, - {"CheckClass::operatorEqRetRefThis","style"}, - {"CheckClass::operatorEqToSelf","warning"}, - {"CheckClass::virtualDestructor",""}, - {"CheckClass::thisSubtraction","warning"}, - {"CheckClass::checkConst","style,inconclusive"}, - {"CheckClass::initializerListOrder","style,inconclusive"}, - {"CheckClass::checkSelfInitialization",""}, - {"CheckClass::checkVirtualFunctionCallInConstructor","warning"}, - {"CheckClass::checkDuplInheritedMembers","warning"}, - {"CheckClass::checkMissingOverride","style,c++03"}, - {"CheckClass::checkUselessOverride","style"}, - {"CheckClass::checkReturnByReference","performance"}, - {"CheckClass::checkThisUseAfterFree","warning"}, - {"CheckClass::checkUnsafeClassRefMember","warning,safeChecks"}, - {"CheckClass::analyseWholeProgram",""}, + {"CheckUnusedFunctions::check","unusedFunction"}, {"CheckUnusedVar::checkFunctionVariableUsage","style"}, {"CheckUnusedVar::checkStructMemberUsage","style"}, + {"CheckVaarg::va_list_usage","notclang"}, + {"CheckVaarg::va_start_argument",""}, }; const std::map premiumCheckers{ @@ -991,7 +991,7 @@ namespace checkers { {"PremiumMetrics::HIS::StmtFile",""}, {"PremiumMetrics::HIS::VOCF",""}, {"PremiumMetrics::HIS::return",""}, - {"PremiumMetrics::cyclomaticComplexity",""} + {"PremiumMetrics::cyclomaticComplexity",""}, }; const char Req[] = "Required"; @@ -2666,7 +2666,6 @@ std::vector checkers::certCInfo{ {"STR04-C", "L3"}, {"STR05-C", "L3"}, {"STR06-C", "L2"}, - {"STR07-C", "L1"}, {"STR08-C", "L2"}, {"STR09-C", "L3"}, {"STR10-C", "L3"}, diff --git a/tools/get_checkers.py b/tools/get_checkers.py index 1d19c3a123a..e2c9719bbfd 100644 --- a/tools/get_checkers.py +++ b/tools/get_checkers.py @@ -4,6 +4,23 @@ import re import requests + +def print_checkers(glob_pattern:str): + checkers = {} + for filename in glob.glob(glob_pattern): + for line in open(filename,'rt'): + res = re.match(r'[ \t]*logChecker\(\s*"([^"]+)"\s*\);.*', line) + if res is None: + continue + if line.find('//') > 0: + req = line[line.find('//')+2:].strip() + else: + req = '' + checkers[res.group(1)] = req + for c,req in dict(sorted(checkers.items())).items(): + print(' {"%s","%s"},' % (c, req)) + + print("""/* * Cppcheck - A tool for static C/C++ code analysis * Copyright (C) 2007-%i Cppcheck team. @@ -29,33 +46,11 @@ namespace checkers { const std::map allCheckers{""" % (datetime.date.today().year,)) - -for filename in glob.glob(os.path.expanduser('~/cppchecksolutions/cppcheck/lib/*.cpp')): - for line in open(filename,'rt'): - res = re.match(r'[ \t]*logChecker\(\s*"([:_a-zA-Z0-9]+)"\s*\);.*', line) - if res is None: - continue - req = '' - if line.find('//')>0: - req = line[line.find('//')+2:].strip() - print(' {"%s","%s"},' % (res.group(1), req)) +print_checkers(os.path.expanduser('~/cppchecksolutions/cppcheck/lib/*.cpp')) print(" };\n") print(' const std::map premiumCheckers{') -premium_checkers = [] -for filename in sorted(glob.glob(os.path.expanduser('~/cppchecksolutions/addon/src/*.cpp'))): - for line in open(filename,'rt'): - res = re.match(r'[ \t]*logChecker\("([^"]+)"\);.*', line) - if res is None: - continue - if line.find('//') > 0: - req = line[line.find('//')+2:].strip() - else: - req = '' - c = ' {"%s","%s"}' % (res.group(1), req) - if c not in premium_checkers: - premium_checkers.append(c) -print(',\n'.join(sorted(premium_checkers))) +print_checkers(os.path.expanduser('~/cppchecksolutions/addon/src/*.cpp')) print(' };')