@specs-feup/clava-misra 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitignore +117 -0
- package/README.md +70 -15
- package/dist/MISRA.d.ts +129 -0
- package/dist/MISRA.d.ts.map +1 -0
- package/dist/MISRA.js +245 -0
- package/dist/MISRA.js.map +1 -0
- package/dist/MISRAContext.d.ts +21 -0
- package/dist/MISRAContext.d.ts.map +1 -0
- package/dist/MISRAContext.js +75 -0
- package/dist/MISRAContext.js.map +1 -0
- package/dist/MISRARule.d.ts +56 -0
- package/dist/MISRARule.d.ts.map +1 -0
- package/dist/MISRARule.js +45 -0
- package/dist/MISRARule.js.map +1 -0
- package/dist/MISRATool.d.ts +12 -0
- package/dist/MISRATool.d.ts.map +1 -0
- package/dist/MISRATool.js +84 -0
- package/dist/MISRATool.js.map +1 -0
- package/dist/foo.d.ts +2 -0
- package/dist/foo.d.ts.map +1 -0
- package/{src/foo.ts → dist/foo.js} +3 -2
- package/dist/foo.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +5 -0
- package/dist/main.js.map +1 -0
- package/dist/misra/MISRAAnalyser.d.ts +14 -0
- package/dist/misra/MISRAAnalyser.d.ts.map +1 -0
- package/{src/misra/MISRAAnalyser.ts → dist/misra/MISRAAnalyser.js} +13 -23
- package/dist/misra/MISRAAnalyser.js.map +1 -0
- package/dist/misra/MISRAPass.d.ts +27 -0
- package/dist/misra/MISRAPass.d.ts.map +1 -0
- package/dist/misra/MISRAPass.js +60 -0
- package/dist/misra/MISRAPass.js.map +1 -0
- package/dist/misra/MISRAPassResult.d.ts +13 -0
- package/dist/misra/MISRAPassResult.d.ts.map +1 -0
- package/dist/misra/MISRAPassResult.js +11 -0
- package/dist/misra/MISRAPassResult.js.map +1 -0
- package/dist/misra/MISRAReporter.d.ts +20 -0
- package/dist/misra/MISRAReporter.d.ts.map +1 -0
- package/dist/misra/MISRAReporter.js +43 -0
- package/dist/misra/MISRAReporter.js.map +1 -0
- package/dist/misra/passes/S10_EssentialTypePass.d.ts +42 -0
- package/dist/misra/passes/S10_EssentialTypePass.d.ts.map +1 -0
- package/dist/misra/passes/S10_EssentialTypePass.js +370 -0
- package/dist/misra/passes/S10_EssentialTypePass.js.map +1 -0
- package/dist/misra/passes/S12_ExpressionPass.d.ts +18 -0
- package/dist/misra/passes/S12_ExpressionPass.d.ts.map +1 -0
- package/dist/misra/passes/S12_ExpressionPass.js +72 -0
- package/dist/misra/passes/S12_ExpressionPass.js.map +1 -0
- package/dist/misra/passes/S13_SideEffectPass.d.ts +18 -0
- package/dist/misra/passes/S13_SideEffectPass.d.ts.map +1 -0
- package/dist/misra/passes/S13_SideEffectPass.js +105 -0
- package/dist/misra/passes/S13_SideEffectPass.js.map +1 -0
- package/dist/misra/passes/S15_ControlFlowPass.d.ts +19 -0
- package/dist/misra/passes/S15_ControlFlowPass.d.ts.map +1 -0
- package/dist/misra/passes/S15_ControlFlowPass.js +94 -0
- package/dist/misra/passes/S15_ControlFlowPass.js.map +1 -0
- package/dist/misra/passes/S16_SwitchStatementPass.d.ts +17 -0
- package/dist/misra/passes/S16_SwitchStatementPass.d.ts.map +1 -0
- package/dist/misra/passes/S16_SwitchStatementPass.js +152 -0
- package/dist/misra/passes/S16_SwitchStatementPass.js.map +1 -0
- package/dist/misra/passes/S17_FunctionPass.d.ts +12 -0
- package/dist/misra/passes/S17_FunctionPass.d.ts.map +1 -0
- package/dist/misra/passes/S17_FunctionPass.js +38 -0
- package/dist/misra/passes/S17_FunctionPass.js.map +1 -0
- package/dist/misra/passes/S18_PointersArraysPass.d.ts +17 -0
- package/dist/misra/passes/S18_PointersArraysPass.d.ts.map +1 -0
- package/dist/misra/passes/S18_PointersArraysPass.js +115 -0
- package/dist/misra/passes/S18_PointersArraysPass.js.map +1 -0
- package/dist/misra/passes/S19_OverlappingStoragePass.d.ts +11 -0
- package/dist/misra/passes/S19_OverlappingStoragePass.d.ts.map +1 -0
- package/dist/misra/passes/S19_OverlappingStoragePass.js +20 -0
- package/dist/misra/passes/S19_OverlappingStoragePass.js.map +1 -0
- package/dist/misra/passes/S21_StandardLibPass.d.ts +20 -0
- package/dist/misra/passes/S21_StandardLibPass.d.ts.map +1 -0
- package/dist/misra/passes/S21_StandardLibPass.js +77 -0
- package/dist/misra/passes/S21_StandardLibPass.js.map +1 -0
- package/dist/misra/passes/S3_CommentPass.d.ts +12 -0
- package/dist/misra/passes/S3_CommentPass.d.ts.map +1 -0
- package/dist/misra/passes/S3_CommentPass.js +27 -0
- package/dist/misra/passes/S3_CommentPass.js.map +1 -0
- package/dist/misra/passes/S5_IdentifierPass.d.ts +13 -0
- package/dist/misra/passes/S5_IdentifierPass.d.ts.map +1 -0
- package/dist/misra/passes/S5_IdentifierPass.js +60 -0
- package/dist/misra/passes/S5_IdentifierPass.js.map +1 -0
- package/dist/misra/passes/S6_TypePass.d.ts +11 -0
- package/dist/misra/passes/S6_TypePass.d.ts.map +1 -0
- package/dist/misra/passes/S6_TypePass.js +25 -0
- package/dist/misra/passes/S6_TypePass.js.map +1 -0
- package/dist/misra/passes/S7_LiteralsConstantsPass.d.ts +14 -0
- package/dist/misra/passes/S7_LiteralsConstantsPass.d.ts.map +1 -0
- package/dist/misra/passes/S7_LiteralsConstantsPass.js +71 -0
- package/dist/misra/passes/S7_LiteralsConstantsPass.js.map +1 -0
- package/dist/misra/passes/S8_DeclDefPass.d.ts +18 -0
- package/dist/misra/passes/S8_DeclDefPass.d.ts.map +1 -0
- package/dist/misra/passes/S8_DeclDefPass.js +127 -0
- package/dist/misra/passes/S8_DeclDefPass.js.map +1 -0
- package/dist/misra/sections/Section10_EssentialTypeModel.d.ts +33 -0
- package/dist/misra/sections/Section10_EssentialTypeModel.d.ts.map +1 -0
- package/{src/misra/sections/Section10_EssentialTypeModel.ts → dist/misra/sections/Section10_EssentialTypeModel.js} +58 -73
- package/dist/misra/sections/Section10_EssentialTypeModel.js.map +1 -0
- package/dist/misra/sections/Section11_PointerTypeConversions.d.ts +12 -0
- package/dist/misra/sections/Section11_PointerTypeConversions.d.ts.map +1 -0
- package/{src/misra/sections/Section11_PointerTypeConversions.ts → dist/misra/sections/Section11_PointerTypeConversions.js} +16 -27
- package/dist/misra/sections/Section11_PointerTypeConversions.js.map +1 -0
- package/dist/misra/sections/Section12_Expressions.d.ts +15 -0
- package/dist/misra/sections/Section12_Expressions.d.ts.map +1 -0
- package/dist/misra/sections/Section12_Expressions.js +70 -0
- package/dist/misra/sections/Section12_Expressions.js.map +1 -0
- package/dist/misra/sections/Section13_SideEffects.d.ts +14 -0
- package/dist/misra/sections/Section13_SideEffects.d.ts.map +1 -0
- package/dist/misra/sections/Section13_SideEffects.js +90 -0
- package/dist/misra/sections/Section13_SideEffects.js.map +1 -0
- package/dist/misra/sections/Section14_ControlStmtExprs.d.ts +8 -0
- package/dist/misra/sections/Section14_ControlStmtExprs.d.ts.map +1 -0
- package/{src/misra/sections/Section14_ControlStmtExprs.ts → dist/misra/sections/Section14_ControlStmtExprs.js} +8 -10
- package/dist/misra/sections/Section14_ControlStmtExprs.js.map +1 -0
- package/dist/misra/sections/Section15_ControlFlow.d.ts +14 -0
- package/dist/misra/sections/Section15_ControlFlow.d.ts.map +1 -0
- package/dist/misra/sections/Section15_ControlFlow.js +97 -0
- package/dist/misra/sections/Section15_ControlFlow.js.map +1 -0
- package/dist/misra/sections/Section16_SwitchStatements.d.ts +13 -0
- package/dist/misra/sections/Section16_SwitchStatements.d.ts.map +1 -0
- package/{src/misra/sections/Section16_SwitchStatements.ts → dist/misra/sections/Section16_SwitchStatements.js} +49 -74
- package/dist/misra/sections/Section16_SwitchStatements.js.map +1 -0
- package/dist/misra/sections/Section17_Functions.d.ts +9 -0
- package/dist/misra/sections/Section17_Functions.d.ts.map +1 -0
- package/{src/misra/sections/Section17_Functions.ts → dist/misra/sections/Section17_Functions.js} +10 -13
- package/dist/misra/sections/Section17_Functions.js.map +1 -0
- package/dist/misra/sections/Section18_PointersAndArrays.d.ts +13 -0
- package/dist/misra/sections/Section18_PointersAndArrays.d.ts.map +1 -0
- package/{src/misra/sections/Section18_PointersAndArrays.ts → dist/misra/sections/Section18_PointersAndArrays.js} +36 -40
- package/dist/misra/sections/Section18_PointersAndArrays.js.map +1 -0
- package/dist/misra/sections/Section19_OverlappingStorage.d.ts +8 -0
- package/dist/misra/sections/Section19_OverlappingStorage.d.ts.map +1 -0
- package/dist/misra/sections/Section19_OverlappingStorage.js +16 -0
- package/dist/misra/sections/Section19_OverlappingStorage.js.map +1 -0
- package/dist/misra/sections/Section20_PreprocessingDirectives.d.ts +8 -0
- package/dist/misra/sections/Section20_PreprocessingDirectives.d.ts.map +1 -0
- package/{src/misra/sections/Section20_PreprocessingDirectives.ts → dist/misra/sections/Section20_PreprocessingDirectives.js} +7 -9
- package/dist/misra/sections/Section20_PreprocessingDirectives.js.map +1 -0
- package/dist/misra/sections/Section21_StandardLibraries.d.ts +17 -0
- package/dist/misra/sections/Section21_StandardLibraries.d.ts.map +1 -0
- package/dist/misra/sections/Section21_StandardLibraries.js +54 -0
- package/dist/misra/sections/Section21_StandardLibraries.js.map +1 -0
- package/dist/misra/sections/Section2_UnusedCode.d.ts +9 -0
- package/dist/misra/sections/Section2_UnusedCode.d.ts.map +1 -0
- package/{src/misra/sections/Section2_UnusedCode.ts → dist/misra/sections/Section2_UnusedCode.js} +11 -16
- package/dist/misra/sections/Section2_UnusedCode.js.map +1 -0
- package/dist/misra/sections/Section3_Comments.d.ts +9 -0
- package/dist/misra/sections/Section3_Comments.d.ts.map +1 -0
- package/{src/misra/sections/Section3_Comments.ts → dist/misra/sections/Section3_Comments.js} +7 -10
- package/dist/misra/sections/Section3_Comments.js.map +1 -0
- package/dist/misra/sections/Section5_Identifiers.d.ts +12 -0
- package/dist/misra/sections/Section5_Identifiers.d.ts.map +1 -0
- package/dist/misra/sections/Section5_Identifiers.js +139 -0
- package/dist/misra/sections/Section5_Identifiers.js.map +1 -0
- package/dist/misra/sections/Section6_Types.d.ts +8 -0
- package/dist/misra/sections/Section6_Types.d.ts.map +1 -0
- package/dist/misra/sections/Section6_Types.js +23 -0
- package/dist/misra/sections/Section6_Types.js.map +1 -0
- package/dist/misra/sections/Section7_LiteralsConstants.d.ts +11 -0
- package/dist/misra/sections/Section7_LiteralsConstants.d.ts.map +1 -0
- package/{src/misra/sections/Section7_LiteralsConstants.ts → dist/misra/sections/Section7_LiteralsConstants.js} +18 -25
- package/dist/misra/sections/Section7_LiteralsConstants.js.map +1 -0
- package/dist/misra/sections/Section8_DeclarationsDefinitions.d.ts +15 -0
- package/dist/misra/sections/Section8_DeclarationsDefinitions.d.ts.map +1 -0
- package/{src/misra/sections/Section8_DeclarationsDefinitions.ts → dist/misra/sections/Section8_DeclarationsDefinitions.js} +18 -33
- package/dist/misra/sections/Section8_DeclarationsDefinitions.js.map +1 -0
- package/dist/misra/tests/utils.d.ts +10 -0
- package/dist/misra/tests/utils.d.ts.map +1 -0
- package/dist/misra/tests/utils.js +33 -0
- package/dist/misra/tests/utils.js.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.d.ts +15 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.d.ts.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.js +33 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.js.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.d.ts +16 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.d.ts.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.js +60 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.js.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.d.ts +19 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.d.ts.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.js +42 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.js.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.d.ts +43 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.d.ts.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.js +103 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.js.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.d.ts +26 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.d.ts.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.js +49 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.js.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.d.ts +26 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.d.ts.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.js +49 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.js.map +1 -0
- package/dist/rules/Section17_Functions/Rule_17_4_NonVoidReturn.d.ts +31 -0
- package/dist/rules/Section17_Functions/Rule_17_4_NonVoidReturn.d.ts.map +1 -0
- package/dist/rules/Section17_Functions/Rule_17_4_NonVoidReturn.js +71 -0
- package/dist/rules/Section17_Functions/Rule_17_4_NonVoidReturn.js.map +1 -0
- package/dist/rules/Section17_Functions/Rule_17_6_StaticArraySizeParam.d.ts +27 -0
- package/dist/rules/Section17_Functions/Rule_17_6_StaticArraySizeParam.d.ts.map +1 -0
- package/dist/rules/Section17_Functions/Rule_17_6_StaticArraySizeParam.js +58 -0
- package/dist/rules/Section17_Functions/Rule_17_6_StaticArraySizeParam.js.map +1 -0
- package/dist/rules/Section17_Functions/Rule_17_7_UnusedReturnValue.d.ts +28 -0
- package/dist/rules/Section17_Functions/Rule_17_7_UnusedReturnValue.d.ts.map +1 -0
- package/dist/rules/Section17_Functions/Rule_17_7_UnusedReturnValue.js +44 -0
- package/dist/rules/Section17_Functions/Rule_17_7_UnusedReturnValue.js.map +1 -0
- package/dist/rules/Section20-PreprocessingDirectives/Rule_20_2_InvalidHeaderFileName.d.ts +55 -0
- package/dist/rules/Section20-PreprocessingDirectives/Rule_20_2_InvalidHeaderFileName.d.ts.map +1 -0
- package/dist/rules/Section20-PreprocessingDirectives/Rule_20_2_InvalidHeaderFileName.js +108 -0
- package/dist/rules/Section20-PreprocessingDirectives/Rule_20_2_InvalidHeaderFileName.js.map +1 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.d.ts +43 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.d.ts.map +1 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.js +68 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.js.map +1 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.d.ts +29 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.d.ts.map +1 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.js +53 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.js.map +1 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.d.ts +15 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.d.ts.map +1 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.js +35 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.js.map +1 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_7_UnusedParameters.d.ts +13 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_7_UnusedParameters.d.ts.map +1 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_7_UnusedParameters.js +53 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_7_UnusedParameters.js.map +1 -0
- package/dist/rules/Section3_Comments/Rule_3_1_CommentSequences.d.ts +13 -0
- package/dist/rules/Section3_Comments/Rule_3_1_CommentSequences.d.ts.map +1 -0
- package/dist/rules/Section3_Comments/Rule_3_1_CommentSequences.js +32 -0
- package/dist/rules/Section3_Comments/Rule_3_1_CommentSequences.js.map +1 -0
- package/dist/rules/Section3_Comments/Rule_3_2_LineSplicing.d.ts +10 -0
- package/dist/rules/Section3_Comments/Rule_3_2_LineSplicing.d.ts.map +1 -0
- package/dist/rules/Section3_Comments/Rule_3_2_LineSplicing.js +26 -0
- package/dist/rules/Section3_Comments/Rule_3_2_LineSplicing.js.map +1 -0
- package/dist/rules/index.d.ts +20 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +38 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/tests/Section17_Functions/misra_config.json +10 -0
- package/dist/tests/utils.d.ts +10 -0
- package/dist/tests/utils.d.ts.map +1 -0
- package/dist/tests/utils.js +29 -0
- package/dist/tests/utils.js.map +1 -0
- package/dist/utils/utils.d.ts +102 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +202 -0
- package/dist/utils/utils.js.map +1 -0
- package/jest.config.js +6 -6
- package/package.json +44 -8
- package/src/MISRA.ts +276 -0
- package/src/MISRAContext.ts +84 -0
- package/src/MISRARule.ts +64 -0
- package/src/MISRATool.ts +95 -0
- package/src/main.ts +4 -33
- package/src/misra-old/MISRAAnalyser.ts +60 -0
- package/src/misra-old/MISRAAnalyserResult.ts +16 -0
- package/src/misra-old/sections/Section10_EssentialTypeModel.ts +377 -0
- package/src/misra-old/sections/Section11_PointerTypeConversions.ts +104 -0
- package/src/{misra → misra-old}/sections/Section12_Expressions.ts +7 -7
- package/src/{misra → misra-old}/sections/Section13_SideEffects.ts +15 -15
- package/src/misra-old/sections/Section14_ControlStmtExprs.ts +27 -0
- package/src/{misra → misra-old}/sections/Section15_ControlFlow.ts +10 -10
- package/src/misra-old/sections/Section18_PointersAndArrays.ts +108 -0
- package/src/{misra → misra-old}/sections/Section19_OverlappingStorage.ts +4 -4
- package/src/misra-old/sections/Section20_PreprocessingDirectives.ts +22 -0
- package/src/misra-old/sections/Section21_StandardLibraries.ts +99 -0
- package/src/{misra → misra-old}/sections/Section5_Identifiers.ts +16 -15
- package/src/{misra → misra-old}/sections/Section6_Types.ts +4 -4
- package/src/misra-old/sections/Section7_LiteralsConstants.ts +76 -0
- package/src/misra-old/sections/Section8_DeclarationsDefinitions.ts +133 -0
- package/src/rules/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.ts +41 -0
- package/src/rules/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.ts +70 -0
- package/src/rules/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.ts +41 -0
- package/src/rules/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.ts +113 -0
- package/src/rules/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.ts +61 -0
- package/src/rules/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.ts +57 -0
- package/src/rules/Section17_Functions/Rule_17_3_ImplicitFunction.ts +180 -0
- package/src/rules/Section17_Functions/Rule_17_4_NonVoidReturn.ts +91 -0
- package/src/rules/Section17_Functions/Rule_17_6_StaticArraySizeParam.ts +68 -0
- package/src/rules/Section17_Functions/Rule_17_7_UnusedReturnValue.ts +49 -0
- package/src/rules/Section20-PreprocessingDirectives/Rule_20_2_InvalidHeaderFileName.ts +120 -0
- package/src/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.ts +78 -0
- package/src/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.ts +61 -0
- package/src/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.ts +47 -0
- package/src/rules/Section2_UnusedCode/Rule_2_7_UnusedParameters.ts +67 -0
- package/src/rules/Section3_Comments/Rule_3_1_CommentSequences.ts +41 -0
- package/src/rules/Section3_Comments/Rule_3_2_LineSplicing.ts +36 -0
- package/src/rules/index.ts +44 -0
- package/src/tests/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.test.ts +55 -0
- package/src/tests/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.test.ts +70 -0
- package/src/tests/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.test.ts +128 -0
- package/src/tests/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.test.ts +132 -0
- package/src/tests/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.test.ts +146 -0
- package/src/tests/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.test.ts +102 -0
- package/src/tests/Section17_Functions/Rule_17_3_ImplicitFunctions.test.ts +79 -0
- package/src/tests/Section17_Functions/Rule_17_4_NonVoidReturn.test.ts +98 -0
- package/src/tests/Section17_Functions/Rule_17_4_NonVoidReturn_MissingConfig.test.ts +77 -0
- package/src/tests/Section17_Functions/Rule_17_6_StaticArraySizeParam.test.ts +36 -0
- package/src/tests/Section17_Functions/Rule_17_7_UnusedReturnValue.test.ts +44 -0
- package/src/tests/Section17_Functions/misra_config.json +19 -0
- package/src/tests/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.test.ts +175 -0
- package/src/tests/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.test.ts +219 -0
- package/src/tests/Section2_UnusedCode/Rule_2_6_UnusedLabels.test.ts +49 -0
- package/src/tests/Section2_UnusedCode/Rule_2_7_UnusedParameters.test.ts +55 -0
- package/src/tests/Section3_Comments/Rule_3_1_CommentSequences.test.ts +37 -0
- package/src/tests/utils.ts +51 -0
- package/src/utils/utils.ts +280 -0
- package/tsconfig.json +4 -3
- package/typedoc.config.js +1 -1
- package/CxxSources/lib.cpp +0 -3
- package/CxxSources/lib.h +0 -8
- package/CxxSources/main.cpp +0 -40
- package/TODO.md +0 -1
- package/consumer_order.txt +0 -2
- package/enum_integer_type.txt +0 -0
- package/is_temporary.txt +0 -0
- package/omp.txt +0 -0
- package/src/misra/passes/S16_SwitchStatementPass.ts +0 -168
- package/src/misra/passes/S3_CommentPass.ts +0 -40
- package/src/misra/sections/Section21_StandardLibraries.ts +0 -65
- package/src/misra/tests/S10_EssentialTypes.test.ts +0 -253
- package/src/misra/tests/S12_Expressions.test.ts +0 -43
- package/src/misra/tests/S13_SideEffects.test.ts +0 -77
- package/src/misra/tests/S15_ControlFlow.test.ts +0 -144
- package/src/misra/tests/S16_SwitchStatements.test.ts +0 -164
- package/src/misra/tests/S17_Functions.test.ts +0 -46
- package/src/misra/tests/S18_PointersArrays.test.ts +0 -167
- package/src/misra/tests/S19_OverlappingStorage.test.ts +0 -38
- package/src/misra/tests/S3_Comments.test.ts +0 -36
- package/src/misra/tests/S6_Types.test.ts +0 -36
- package/src/misra/tests/S7_LiteralsConstants.test.ts +0 -48
- package/src/misra/tests/utils.ts +0 -47
- package/types_with_templates.txt +0 -0
- /package/src/{misra → misra-old}/MISRAPass.ts +0 -0
- /package/src/{misra → misra-old}/MISRAPassResult.ts +0 -0
- /package/src/{misra → misra-old}/MISRAReporter.ts +0 -0
- /package/src/{misra → misra-old}/passes/S10_EssentialTypePass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S12_ExpressionPass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S13_SideEffectPass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S15_ControlFlowPass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S17_FunctionPass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S18_PointersArraysPass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S19_OverlappingStoragePass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S21_StandardLibPass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S5_IdentifierPass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S6_TypePass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S7_LiteralsConstantsPass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S8_DeclDefPass.ts +0 -0
@@ -1,168 +0,0 @@
|
|
1
|
-
import { LaraJoinPoint } from "@specs-feup/lara/api/LaraJoinPoint.js";
|
2
|
-
import MISRAPass from "../MISRAPass.js";
|
3
|
-
import { PreprocessingReqs } from "../MISRAReporter.js";
|
4
|
-
import { BinaryOp, Break, BuiltinType, Case, Expression, Joinpoint, Switch } from "@specs-feup/clava/api/Joinpoints.js";
|
5
|
-
import Fix from "@specs-feup/clava/api/clava/analysis/Fix.js";
|
6
|
-
import ClavaJoinPoints from "@specs-feup/clava/api/clava/ClavaJoinPoints.js";
|
7
|
-
|
8
|
-
export default class S16_SwitchStatementPass extends MISRAPass {
|
9
|
-
protected _preprocessingReqs: PreprocessingReqs[] = [];
|
10
|
-
private _wellFormedSwitch: boolean = false;
|
11
|
-
|
12
|
-
initRuleMapper(): void {
|
13
|
-
this._ruleMapper = new Map([
|
14
|
-
[1, this.r16_1_16_3_wellFormedSwitch.bind(this)],
|
15
|
-
[2, this.r16_2_topLevelSwitchLabels.bind(this)],
|
16
|
-
[4, this.r16_4_switchHasDefault.bind(this)],
|
17
|
-
[5, this.r16_5_defaultFirstOrLast.bind(this)],
|
18
|
-
[6, this.r16_6_noTwoClauses.bind(this)],
|
19
|
-
[7, this.r16_7_noEssentialBooleanInSwitch.bind(this)]
|
20
|
-
]);
|
21
|
-
}
|
22
|
-
|
23
|
-
matchJoinpoint($jp: LaraJoinPoint): boolean {
|
24
|
-
return $jp instanceof Switch || $jp instanceof Case;
|
25
|
-
}
|
26
|
-
|
27
|
-
private r16_1_16_3_wellFormedSwitch($startNode: Joinpoint) {
|
28
|
-
if (!($startNode instanceof Switch)) return;
|
29
|
-
this._wellFormedSwitch = true;
|
30
|
-
|
31
|
-
let foundStmt = false;
|
32
|
-
let first = true;
|
33
|
-
for (const child of $startNode.children[1].children) {
|
34
|
-
if (child instanceof Break) {;
|
35
|
-
foundStmt = false;
|
36
|
-
}
|
37
|
-
else if (child instanceof Case) {
|
38
|
-
first = false;
|
39
|
-
}
|
40
|
-
else {
|
41
|
-
foundStmt = true;
|
42
|
-
}
|
43
|
-
|
44
|
-
if (foundStmt && child instanceof Case) {
|
45
|
-
this.logMISRAError(`A break is missing before ${child.code}`);
|
46
|
-
this._wellFormedSwitch = false;
|
47
|
-
}
|
48
|
-
}
|
49
|
-
if (!($startNode.children[1].lastChild instanceof Break)) {
|
50
|
-
this.logMISRAError("A break is missing at the end of the switch statement.");
|
51
|
-
this._wellFormedSwitch = false;
|
52
|
-
}
|
53
|
-
}
|
54
|
-
|
55
|
-
private r16_2_topLevelSwitchLabels($startNode: Joinpoint) {
|
56
|
-
if (!($startNode instanceof Case)) return;
|
57
|
-
|
58
|
-
if (!($startNode.currentRegion instanceof Switch)) {
|
59
|
-
this.logMISRAError("A switch label can only be used if its enclosing compound statement is the switch statement itself.");
|
60
|
-
}
|
61
|
-
}
|
62
|
-
|
63
|
-
private r16_4_switchHasDefault($startNode: Joinpoint) {
|
64
|
-
if (!($startNode instanceof Switch && !$startNode.hasDefaultCase)) return;
|
65
|
-
|
66
|
-
this.logMISRAError("Switch statement is missing a default case.");
|
67
|
-
}
|
68
|
-
|
69
|
-
|
70
|
-
private r16_5_defaultFirstOrLast($startNode: Joinpoint) {
|
71
|
-
if (!($startNode instanceof Switch)) return;
|
72
|
-
|
73
|
-
for (let i = 0; i < $startNode.cases.length; i++) {
|
74
|
-
if ($startNode.cases[i].isDefault && (i == 0 || i == $startNode.cases.length-1)) {
|
75
|
-
return;
|
76
|
-
}
|
77
|
-
else if ($startNode.cases[i].isDefault) {
|
78
|
-
this.logMISRAError("The default case of a switch statement must be the first or last label.");
|
79
|
-
return;
|
80
|
-
}
|
81
|
-
}
|
82
|
-
}
|
83
|
-
|
84
|
-
private r16_6_noTwoClauses($startNode: Joinpoint) {
|
85
|
-
if (!($startNode instanceof Switch)) return;
|
86
|
-
this.dependsOn(1, $startNode);
|
87
|
-
if (this._wellFormedSwitch === false) return;
|
88
|
-
|
89
|
-
let clauses = 0;
|
90
|
-
for (const child of $startNode.children[1].children) {
|
91
|
-
if (child instanceof Break) {
|
92
|
-
clauses++;
|
93
|
-
}
|
94
|
-
}
|
95
|
-
|
96
|
-
if (clauses <= 2) {
|
97
|
-
this.logMISRAError("Switch statements should have more than two clauses.", new Fix(
|
98
|
-
$startNode,
|
99
|
-
(switchStmt: Joinpoint) => {
|
100
|
-
const switchJp = switchStmt as Switch;
|
101
|
-
let firstClauseExpr: Expression | undefined = undefined;
|
102
|
-
let secondClauseExpr: Expression | undefined = undefined;
|
103
|
-
let firstClause: Joinpoint[] = [];
|
104
|
-
let secondClause: Joinpoint[] = [];
|
105
|
-
let currClauseExpr: Expression | undefined = undefined;
|
106
|
-
let currClause: Joinpoint[] = [];
|
107
|
-
let clauseHasDefault: boolean = false;
|
108
|
-
let filledFirstClause: boolean = false;
|
109
|
-
const newVar = ClavaJoinPoints.varDecl("switchToIf_" + switchJp.astId, switchJp.condition);
|
110
|
-
switchJp.insertBefore(newVar.stmt);
|
111
|
-
for (const child of switchStmt.children[1].children) {
|
112
|
-
if (child instanceof Case) {
|
113
|
-
let tempOp: BinaryOp;
|
114
|
-
if (child.isDefault) {
|
115
|
-
clauseHasDefault = true;
|
116
|
-
continue;
|
117
|
-
}
|
118
|
-
else if (child.values.length === 1) {
|
119
|
-
tempOp = ClavaJoinPoints.binaryOp("eq", newVar.varref(), child.values[0]);
|
120
|
-
}
|
121
|
-
else {
|
122
|
-
tempOp = ClavaJoinPoints.binaryOp("l_or", ClavaJoinPoints.binaryOp("ge", newVar.varref(), child.values[0]), ClavaJoinPoints.binaryOp("le", newVar.varref(), child.values[1]));
|
123
|
-
}
|
124
|
-
currClauseExpr = currClauseExpr ? ClavaJoinPoints.binaryOp("l_or", currClauseExpr, tempOp) : tempOp;
|
125
|
-
}
|
126
|
-
else if (child instanceof Break) {
|
127
|
-
if (clauseHasDefault) {
|
128
|
-
secondClause = currClause;
|
129
|
-
secondClauseExpr = undefined;
|
130
|
-
}
|
131
|
-
else if (filledFirstClause) {
|
132
|
-
secondClause = currClause;
|
133
|
-
secondClauseExpr = currClauseExpr;
|
134
|
-
}
|
135
|
-
else {
|
136
|
-
firstClause = currClause;
|
137
|
-
firstClauseExpr = currClauseExpr;
|
138
|
-
filledFirstClause = true;
|
139
|
-
}
|
140
|
-
clauseHasDefault = false;
|
141
|
-
currClause = [];
|
142
|
-
currClauseExpr = undefined;
|
143
|
-
}
|
144
|
-
else {
|
145
|
-
currClause.push(child);
|
146
|
-
}
|
147
|
-
}
|
148
|
-
|
149
|
-
const elseStmt = secondClauseExpr ? ClavaJoinPoints.ifStmt(secondClauseExpr, ClavaJoinPoints.scope(...secondClause)) : ClavaJoinPoints.scope(...secondClause);
|
150
|
-
switchJp.replaceWith(ClavaJoinPoints.ifStmt(firstClauseExpr ?? "", ClavaJoinPoints.scope(...firstClause), elseStmt));
|
151
|
-
}
|
152
|
-
));
|
153
|
-
}
|
154
|
-
}
|
155
|
-
|
156
|
-
private r16_7_noEssentialBooleanInSwitch($startNode: Joinpoint) { //UNFINISHED, can have transformation
|
157
|
-
if (!($startNode instanceof Switch)) return;
|
158
|
-
this.dependsOn(1, $startNode);
|
159
|
-
if (this._wellFormedSwitch === false) return;
|
160
|
-
|
161
|
-
if ($startNode.condition.type.desugarAll instanceof BuiltinType && $startNode.condition.type.desugarAll.builtinKind === "Bool") {
|
162
|
-
this.logMISRAError("The controlling expression of a switch statement must not have essentially boolean type.");
|
163
|
-
}
|
164
|
-
}
|
165
|
-
|
166
|
-
protected _name: string = "Switch statements";
|
167
|
-
|
168
|
-
}
|
@@ -1,40 +0,0 @@
|
|
1
|
-
import { LaraJoinPoint } from "@specs-feup/lara/api/LaraJoinPoint.js";
|
2
|
-
import MISRAPass from "../MISRAPass.js";
|
3
|
-
import { PreprocessingReqs } from "../MISRAReporter.js";
|
4
|
-
import { Comment, Joinpoint } from "@specs-feup/clava/api/Joinpoints.js";
|
5
|
-
import Fix from "@specs-feup/clava/api/clava/analysis/Fix.js";
|
6
|
-
|
7
|
-
export default class S3_CommentPass extends MISRAPass {
|
8
|
-
protected _preprocessingReqs: PreprocessingReqs[] = [];
|
9
|
-
|
10
|
-
initRuleMapper(): void {
|
11
|
-
this._ruleMapper = new Map([
|
12
|
-
[3, this.r3_1_fixComments.bind(this)]
|
13
|
-
]);
|
14
|
-
}
|
15
|
-
|
16
|
-
matchJoinpoint($jp: LaraJoinPoint): boolean {
|
17
|
-
return true;
|
18
|
-
}
|
19
|
-
|
20
|
-
private static removeCommentSequences(str: string) {
|
21
|
-
return str.replace(/(\/\/|\/\*)/g, '');
|
22
|
-
}
|
23
|
-
|
24
|
-
private r3_1_fixComments($startNode: Joinpoint) { //inlines
|
25
|
-
if ($startNode instanceof Comment && /(\/\/|\/\*)/g.test($startNode.text)) {
|
26
|
-
this.logMISRAError(`Comment ${$startNode.text} contains invalid character sequences.`, new Fix(
|
27
|
-
$startNode,
|
28
|
-
$jp => ($jp as Comment).setText(S3_CommentPass.removeCommentSequences($startNode.text))
|
29
|
-
));
|
30
|
-
}
|
31
|
-
$startNode.inlineComments.filter(comment => /(\/\/|\/\*)/g.test(comment.text)).forEach(comment => {
|
32
|
-
this.logMISRAError(`Comment ${comment.text} contains invalid character sequences.`, new Fix(
|
33
|
-
$startNode,
|
34
|
-
$jp => ($jp as Comment).setText(S3_CommentPass.removeCommentSequences(comment.text))
|
35
|
-
));
|
36
|
-
});
|
37
|
-
}
|
38
|
-
|
39
|
-
protected _name: string = "Comments";
|
40
|
-
}
|
@@ -1,65 +0,0 @@
|
|
1
|
-
import Query from "@specs-feup/lara/api/weaver/Query.js";
|
2
|
-
import { Call, FileJp, Include, Joinpoint, Program } from "@specs-feup/clava/api/Joinpoints.js";
|
3
|
-
import MISRAAnalyser from "../MISRAAnalyser.js";
|
4
|
-
|
5
|
-
export default class Section21_StandardLibraries extends MISRAAnalyser {
|
6
|
-
ruleMapper: Map<number, (jp: FileJp | Program) => void>;
|
7
|
-
|
8
|
-
constructor(rules: number[]) {
|
9
|
-
super(rules);
|
10
|
-
this.ruleMapper = new Map([
|
11
|
-
[3, this.r21_3_noDynamicAllocation.bind(this)],
|
12
|
-
[4, this.r21_4_noSetjmpUsage.bind(this)],
|
13
|
-
[5, this.r21_5_noSignalUsage.bind(this)],
|
14
|
-
[6, this.r21_6_noStandardIO.bind(this)],
|
15
|
-
[7, this.r21_7_noStringFunctions.bind(this)],
|
16
|
-
[8, this.r21_8_noSysFunctions.bind(this)],
|
17
|
-
[9, this.r21_9_noStdAlgos.bind(this)],
|
18
|
-
[10, this.r21_10_noDateUsage.bind(this)],
|
19
|
-
[11, this.r21_11_noTgmathUsage.bind(this)],
|
20
|
-
[12, this.r21_12_noFenvExceptions.bind(this)]
|
21
|
-
]);
|
22
|
-
}
|
23
|
-
|
24
|
-
private r21_3_noDynamicAllocation($startNode: Joinpoint) {
|
25
|
-
Query.searchFrom($startNode, Call, {name: /(malloc|realloc|calloc|free)/}).get().forEach(call => this.logMISRAError(call, "Use of memory allocation functions provided by <stdlib.h> is not allowed."), this);
|
26
|
-
}
|
27
|
-
|
28
|
-
private r21_4_noSetjmpUsage($startNode: Joinpoint) {
|
29
|
-
Query.searchFrom($startNode, Include, {name: "setjmp.h", isAngled: true}).get().forEach(include => this.logMISRAError(include, "Use of <setjmp.h> is not allowed."), this);
|
30
|
-
}
|
31
|
-
|
32
|
-
private r21_5_noSignalUsage($startNode: Joinpoint) {
|
33
|
-
Query.searchFrom($startNode, Include, {name: "signal.h", isAngled: true}).get().forEach(include => this.logMISRAError(include, "Use of <setjmp.h> is not allowed."), this);
|
34
|
-
}
|
35
|
-
|
36
|
-
private r21_6_noStandardIO($startNode: Joinpoint) {
|
37
|
-
Query.searchFrom($startNode, Include, {name: /(stdio.h|wchar.h)/}).get().forEach(include => this.logMISRAError(include, "Use of the standard library I/O functions provided by <stdio.h> and <wchar.h> is not allowed."), this);
|
38
|
-
}
|
39
|
-
|
40
|
-
//how to avoid triggering errors for functions with the same name?
|
41
|
-
private r21_7_noStringFunctions($startNode: Joinpoint) {
|
42
|
-
Query.searchFrom($startNode, Call, {name: /(atoi|atof|atol|atoll)/}).get().forEach(call => this.logMISRAError(call, `Use of function ${call.signature} is not allowed.`), this);
|
43
|
-
}
|
44
|
-
|
45
|
-
private r21_8_noSysFunctions($startNode: Joinpoint) {
|
46
|
-
Query.searchFrom($startNode, Call, {name: /(system|abort|exit|getenv)/}).get().forEach(call => this.logMISRAError(call, `Use of function ${call.signature} is not allowed.`), this);
|
47
|
-
}
|
48
|
-
|
49
|
-
private r21_9_noStdAlgos($startNode: Joinpoint) {
|
50
|
-
Query.searchFrom($startNode, Call, {name: /(qsort|bsearch)/}).get().forEach(call => this.logMISRAError(call, `Use of function ${call.signature} is not allowed.`), this);
|
51
|
-
}
|
52
|
-
|
53
|
-
private r21_10_noDateUsage($startNode: Joinpoint) {
|
54
|
-
Query.searchFrom($startNode, Include, {name: "time.h", isAngled: true}).get().forEach(include => this.logMISRAError(include, "Use of <time.h> is not allowed."), this);
|
55
|
-
Query.searchFrom($startNode, Call, {name: "wcsftime"}).get().forEach(call => this.logMISRAError(call, "Identifier 'wcsftime' shall not be used."), this);
|
56
|
-
}
|
57
|
-
|
58
|
-
private r21_11_noTgmathUsage($startNode: Joinpoint) {
|
59
|
-
Query.searchFrom($startNode, Include, {name: "tgmath.h", isAngled: true}).get().forEach(include => this.logMISRAError(include, "Use of <tgmath.h> is not allowed."), this);
|
60
|
-
}
|
61
|
-
|
62
|
-
private r21_12_noFenvExceptions($startNode: Joinpoint) {
|
63
|
-
Query.searchFrom($startNode, Call, {name : /(feclearexcept|fegetexceptflag|feraiseexcept|fesetexceptflag|fetestexcept)/}).get().forEach(call => this.logMISRAError(call, `Use of function ${call.signature} is not allowed`), this);
|
64
|
-
}
|
65
|
-
}
|
@@ -1,253 +0,0 @@
|
|
1
|
-
import MISRAReporter from "../MISRAReporter.js";
|
2
|
-
import S10_EssentialTypePass from "../passes/S10_EssentialTypePass.js";
|
3
|
-
import Query from "@specs-feup/lara/api/weaver/Query.js";
|
4
|
-
import { FileJp, Joinpoint } from "@specs-feup/clava/api/Joinpoints.js";
|
5
|
-
import { expectNumberOfErrors, registerSourceCode, TestFile } from "./utils.js";
|
6
|
-
|
7
|
-
const passingOperands = `void goodOperands() {
|
8
|
-
bool bla, blb;
|
9
|
-
unsigned u8a, u8b, u16b;
|
10
|
-
char cha, chb;
|
11
|
-
enum ena {R,G,B} ena;
|
12
|
-
enum {K1=5};
|
13
|
-
int a1,s8a,s16b,s8b;
|
14
|
-
float f32a, f32b;
|
15
|
-
|
16
|
-
bla && blb;
|
17
|
-
bla ? u8a : u8b;
|
18
|
-
cha - chb;
|
19
|
-
cha > chb;
|
20
|
-
ena > a1;
|
21
|
-
K1 * s8a; /* Compliant as K1 from anonymous enum */
|
22
|
-
s8a + s16b;
|
23
|
-
-( s8a ) * s8b;
|
24
|
-
s8a > 0;
|
25
|
-
--s16b;
|
26
|
-
u8a + u16b;
|
27
|
-
u8a & 2U;
|
28
|
-
u8a > 0U;
|
29
|
-
u8a << 2U;
|
30
|
-
u8a << 1; /* Compliant by exception */
|
31
|
-
f32a + f32b;
|
32
|
-
f32a > 0.0;
|
33
|
-
|
34
|
-
'0' + u8a; /* Convert u8a to digit */
|
35
|
-
s8a + '0'; /* Convert s8a to digit */
|
36
|
-
cha - '0'; /* Convert cha to ordinal */
|
37
|
-
'0' - s8a; /* Convert -s8a to digit */
|
38
|
-
}`;
|
39
|
-
|
40
|
-
const failingOperands = `void badOperands() {
|
41
|
-
char cha, chb;
|
42
|
-
enum ena {R,G,B} ena;
|
43
|
-
bool bla, blb;
|
44
|
-
int a1,a2,s8a;
|
45
|
-
unsigned u8a;
|
46
|
-
float f32a;
|
47
|
-
|
48
|
-
cha && bla ; /* Rationale 2 - char type used as a Boolean value */
|
49
|
-
ena ? a1 : a2 ; /* Rationale 2 - enum type used as a Boolean value */
|
50
|
-
s8a && bla ; /* Rationale 2 - signed type used as a Boolean value */
|
51
|
-
u8a ? a1 : a2 ; /* Rationale 2 - unsigned type used as a Boolean value */
|
52
|
-
f32a && bla ; /* Rationale 2 - floating type used as a Boolean value */
|
53
|
-
bla * blb ; /* Rationale 3 - Boolean used as a numeric value */
|
54
|
-
bla > blb ; /* Rationale 3 - Boolean used as a numeric value */
|
55
|
-
cha & chb ; /* Rationale 4 - char type used as a numeric value */
|
56
|
-
cha << 1 ; /* Rationale 4 - char type used as a numeric value */
|
57
|
-
ena * a1 ; /* Rationale 5 - enum type used in arithmetic operation */
|
58
|
-
s8a & 2 ; /* Rationale 6 - bitwise operation on signed type */
|
59
|
-
50 << 3U ; /* Rationale 6 - shift operation on signed type */
|
60
|
-
u8a << s8a ; /* Rationale 7 - shift magnitude uses signed type */
|
61
|
-
u8a << -1 ; /* Rationale 7 - shift magnitude uses signed type */
|
62
|
-
-u8a ; /* Rationale 8 - unary minus on unsigned type */
|
63
|
-
|
64
|
-
int s16a;
|
65
|
-
s16a - 'a';
|
66
|
-
'0' + f32a;
|
67
|
-
cha + ':';
|
68
|
-
cha - ena;
|
69
|
-
}`;
|
70
|
-
|
71
|
-
const operandFiles: TestFile[] = [
|
72
|
-
{name: "badoperands.cpp", code: failingOperands},
|
73
|
-
{name: "goodoperands.cpp", code: passingOperands},
|
74
|
-
];
|
75
|
-
|
76
|
-
const passingAssignments = `void use_uint16(unsigned int a) {
|
77
|
-
return;
|
78
|
-
}
|
79
|
-
|
80
|
-
void goodAssignments() {
|
81
|
-
unsigned char u8b, u8c, u8d;
|
82
|
-
enum ena {R,G,B} ena;
|
83
|
-
enum {A1, K1};
|
84
|
-
int s8a;
|
85
|
-
char cha;
|
86
|
-
|
87
|
-
unsigned int u8a = 0; /* By exception */
|
88
|
-
bool flag = ( bool ) 0;
|
89
|
-
bool set = true; /* true is essentially Boolean */
|
90
|
-
bool get = ( u8b > u8c );
|
91
|
-
s8a = K1; /* Constant value fits */
|
92
|
-
u8a = 2; /* By exception */
|
93
|
-
//u8a = 2 * 24; /* By exception */ <-- DO THIS WHEN ISINTEGERCONSTANTEXPR IS AVAILABLE
|
94
|
-
u8a = ( unsigned int ) s8a; /* Cast gives same essential type */
|
95
|
-
|
96
|
-
unsigned int u32a;
|
97
|
-
unsigned char u16a, u16b;
|
98
|
-
u32a = u16a; /* Assignment to a wider essential type */
|
99
|
-
u32a = 2U + 125U; /* Assignment to a wider essential type */
|
100
|
-
use_uint16 ( u8a ); /* Assignment to a wider essential type */
|
101
|
-
use_uint16 ( u8a + u16b ); /* Assignment to same essential type */
|
102
|
-
}`;
|
103
|
-
|
104
|
-
const failingAssignments = `void use_uint32(unsigned int a) {
|
105
|
-
return;
|
106
|
-
}
|
107
|
-
|
108
|
-
void use_uint16(unsigned short a) {
|
109
|
-
return;
|
110
|
-
}
|
111
|
-
|
112
|
-
unsigned char foo1 ( unsigned int x )
|
113
|
-
{
|
114
|
-
return x; /* uint16_t to uint8_t */
|
115
|
-
}
|
116
|
-
|
117
|
-
void badAssignments() {
|
118
|
-
char cha;
|
119
|
-
unsigned u8b, u8c;
|
120
|
-
int s32a;
|
121
|
-
short u16a;
|
122
|
-
long u32a;
|
123
|
-
|
124
|
-
unsigned u8a = 1.0f; /* unsigned and floating */
|
125
|
-
bool bla = 0; /* boolean and signed */
|
126
|
-
cha = 7; /* character and signed */
|
127
|
-
u8a = 'a'; /* unsigned and character */
|
128
|
-
u8b = 1 - 2; /* unsigned and signed */
|
129
|
-
//u8c += 'a'; /* u8c = u8c + 'a' assigns character to unsigned */
|
130
|
-
use_uint32 ( s32a ); /* signed and unsigned */
|
131
|
-
//s8a = K2; /* Constant value does not fit */
|
132
|
-
u16a = u32a; /* uint32_t to uint16_t */
|
133
|
-
use_uint16 ( u32a ); /* uint32_t to uint16_t */
|
134
|
-
}`;
|
135
|
-
|
136
|
-
const assignmentFiles: TestFile[] = [
|
137
|
-
{name: "badassignments.cpp", code: failingAssignments},
|
138
|
-
{name: "goodassignments.cpp", code: passingAssignments}
|
139
|
-
];
|
140
|
-
|
141
|
-
const failingCasts = `void badCasts() {
|
142
|
-
enum enuma {R,G,B} ena;
|
143
|
-
enum enumc {C,M,Y} enc;
|
144
|
-
|
145
|
-
//( bool ) false; /* Compliant - 'false' is essentially Boolean */
|
146
|
-
//( int ) 3U; /* Compliant */
|
147
|
-
//( bool ) 0; /* Compliant - by exception */
|
148
|
-
( bool ) 3U; /* Non-compliant */
|
149
|
-
//( int ) ena; /* Compliant */
|
150
|
-
( enum enuma ) 3; /* Non-compliant */
|
151
|
-
//( char ) enc; /* Compliant */
|
152
|
-
}`;
|
153
|
-
|
154
|
-
const passingCasts = `void goodCasts() {
|
155
|
-
enum enuma {R,G,B} ena;
|
156
|
-
enum enumc {C,M,Y} enc;
|
157
|
-
|
158
|
-
( bool ) false; /* Compliant - 'false' is essentially Boolean */
|
159
|
-
( int ) 3U; /* Compliant */
|
160
|
-
( bool ) 0; /* Compliant - by exception */
|
161
|
-
//( bool ) 3U; /* Non-compliant */
|
162
|
-
( int ) ena; /* Compliant */
|
163
|
-
//( enum enuma ) 3; /* Non-compliant */
|
164
|
-
( char ) enc; /* Compliant */
|
165
|
-
}`;
|
166
|
-
|
167
|
-
const castFiles: TestFile[] = [
|
168
|
-
{name: "goodcasts.cpp", code: passingCasts},
|
169
|
-
{name: "badcasts.cpp", code: failingCasts}
|
170
|
-
];
|
171
|
-
|
172
|
-
const passingComposites = `void goodComposites() {
|
173
|
-
unsigned short u16a,u16b,u16c;
|
174
|
-
unsigned long u32a,u32b;
|
175
|
-
signed long s32a;
|
176
|
-
|
177
|
-
u16c = u16a + u16b; /* Same essential type */
|
178
|
-
u32a = ( unsigned long ) u16a + u16b; /* Cast causes addition in uint32_t */
|
179
|
-
|
180
|
-
( unsigned short ) ( u32a + u32b ); /* Compliant */
|
181
|
-
( unsigned long ) s32a; /* Compliant - s32a is not composite */
|
182
|
-
}`;
|
183
|
-
|
184
|
-
const failingComposites = `void badComposites() {
|
185
|
-
unsigned short u16a,u16b,u16c;
|
186
|
-
unsigned long u32a,u32b;
|
187
|
-
signed long s32a,s32b;
|
188
|
-
|
189
|
-
u32a = u16a + u16b; /* Implicit conversion on assignment */
|
190
|
-
( unsigned short ) ( s32a + s32b );
|
191
|
-
//( unsigned long ) ( u16a + u16b ); WIDTH PROBLEMS
|
192
|
-
}`;
|
193
|
-
|
194
|
-
const compositeFiles: TestFile[] = [
|
195
|
-
{name: "goodcomposites.cpp", code: passingComposites},
|
196
|
-
{name: "badcomposites.cpp", code: failingComposites}
|
197
|
-
]
|
198
|
-
|
199
|
-
describe("Essential type model: operands", () => {
|
200
|
-
const reporter = new MISRAReporter();
|
201
|
-
const pass = new S10_EssentialTypePass(true, [1, 2]);
|
202
|
-
registerSourceCode(operandFiles);
|
203
|
-
|
204
|
-
it("should pass", () => {
|
205
|
-
expectNumberOfErrors(reporter, pass, 0, Query.search(FileJp, {name: "goodoperands.cpp"}).first() as Joinpoint);
|
206
|
-
});
|
207
|
-
|
208
|
-
it("should fail", () => {
|
209
|
-
expectNumberOfErrors(reporter, pass, 24, Query.search(FileJp, {name: "badoperands.cpp"}).first() as Joinpoint);
|
210
|
-
});
|
211
|
-
});
|
212
|
-
|
213
|
-
describe("Essential type model: assignments", () => {
|
214
|
-
const reporter = new MISRAReporter();
|
215
|
-
const pass = new S10_EssentialTypePass(true, [3]);
|
216
|
-
registerSourceCode(assignmentFiles);
|
217
|
-
|
218
|
-
it("should pass", () => {
|
219
|
-
expectNumberOfErrors(reporter, pass, 0, Query.search(FileJp, {name: "goodassignments.cpp"}).first() as Joinpoint);
|
220
|
-
});
|
221
|
-
|
222
|
-
it("should fail", () => { //SHOULD BE 9 BUT DOESNT WORK FOR RETURN STMTS
|
223
|
-
expectNumberOfErrors(reporter, pass, 8, Query.search(FileJp, {name: "badassignments.cpp"}).first() as Joinpoint);
|
224
|
-
});
|
225
|
-
});
|
226
|
-
|
227
|
-
describe("Essential type model: casts", () => {
|
228
|
-
const reporter = new MISRAReporter();
|
229
|
-
const pass = new S10_EssentialTypePass(true, [5]);
|
230
|
-
registerSourceCode(castFiles);
|
231
|
-
|
232
|
-
it("should pass", () => {
|
233
|
-
expectNumberOfErrors(reporter, pass, 0, Query.search(FileJp, {name: "goodcasts.cpp"}).first() as Joinpoint);
|
234
|
-
});
|
235
|
-
|
236
|
-
it("should fail", () => { //SHOULD BE 9 BUT DOESNT WORK FOR RETURN STMTS
|
237
|
-
expectNumberOfErrors(reporter, pass, 2, Query.search(FileJp, {name: "badcasts.cpp"}).first() as Joinpoint);
|
238
|
-
});
|
239
|
-
});
|
240
|
-
|
241
|
-
describe("Essential type model: composite expressions", () => {
|
242
|
-
const reporter = new MISRAReporter();
|
243
|
-
const pass = new S10_EssentialTypePass(true, [6,8]);
|
244
|
-
registerSourceCode(compositeFiles);
|
245
|
-
|
246
|
-
it("should pass", () => {
|
247
|
-
expectNumberOfErrors(reporter, pass, 0, Query.search(FileJp, {name: "goodcomposites.cpp"}).first() as Joinpoint);
|
248
|
-
});
|
249
|
-
|
250
|
-
it("should fail", () => { //SHOULD BE 9 BUT DOESNT WORK FOR RETURN STMTS
|
251
|
-
expectNumberOfErrors(reporter, pass, 2, Query.search(FileJp, {name: "badcomposites.cpp"}).first() as Joinpoint);
|
252
|
-
});
|
253
|
-
});
|
@@ -1,43 +0,0 @@
|
|
1
|
-
import MISRAReporter from "../MISRAReporter.js";
|
2
|
-
import S12_ExpressionPass from "../passes/S12_ExpressionPass.js";
|
3
|
-
import Query from "@specs-feup/lara/api/weaver/Query.js";
|
4
|
-
import { FileJp, Joinpoint } from "@specs-feup/clava/api/Joinpoints.js";
|
5
|
-
import { expectNumberOfErrors, registerSourceCode, TestFile } from "./utils.js";
|
6
|
-
|
7
|
-
const passingCode = `int main(int argc, char *argv[]) {
|
8
|
-
int x, y, z;
|
9
|
-
x = 2;
|
10
|
-
y = 3;
|
11
|
-
|
12
|
-
x = x + (y * z);
|
13
|
-
|
14
|
-
return 0;
|
15
|
-
}`;
|
16
|
-
|
17
|
-
const failingCode = `int test(int argc, char *argv[]) {
|
18
|
-
int x, y, z;
|
19
|
-
x = 2, y = 3;
|
20
|
-
|
21
|
-
x = x + y * z;
|
22
|
-
|
23
|
-
return 0;
|
24
|
-
}`;
|
25
|
-
|
26
|
-
const files: TestFile[] = [
|
27
|
-
{name: "bad.cpp", code: failingCode},
|
28
|
-
{name: "good.cpp", code: passingCode}
|
29
|
-
]
|
30
|
-
|
31
|
-
describe("Expressions", () => {
|
32
|
-
const reporter = new MISRAReporter();
|
33
|
-
const pass = new S12_ExpressionPass(true, [1, 3]);
|
34
|
-
registerSourceCode(files);
|
35
|
-
|
36
|
-
it("should pass", () => {
|
37
|
-
expectNumberOfErrors(reporter, pass, 0, Query.search(FileJp, {name: "good.cpp"}).first() as Joinpoint);
|
38
|
-
});
|
39
|
-
|
40
|
-
it("should fail", () => {
|
41
|
-
expectNumberOfErrors(reporter, pass, 2, Query.search(FileJp, {name: "bad.cpp"}).first() as Joinpoint);
|
42
|
-
});
|
43
|
-
});
|
@@ -1,77 +0,0 @@
|
|
1
|
-
import MISRAReporter from "../MISRAReporter.js";
|
2
|
-
import S13_SideEffectPass from "../passes/S13_SideEffectPass.js";
|
3
|
-
import Query from "@specs-feup/lara/api/weaver/Query.js";
|
4
|
-
import { FileJp, Joinpoint } from "@specs-feup/clava/api/Joinpoints.js";
|
5
|
-
import { expectNumberOfErrors, registerSourceCode, TestFile } from "./utils.js";
|
6
|
-
|
7
|
-
const passingCode = `int v1;
|
8
|
-
void f1 ( void )
|
9
|
-
{
|
10
|
-
int a[ 2 ] = { v1, 0 };
|
11
|
-
}
|
12
|
-
int x = 0u;
|
13
|
-
extern void p ( int a[ 2 ] );
|
14
|
-
void h1 ( void )
|
15
|
-
{
|
16
|
-
/* Non-compliant - two side effects */
|
17
|
-
p ( ( int[ 2 ] ) { x, x } );
|
18
|
-
}
|
19
|
-
|
20
|
-
void foo1() {
|
21
|
-
unsigned u8a, u8b;
|
22
|
-
int a[4], x, y, s;
|
23
|
-
u8a = ( 1u == 1u ) ? 0u : u8b;
|
24
|
-
u8b++;
|
25
|
-
s = sizeof ( 5 );
|
26
|
-
if ( ( x == 0u ) || ( v1 == 1u ) )
|
27
|
-
{
|
28
|
-
}
|
29
|
-
}`;
|
30
|
-
|
31
|
-
const failingCode = `volatile int v1;
|
32
|
-
void f ( void )
|
33
|
-
{
|
34
|
-
/* Non-compliant - volatile access is persistent side effect */
|
35
|
-
int a[ 2 ] = { v1, 0 };
|
36
|
-
}
|
37
|
-
int x = 0u;
|
38
|
-
extern void p ( int a[ 2 ] );
|
39
|
-
void h ( void )
|
40
|
-
{
|
41
|
-
/* Non-compliant - two side effects */
|
42
|
-
p ( ( int[ 2 ] ) { x++, x++ } );
|
43
|
-
}
|
44
|
-
|
45
|
-
int bar() {
|
46
|
-
return 5;
|
47
|
-
}
|
48
|
-
|
49
|
-
void foo() {
|
50
|
-
unsigned u8a, u8b;
|
51
|
-
int a[4], x, y, s;
|
52
|
-
u8a = ( 1u == 1u ) ? 0u : u8b++;
|
53
|
-
s = sizeof ( bar() ); /* Non-compliant */
|
54
|
-
a[ x ] = a[ x = y ];
|
55
|
-
if ( ( x == 0u ) || ( v1 == 1u ) )
|
56
|
-
{
|
57
|
-
}
|
58
|
-
}`;
|
59
|
-
|
60
|
-
const files: TestFile[] = [
|
61
|
-
{name: "bad.cpp", code: failingCode},
|
62
|
-
{name: "good.cpp", code: passingCode}
|
63
|
-
]
|
64
|
-
|
65
|
-
describe("Expressions", () => {
|
66
|
-
const reporter = new MISRAReporter();
|
67
|
-
const pass = new S13_SideEffectPass(true, [1, 3, 4, 5, 6]);
|
68
|
-
registerSourceCode(files);
|
69
|
-
|
70
|
-
it("should pass", () => {
|
71
|
-
expectNumberOfErrors(reporter, pass, 0, Query.search(FileJp, {name: "good.cpp"}).first() as Joinpoint);
|
72
|
-
});
|
73
|
-
|
74
|
-
it("should fail", () => {
|
75
|
-
expectNumberOfErrors(reporter, pass, 8, Query.search(FileJp, {name: "bad.cpp"}).first() as Joinpoint);
|
76
|
-
});
|
77
|
-
});
|