@@ -258,14 +258,19 @@ void Settings::setCheckLevelNormal()
258258
259259// TODO: auto generate these tables
260260
261- static const std::set<std::string> autosar_checkers {
261+ static const std::set<std::string> autosarCheckers {
262262 " accessMoved" ,
263+ " argumentSize" ,
263264 " arrayIndexOutOfBounds" ,
265+ " arrayIndexOutOfBoundsCond" ,
266+ " arrayIndexThenCheck" ,
267+ " bufferAccessOutOfBounds" ,
264268 " comparePointers" ,
265269 " constParameter" ,
266270 " cstyleCast" ,
267271 " ctuOneDefinitionViolation" ,
268272 " doubleFree" ,
273+ " duplInheritedMember" ,
269274 " duplicateBreak" ,
270275 " funcArgNamesDifferent" ,
271276 " functionConst" ,
@@ -274,122 +279,247 @@ static const std::set<std::string> autosar_checkers{
274279 " memleak" ,
275280 " mismatchAllocDealloc" ,
276281 " missingReturn" ,
282+ " negativeIndex" ,
277283 " noExplicitConstructor" ,
278284 " nullPointer" ,
285+ " nullPointerArithmetic" ,
286+ " nullPointerArithmeticRedundantCheck" ,
287+ " nullPointerDefaultArg" ,
288+ " nullPointerRedundantCheck" ,
289+ " objectIndex" ,
290+ " overlappingWriteFunction" ,
291+ " overlappingWriteUnion" ,
279292 " pointerOutOfBounds" ,
280- " unreadVariable " ,
281- " unusedValue " ,
293+ " pointerOutOfBoundsCond " ,
294+ " preprocessorErrorDirective " ,
282295 " redundantAssignment" ,
283296 " redundantInitialization" ,
284297 " returnDanglingLifetime" ,
285- " shadowVariable" ,
286298 " shiftTooManyBits" ,
287299 " sizeofSideEffects" ,
288300 " throwInDestructor" ,
289301 " throwInNoexceptFunction" ,
290- " unreachableCode" ,
291302 " uninitData" ,
292303 " uninitMember" ,
304+ " unreachableCode" ,
305+ " unreadVariable" ,
306+ " unsignedLessThanZero" ,
307+ " unusedFunction" ,
308+ " unusedStructMember" ,
309+ " unusedValue" ,
293310 " unusedVariable" ,
294311 " useInitializerList" ,
295312 " variableScope" ,
296313 " virtualCallInConstructor" ,
297- " zeroDiv"
314+ " zerodiv" ,
315+ " zerodivcond"
298316};
299317
300- static const std::set<std::string> cert_c_checkers{
301- " danglingLifetime" , " autoVariables" , " invalidLifetime" ,
302- " unknownEvaluationOrder" ,
303- " uninitvar" , " uninitdata" , " uninitStructMember" ,
304- " nullPointer" ,
305- " sizeofCalculation" ,
318+ static const std::set<std::string> certCCheckers{
319+ " IOWithoutPositioning" ,
320+ " autoVariables" ,
321+ " autovarInvalidDeallocation" ,
306322 " bitwiseOnBoolean" ,
307- " invalidFunctionArg" ,
308- " floatConversionOverflow" ,
309323 " comparePointers" ,
310- " stringLiteralWrite" ,
311- " doubleFree" ,
324+ " danglingLifetime" ,
312325 " deallocret" ,
313326 " deallocuse" ,
327+ " doubleFree" ,
328+ " floatConversionOverflow" ,
329+ " invalidFunctionArg" ,
330+ " invalidLengthModifierError" ,
331+ " invalidLifetime" ,
332+ " invalidScanfFormatWidth" ,
333+ " invalidscanf" ,
334+ " leakReturnValNotUsed" ,
335+ " leakUnsafeArgAlloc" ,
314336 " memleak" ,
315- " autovarInvalidDeallocation " ,
337+ " memleakOnRealloc " ,
316338 " mismatchAllocDealloc" ,
317- " IOWithoutPositioning" ,
339+ " missingReturn" ,
340+ " nullPointer" ,
341+ " nullPointerArithmetic" ,
342+ " nullPointerArithmeticRedundantCheck" ,
343+ " nullPointerDefaultArg" ,
344+ " nullPointerRedundantCheck" ,
345+ " preprocessorErrorDirective" ,
318346 " resourceLeak" ,
347+ " sizeofCalculation" ,
348+ " stringLiteralWrite" ,
349+ " uninitStructMember" ,
350+ " uninitdata" ,
351+ " uninitvar" ,
352+ " unknownEvaluationOrder" ,
319353 " useClosedFile" ,
320- " invalidscanf" ,
321354 " wrongPrintfScanfArgNum" ,
322- " invalidLengthModifierError" ,
323- " invalidScanfFormatWidth" ,
324- " wrongPrintfScanfParameterPositionError" ,
325- " missingReturn"
355+ " wrongPrintfScanfParameterPositionError"
326356};
327357
328- static const std::set<std::string> cert_cpp_checkers{
329- " deallocThrow" , " exceptThrowInDestructor" ,
330- " ctuOneDefinitionViolation" ,
331- " sizeofCalculation" ,
332- " comparePointers" ,
358+ static const std::set<std::string> certCppCheckers{
333359 " IOWithoutPositioning" ,
334- " virtualCallInConstructor" ,
335- " virtualDestructor" ,
360+ " accessMoved" ,
361+ " comparePointers" ,
362+ " containerOutOfBounds" ,
363+ " ctuOneDefinitionViolation" ,
364+ " deallocMismatch" ,
365+ " deallocThrow" ,
366+ " deallocuse" ,
367+ " doubleFree" ,
368+ " eraseDereference" ,
369+ " exceptThrowInDestructor" ,
336370 " initializerList" ,
337- " operatorEqToSelf" ,
371+ " invalidContainer" ,
372+ " lifetime" ,
373+ " memleak" ,
338374 " missingReturn" ,
375+ " nullPointer" ,
376+ " operatorEqToSelf" ,
377+ " sizeofCalculation" ,
378+ " uninitvar" ,
379+ " virtualCallInConstructor" ,
380+ " virtualDestructor"
339381};
340382
341- static const std::set<std::string> misra_c_checkers{
342- " alwaysFalse" , " duplicateBreak" ,
343- " alwaysTrue" , " redundantCondition" , " redundantAssignment" , " redundantAssignInSwitch" , " unreadVariable" ,
344- " unusedVariable" ,
345- " unusedLabel" ,
346- " shadowVariable" ,
347- " funcArgNamesDifferent" ,
383+ static const std::set<std::string> misrac2012Checkers{
384+ " alwaysFalse" ,
385+ " alwaysTrue" ,
386+ " argumentSize" ,
387+ " autovarInvalidDeallocation" ,
388+ " bufferAccessOutOfBounds" ,
389+ " comparePointers" ,
390+ " compareValueOutOfTypeRangeError" ,
348391 " constPointer" ,
392+ " danglingLifetime" ,
393+ " duplicateBreak" ,
394+ " error" ,
395+ " funcArgNamesDifferent" ,
396+ " incompatibleFileOpen" ,
397+ " invalidFunctionArg" ,
398+ " knownConditionTrueFalse" ,
399+ " leakNoVarFunctionCall" ,
400+ " leakReturnValNotUsed" ,
401+ " memleak" ,
402+ " memleakOnRealloc" ,
403+ " missingReturn" ,
404+ " overlappingWriteFunction" ,
405+ " overlappingWriteUnion" ,
406+ " pointerOutOfBounds" ,
407+ " preprocessorErrorDirective" ,
408+ " redundantAssignInSwitch" ,
409+ " redundantAssignment" ,
410+ " redundantCondition" ,
411+ " resourceLeak" ,
412+ " shadowVariable" ,
413+ " sizeofCalculation" ,
414+ " syntaxError" ,
349415 " uninitvar" ,
350- " alwaysTrue" , " alwaysFalse" , " compareValueOutOfTypeRangeError" , " knownConditionTrueFalse" ,
351416 " unknownEvaluationOrder" ,
352- " sizeofCalculation" ,
353- " missingReturn" ,
417+ " unreadVariable" ,
418+ " unusedLabel" ,
419+ " unusedVariable" ,
420+ " useClosedFile" ,
421+ " writeReadOnlyFile"
422+ };
423+
424+ static const std::set<std::string> misrac2023Checkers{
425+ " alwaysFalse" ,
426+ " alwaysTrue" ,
354427 " argumentSize" ,
355- " pointerOutOfBounds" ,
428+ " autovarInvalidDeallocation" ,
429+ " bufferAccessOutOfBounds" ,
356430 " comparePointers" ,
431+ " compareValueOutOfTypeRangeError" ,
432+ " constPointer" ,
357433 " danglingLifetime" ,
358- " overlappingWriteUnion" , " overlappingWriteFunction" ,
359- " invalidFunctionArg" ,
360- " bufferAccessOutOfBounds" ,
361- " memleak" , " resourceLeak" , " memleakOnRealloc" , " leakReturnValNotUsed" , " leakNoVarFunctionCall" ,
362- " autovarInvalidDeallocation" ,
434+ " duplicateBreak" ,
435+ " error" ,
436+ " funcArgNamesDifferent" ,
363437 " incompatibleFileOpen" ,
364- " writeReadOnlyFile" ,
365- " useClosedFile"
366- };
367-
368- static const std::set<std::string> misra_cpp_checkers{
369- " redundantAssignment" , " unreadVariable" , " varScope" ,
438+ " invalidFunctionArg" ,
439+ " knownConditionTrueFalse" ,
440+ " leakNoVarFunctionCall" ,
441+ " leakReturnValNotUsed" ,
442+ " memleak" ,
443+ " memleakOnRealloc" ,
444+ " missingReturn" ,
445+ " overlappingWriteFunction" ,
446+ " overlappingWriteUnion" ,
447+ " pointerOutOfBounds" ,
448+ " preprocessorErrorDirective" ,
449+ " redundantAssignInSwitch" ,
450+ " redundantAssignment" ,
451+ " redundantCondition" ,
452+ " resourceLeak" ,
370453 " shadowVariable" ,
454+ " sizeofCalculation" ,
455+ " syntaxError" ,
456+ " uninitvar" ,
371457 " unknownEvaluationOrder" ,
458+ " unreadVariable" ,
459+ " unusedLabel" ,
460+ " unusedVariable" ,
461+ " useClosedFile" ,
462+ " writeReadOnlyFile"
463+ };
464+
465+ static const std::set<std::string> misracpp2008Checkers{
466+ " autoVariables" ,
467+ " comparePointers" ,
468+ " constParameter" ,
469+ " constVariable" ,
372470 " cstyleCast" ,
373- " constVariable " , " constParameter " ,
471+ " ctuOneDefinitionViolation " ,
374472 " danglingLifetime" ,
473+ " duplInheritedMember" ,
474+ " duplicateBreak" ,
475+ " exceptThrowInDestructor" ,
476+ " funcArgNamesDifferent" ,
477+ " functionConst" ,
478+ " functionStatic" ,
375479 " missingReturn" ,
376- " uninitMember" ,
377480 " noExplicit" ,
378- " exceptThrowInDestructor" ,
379- " throwInDestructor"
481+ " overlappingWriteFunction" ,
482+ " overlappingWriteUnion" ,
483+ " pointerOutOfBounds" ,
484+ " preprocessorErrorDirective" ,
485+ " redundantAssignment" ,
486+ " redundantInitialization" ,
487+ " returnReference" ,
488+ " returnTempReference" ,
489+ " shadowVariable" ,
490+ " shiftTooManyBits" ,
491+ " sizeofSideEffects" ,
492+ " throwInDestructor" ,
493+ " uninitDerivedMemberVar" ,
494+ " uninitDerivedMemberVarPrivate" ,
495+ " uninitMemberVar" ,
496+ " uninitMemberVarPrivate" ,
497+ " uninitStructMember" ,
498+ " uninitdata" ,
499+ " uninitvar" ,
500+ " unknownEvaluationOrder" ,
501+ " unreachableCode" ,
502+ " unreadVariable" ,
503+ " unsignedLessThanZero" ,
504+ " unusedFunction" ,
505+ " unusedStructMember" ,
506+ " unusedVariable" ,
507+ " varScope" ,
508+ " variableScope" ,
509+ " virtualCallInConstructor"
380510};
381511
382512bool Settings::isPremiumEnabled (const char id[]) const
383513{
384- if (premiumArgs.find (" autosar" ) != std::string::npos && autosar_checkers .count (id))
514+ if (premiumArgs.find (" autosar" ) != std::string::npos && autosarCheckers .count (id))
385515 return true ;
386- if (premiumArgs.find (" cert-c-" ) != std::string::npos && cert_c_checkers .count (id))
516+ if (premiumArgs.find (" cert-c-" ) != std::string::npos && certCCheckers .count (id))
387517 return true ;
388- if (premiumArgs.find (" cert-c++" ) != std::string::npos && cert_cpp_checkers .count (id))
518+ if (premiumArgs.find (" cert-c++" ) != std::string::npos && certCppCheckers .count (id))
389519 return true ;
390- if (premiumArgs.find (" misra-c-" ) != std::string::npos && misra_c_checkers .count (id))
520+ if (premiumArgs.find (" misra-c-" ) != std::string::npos && (misrac2012Checkers .count (id) || misrac2023Checkers. count (id) ))
391521 return true ;
392- if (premiumArgs.find (" misra-c++" ) != std::string::npos && misra_cpp_checkers .count (id))
522+ if (premiumArgs.find (" misra-c++" ) != std::string::npos && misracpp2008Checkers .count (id))
393523 return true ;
394524 return false ;
395525}
0 commit comments