@specs-feup/clava-misra 1.0.2 → 1.0.4
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 +8 -0
- package/README.md +53 -19
- package/dist/MISRA.d.ts +28 -10
- package/dist/MISRA.d.ts.map +1 -1
- package/dist/MISRA.js +30 -10
- package/dist/MISRA.js.map +1 -1
- package/dist/MISRAContext.d.ts +65 -11
- package/dist/MISRAContext.d.ts.map +1 -1
- package/dist/MISRAContext.js +131 -35
- package/dist/MISRAContext.js.map +1 -1
- package/dist/MISRARule.d.ts +38 -25
- package/dist/MISRARule.d.ts.map +1 -1
- package/dist/MISRARule.js +40 -18
- package/dist/MISRARule.js.map +1 -1
- package/dist/MISRATool.d.ts +46 -5
- package/dist/MISRATool.d.ts.map +1 -1
- package/dist/MISRATool.js +118 -45
- package/dist/MISRATool.js.map +1 -1
- package/dist/StandardGuideline.d.ts +22 -0
- package/dist/StandardGuideline.d.ts.map +1 -0
- package/dist/StandardGuideline.js +12 -0
- package/dist/StandardGuideline.js.map +1 -0
- package/dist/ast-visitor/Context.d.ts +11 -0
- package/dist/ast-visitor/Context.d.ts.map +1 -0
- package/dist/ast-visitor/Context.js +15 -0
- package/dist/ast-visitor/Context.js.map +1 -0
- package/dist/ast-visitor/Visit.d.ts +23 -0
- package/dist/ast-visitor/Visit.d.ts.map +1 -0
- package/dist/ast-visitor/Visit.js +18 -0
- package/dist/ast-visitor/Visit.js.map +1 -0
- package/dist/ast-visitor/VisitWithContext.d.ts +32 -0
- package/dist/ast-visitor/VisitWithContext.d.ts.map +1 -0
- package/dist/ast-visitor/VisitWithContext.js +26 -0
- package/dist/ast-visitor/VisitWithContext.js.map +1 -0
- package/dist/main.js +1 -2
- package/dist/main.js.map +1 -1
- package/dist/rules/Section13_SideEffects/Rule_13_6_SafeSizeOfOperand.d.ts +27 -0
- package/dist/rules/Section13_SideEffects/Rule_13_6_SafeSizeOfOperand.d.ts.map +1 -0
- package/dist/rules/Section13_SideEffects/Rule_13_6_SafeSizeOfOperand.js +98 -0
- package/dist/rules/Section13_SideEffects/Rule_13_6_SafeSizeOfOperand.js.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.d.ts +45 -6
- package/dist/rules/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.d.ts.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.js +91 -8
- package/dist/rules/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.js.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.d.ts +15 -5
- package/dist/rules/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.d.ts.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.js +20 -6
- package/dist/rules/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.js.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.d.ts +11 -5
- package/dist/rules/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.d.ts.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.js +13 -10
- package/dist/rules/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.js.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.d.ts +11 -6
- package/dist/rules/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.d.ts.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.js +19 -11
- package/dist/rules/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.js.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.d.ts +15 -5
- package/dist/rules/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.d.ts.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.js +24 -10
- package/dist/rules/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.js.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.d.ts +22 -6
- package/dist/rules/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.d.ts.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.js +37 -10
- package/dist/rules/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.js.map +1 -1
- package/dist/rules/Section17_Functions/Rule_17_3_ImplicitFunction.d.ts +66 -0
- package/dist/rules/Section17_Functions/Rule_17_3_ImplicitFunction.d.ts.map +1 -0
- package/dist/rules/Section17_Functions/Rule_17_3_ImplicitFunction.js +209 -0
- package/dist/rules/Section17_Functions/Rule_17_3_ImplicitFunction.js.map +1 -0
- package/dist/rules/Section17_Functions/Rule_17_4_NonVoidReturn.d.ts +37 -12
- package/dist/rules/Section17_Functions/Rule_17_4_NonVoidReturn.d.ts.map +1 -1
- package/dist/rules/Section17_Functions/Rule_17_4_NonVoidReturn.js +112 -39
- package/dist/rules/Section17_Functions/Rule_17_4_NonVoidReturn.js.map +1 -1
- package/dist/rules/Section17_Functions/Rule_17_6_StaticArraySizeParam.d.ts +15 -5
- package/dist/rules/Section17_Functions/Rule_17_6_StaticArraySizeParam.d.ts.map +1 -1
- package/dist/rules/Section17_Functions/Rule_17_6_StaticArraySizeParam.js +21 -7
- package/dist/rules/Section17_Functions/Rule_17_6_StaticArraySizeParam.js.map +1 -1
- package/dist/rules/Section17_Functions/Rule_17_7_UnusedReturnValue.d.ts +11 -6
- package/dist/rules/Section17_Functions/Rule_17_7_UnusedReturnValue.d.ts.map +1 -1
- package/dist/rules/Section17_Functions/Rule_17_7_UnusedReturnValue.js +17 -8
- package/dist/rules/Section17_Functions/Rule_17_7_UnusedReturnValue.js.map +1 -1
- package/dist/rules/Section21-StandardLibraries/DisallowedStdLibFunctionRule.d.ts +105 -0
- package/dist/rules/Section21-StandardLibraries/DisallowedStdLibFunctionRule.d.ts.map +1 -0
- package/dist/rules/Section21-StandardLibraries/DisallowedStdLibFunctionRule.js +258 -0
- package/dist/rules/Section21-StandardLibraries/DisallowedStdLibFunctionRule.js.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_10_NoTimeDateFunctions.d.ts +25 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_10_NoTimeDateFunctions.d.ts.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_10_NoTimeDateFunctions.js +27 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_10_NoTimeDateFunctions.js.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_11_NoTgmathFunctions.d.ts +29 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_11_NoTgmathFunctions.d.ts.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_11_NoTgmathFunctions.js +31 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_11_NoTgmathFunctions.js.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_3_NoDynamicMemory.d.ts +25 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_3_NoDynamicMemory.d.ts.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_3_NoDynamicMemory.js +27 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_3_NoDynamicMemory.js.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_6_NoStdIOFunctions.d.ts +25 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_6_NoStdIOFunctions.d.ts.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_6_NoStdIOFunctions.js +27 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_6_NoStdIOFunctions.js.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_7_NoNumericStringConversions.d.ts +25 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_7_NoNumericStringConversions.d.ts.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_7_NoNumericStringConversions.js +27 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_7_NoNumericStringConversions.js.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_8_NoProcessControlFunctions.d.ts +30 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_8_NoProcessControlFunctions.d.ts.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_8_NoProcessControlFunctions.js +32 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_8_NoProcessControlFunctions.js.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_9_NoGenericSearchOrSort.d.ts +25 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_9_NoGenericSearchOrSort.d.ts.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_9_NoGenericSearchOrSort.js +27 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_9_NoGenericSearchOrSort.js.map +1 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.d.ts +6 -14
- package/dist/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.d.ts.map +1 -1
- package/dist/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.js +17 -27
- package/dist/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.js.map +1 -1
- package/dist/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.d.ts +13 -7
- package/dist/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.d.ts.map +1 -1
- package/dist/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.js +31 -17
- package/dist/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.js.map +1 -1
- package/dist/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.d.ts +26 -7
- package/dist/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.d.ts.map +1 -1
- package/dist/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.js +32 -14
- package/dist/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.js.map +1 -1
- package/dist/rules/Section2_UnusedCode/Rule_2_7_UnusedParameters.d.ts +48 -6
- package/dist/rules/Section2_UnusedCode/Rule_2_7_UnusedParameters.d.ts.map +1 -1
- package/dist/rules/Section2_UnusedCode/Rule_2_7_UnusedParameters.js +84 -34
- package/dist/rules/Section2_UnusedCode/Rule_2_7_UnusedParameters.js.map +1 -1
- package/dist/rules/Section3_Comments/Rule_3_1_CommentSequences.d.ts +24 -5
- package/dist/rules/Section3_Comments/Rule_3_1_CommentSequences.d.ts.map +1 -1
- package/dist/rules/Section3_Comments/Rule_3_1_CommentSequences.js +27 -7
- package/dist/rules/Section3_Comments/Rule_3_1_CommentSequences.js.map +1 -1
- package/dist/rules/Section5_Identifiers/IdentifierRenameRule.d.ts +46 -0
- package/dist/rules/Section5_Identifiers/IdentifierRenameRule.d.ts.map +1 -0
- package/dist/rules/Section5_Identifiers/IdentifierRenameRule.js +40 -0
- package/dist/rules/Section5_Identifiers/IdentifierRenameRule.js.map +1 -0
- package/dist/rules/Section5_Identifiers/Rule_5_1_DistinctExternalIdentifiers.d.ts +25 -0
- package/dist/rules/Section5_Identifiers/Rule_5_1_DistinctExternalIdentifiers.d.ts.map +1 -0
- package/dist/rules/Section5_Identifiers/Rule_5_1_DistinctExternalIdentifiers.js +46 -0
- package/dist/rules/Section5_Identifiers/Rule_5_1_DistinctExternalIdentifiers.js.map +1 -0
- package/dist/rules/Section5_Identifiers/Rule_5_6_UniqueTypedefNames.d.ts +26 -0
- package/dist/rules/Section5_Identifiers/Rule_5_6_UniqueTypedefNames.d.ts.map +1 -0
- package/dist/rules/Section5_Identifiers/Rule_5_6_UniqueTypedefNames.js +54 -0
- package/dist/rules/Section5_Identifiers/Rule_5_6_UniqueTypedefNames.js.map +1 -0
- package/dist/rules/Section5_Identifiers/Rule_5_7_UniqueTagNames.d.ts +27 -0
- package/dist/rules/Section5_Identifiers/Rule_5_7_UniqueTagNames.d.ts.map +1 -0
- package/dist/rules/Section5_Identifiers/Rule_5_7_UniqueTagNames.js +55 -0
- package/dist/rules/Section5_Identifiers/Rule_5_7_UniqueTagNames.js.map +1 -0
- package/dist/rules/Section5_Identifiers/Rule_5_8_UniqueExternalLinkIdentifiers.d.ts +24 -0
- package/dist/rules/Section5_Identifiers/Rule_5_8_UniqueExternalLinkIdentifiers.d.ts.map +1 -0
- package/dist/rules/Section5_Identifiers/Rule_5_8_UniqueExternalLinkIdentifiers.js +42 -0
- package/dist/rules/Section5_Identifiers/Rule_5_8_UniqueExternalLinkIdentifiers.js.map +1 -0
- package/dist/rules/Section5_Identifiers/Rule_5_9_UniqueInternalLinkIdentifiers.d.ts +24 -0
- package/dist/rules/Section5_Identifiers/Rule_5_9_UniqueInternalLinkIdentifiers.d.ts.map +1 -0
- package/dist/rules/Section5_Identifiers/Rule_5_9_UniqueInternalLinkIdentifiers.js +42 -0
- package/dist/rules/Section5_Identifiers/Rule_5_9_UniqueInternalLinkIdentifiers.js.map +1 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_6_SingleExternalDefinition.d.ts +35 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_6_SingleExternalDefinition.d.ts.map +1 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_6_SingleExternalDefinition.js +98 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_6_SingleExternalDefinition.js.map +1 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_7_RestrictExternalLinkage.d.ts +35 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_7_RestrictExternalLinkage.d.ts.map +1 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_7_RestrictExternalLinkage.js +76 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_7_RestrictExternalLinkage.js.map +1 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_9_BlockScopeDefinition.d.ts +32 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_9_BlockScopeDefinition.d.ts.map +1 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_9_BlockScopeDefinition.js +57 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_9_BlockScopeDefinition.js.map +1 -0
- package/dist/rules/UserConfigurableRule.d.ts +55 -0
- package/dist/rules/UserConfigurableRule.d.ts.map +1 -0
- package/dist/rules/UserConfigurableRule.js +16 -0
- package/dist/rules/UserConfigurableRule.js.map +1 -0
- package/dist/rules/index.d.ts +11 -18
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/index.js +47 -7
- package/dist/rules/index.js.map +1 -1
- package/dist/tests/Section17_Functions/misra_config.json +10 -0
- package/dist/tests/Section21-StandardLibraries/misra_config.json +88 -0
- package/dist/tests/Section21-StandardLibraries/problematic_misra_config.json +19 -0
- package/dist/tests/utils.d.ts +6 -3
- package/dist/tests/utils.d.ts.map +1 -1
- package/dist/tests/utils.js +33 -7
- package/dist/tests/utils.js.map +1 -1
- package/dist/utils/CallUtils.d.ts +15 -0
- package/dist/utils/CallUtils.d.ts.map +1 -0
- package/dist/utils/CallUtils.js +34 -0
- package/dist/utils/CallUtils.js.map +1 -0
- package/dist/utils/CommentUtils.d.ts +21 -0
- package/dist/utils/CommentUtils.d.ts.map +1 -0
- package/dist/utils/CommentUtils.js +27 -0
- package/dist/utils/CommentUtils.js.map +1 -0
- package/dist/utils/FileUtils.d.ts +67 -0
- package/dist/utils/FileUtils.d.ts.map +1 -0
- package/dist/utils/FileUtils.js +144 -0
- package/dist/utils/FileUtils.js.map +1 -0
- package/dist/utils/FunctionUtils.d.ts +47 -0
- package/dist/utils/FunctionUtils.d.ts.map +1 -0
- package/dist/utils/FunctionUtils.js +87 -0
- package/dist/utils/FunctionUtils.js.map +1 -0
- package/dist/utils/IdentifierUtils.d.ts +63 -0
- package/dist/utils/IdentifierUtils.d.ts.map +1 -0
- package/dist/utils/IdentifierUtils.js +133 -0
- package/dist/utils/IdentifierUtils.js.map +1 -0
- package/dist/utils/JoinpointUtils.d.ts +36 -0
- package/dist/utils/JoinpointUtils.d.ts.map +1 -0
- package/dist/utils/JoinpointUtils.js +63 -0
- package/dist/utils/JoinpointUtils.js.map +1 -0
- package/dist/utils/ProgramUtils.d.ts +39 -0
- package/dist/utils/ProgramUtils.d.ts.map +1 -0
- package/dist/utils/ProgramUtils.js +97 -0
- package/dist/utils/ProgramUtils.js.map +1 -0
- package/dist/utils/SwitchUtils.d.ts +21 -0
- package/dist/utils/SwitchUtils.d.ts.map +1 -0
- package/dist/utils/SwitchUtils.js +47 -0
- package/dist/utils/SwitchUtils.js.map +1 -0
- package/dist/utils/TypeDeclUtils.d.ts +35 -0
- package/dist/utils/TypeDeclUtils.d.ts.map +1 -0
- package/dist/utils/TypeDeclUtils.js +78 -0
- package/dist/utils/TypeDeclUtils.js.map +1 -0
- package/dist/utils/VarUtils.d.ts +51 -0
- package/dist/utils/VarUtils.d.ts.map +1 -0
- package/dist/utils/VarUtils.js +91 -0
- package/dist/utils/VarUtils.js.map +1 -0
- package/package.json +16 -7
- package/src/MISRA.ts +33 -17
- package/src/MISRAContext.ts +128 -30
- package/src/MISRARule.ts +61 -29
- package/src/MISRATool.ts +126 -42
- package/src/StandardGuideline.ts +23 -0
- package/src/ast-visitor/Context.ts +16 -0
- package/src/ast-visitor/Visit.ts +26 -0
- package/src/ast-visitor/VisitWithContext.ts +42 -0
- package/src/main.ts +1 -4
- package/src/rules/Section13_SideEffects/Rule_13_6_SafeSizeOfOperand.ts +114 -0
- package/src/rules/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.ts +103 -13
- package/src/rules/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.ts +24 -10
- package/src/rules/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.ts +17 -8
- package/src/rules/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.ts +20 -12
- package/src/rules/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.ts +23 -12
- package/src/rules/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.ts +44 -13
- package/src/rules/Section17_Functions/Rule_17_3_ImplicitFunction.ts +153 -104
- package/src/rules/Section17_Functions/Rule_17_4_NonVoidReturn.ts +114 -44
- package/src/rules/Section17_Functions/Rule_17_6_StaticArraySizeParam.ts +27 -10
- package/src/rules/Section17_Functions/Rule_17_7_UnusedReturnValue.ts +20 -12
- package/src/rules/Section21-StandardLibraries/DisallowedStdLibFunctionRule.ts +317 -0
- package/src/rules/Section21-StandardLibraries/Rule_21_10_NoTimeDateFunctions.ts +30 -0
- package/src/rules/Section21-StandardLibraries/Rule_21_11_NoTgmathFunctions.ts +35 -0
- package/src/rules/Section21-StandardLibraries/Rule_21_3_NoDynamicMemory.ts +30 -0
- package/src/rules/Section21-StandardLibraries/Rule_21_6_NoStdIOFunctions.ts +30 -0
- package/src/rules/Section21-StandardLibraries/Rule_21_7_NoNumericStringConversions.ts +29 -0
- package/src/rules/Section21-StandardLibraries/Rule_21_8_NoProcessControlFunctions.ts +36 -0
- package/src/rules/Section21-StandardLibraries/Rule_21_9_NoGenericSearchOrSort.ts +30 -0
- package/src/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.ts +14 -29
- package/src/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.ts +33 -19
- package/src/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.ts +33 -20
- package/src/rules/Section2_UnusedCode/Rule_2_7_UnusedParameters.ts +90 -45
- package/src/rules/Section3_Comments/Rule_3_1_CommentSequences.ts +27 -8
- package/src/rules/Section5_Identifiers/IdentifierRenameRule.ts +63 -0
- package/src/rules/Section5_Identifiers/Rule_5_1_DistinctExternalIdentifiers.ts +52 -0
- package/src/rules/Section5_Identifiers/Rule_5_6_UniqueTypedefNames.ts +62 -0
- package/src/rules/Section5_Identifiers/Rule_5_7_UniqueTagNames.ts +61 -0
- package/src/rules/Section5_Identifiers/Rule_5_8_UniqueExternalLinkIdentifiers.ts +47 -0
- package/src/rules/Section5_Identifiers/Rule_5_9_UniqueInternalLinkIdentifiers.ts +47 -0
- package/src/rules/Section8_DeclarationsAndDefinitions/Rule_8_6_SingleExternalDefinition.ts +118 -0
- package/src/rules/Section8_DeclarationsAndDefinitions/Rule_8_7_RestrictExternalLinkage.ts +89 -0
- package/src/rules/Section8_DeclarationsAndDefinitions/Rule_8_9_BlockScopeDefinition.ts +65 -0
- package/src/rules/UserConfigurableRule.ts +60 -0
- package/src/rules/index.ts +45 -7
- package/src/tests/Section13_SideEffects/Rule_13_6_SafeSizeOfOperand.test.ts +114 -0
- package/src/tests/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.test.ts +7 -5
- package/src/tests/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.test.ts +40 -13
- package/src/tests/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.test.ts +10 -12
- package/src/tests/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.test.ts +5 -5
- package/src/tests/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.test.ts +5 -5
- package/src/tests/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.test.ts +5 -5
- package/src/tests/Section17_Functions/Rule_17_3_ImplicitFunctions.test.ts +68 -40
- package/src/tests/Section17_Functions/Rule_17_3_ImplicitFunctions_MissingConfig.test.ts +98 -0
- package/src/tests/Section17_Functions/Rule_17_3_ImplicitFunctions_ProblematicConfig.test.ts +71 -0
- package/src/tests/Section17_Functions/Rule_17_4_NonVoidReturn.test.ts +103 -49
- package/src/tests/Section17_Functions/Rule_17_4_NonVoidReturn_MissingConfig.test.ts +7 -7
- package/src/tests/Section17_Functions/Rule_17_6_StaticArraySizeParam.test.ts +36 -7
- package/src/tests/Section17_Functions/Rule_17_7_UnusedReturnValue.test.ts +25 -21
- package/src/tests/Section17_Functions/misra_config.json +4 -3
- package/src/tests/Section21-StandardLibraries/Rule_21_10_NoTimeDateFunctions.test.ts +62 -0
- package/src/tests/Section21-StandardLibraries/Rule_21_11_NoTgmathFunctions.test.ts +67 -0
- package/src/tests/Section21-StandardLibraries/Rule_21_3_NoDynamicMemory.test.ts +84 -0
- package/src/tests/Section21-StandardLibraries/Rule_21_3_NoDynamicMemory_MissingConfig.test.ts +33 -0
- package/src/tests/Section21-StandardLibraries/Rule_21_3_NoDynamicMemory_ProblematicConfig.test.ts +71 -0
- package/src/tests/Section21-StandardLibraries/Rule_21_6_NoStdIOFunctions.test.ts +63 -0
- package/src/tests/Section21-StandardLibraries/Rule_21_7_NoNumericStringConversions.test.ts +91 -0
- package/src/tests/Section21-StandardLibraries/Rule_21_8_NoProcessControlFunctions.test.ts +65 -0
- package/src/tests/Section21-StandardLibraries/Rule_21_9_NoGenericSearchOrSort.test.ts +89 -0
- package/src/tests/Section21-StandardLibraries/misra_config.json +88 -0
- package/src/tests/Section21-StandardLibraries/problematic_misra_config.json +19 -0
- package/src/tests/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.test.ts +148 -113
- package/src/tests/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.test.ts +243 -163
- package/src/tests/Section2_UnusedCode/Rule_2_6_UnusedLabels.test.ts +32 -20
- package/src/tests/Section2_UnusedCode/Rule_2_7_UnusedParameters.test.ts +36 -30
- package/src/tests/Section3_Comments/Rule_3_1_CommentSequences.test.ts +37 -8
- package/src/tests/Section5_Identifiers/Rule_5_1_DistinctExternalIdentifiers.test.ts +78 -0
- package/src/tests/Section5_Identifiers/Rule_5_6_UniqueTypedefNames.test.ts +120 -0
- package/src/tests/Section5_Identifiers/Rule_5_7_UniqueTagNames.test.ts +51 -0
- package/src/tests/Section5_Identifiers/Rule_5_8_UniqueExternalLinkIdentifiers.test.ts +73 -0
- package/src/tests/Section5_Identifiers/Rule_5_9_UniqueInternalLinkIdentifiers.test.ts +97 -0
- package/src/tests/Section8_DeclarationsAndDefinitions/Rule_8_6_SingleExternalDefinition.test.ts +160 -0
- package/src/tests/Section8_DeclarationsAndDefinitions/Rule_8_7_RestrictExternalLinkage.test.ts +46 -0
- package/src/tests/Section8_DeclarationsAndDefinitions/Rule_8_9_BlockScopeDefinition.test.ts +69 -0
- package/src/tests/utils.ts +32 -7
- package/src/utils/CallUtils.ts +37 -0
- package/src/utils/CommentUtils.ts +29 -0
- package/src/utils/FileUtils.ts +169 -0
- package/src/utils/FunctionUtils.ts +97 -0
- package/src/utils/IdentifierUtils.ts +142 -0
- package/src/utils/JoinpointUtils.ts +70 -0
- package/src/utils/ProgramUtils.ts +107 -0
- package/src/utils/SwitchUtils.ts +52 -0
- package/src/utils/TypeDeclUtils.ts +88 -0
- package/src/utils/VarUtils.ts +102 -0
- package/tsconfig.json +2 -1
- package/src/rules/Section20-PreprocessingDirectives/Rule_20_2_InvalidHeaderFileName.ts +0 -120
- package/src/rules/Section3_Comments/Rule_3_2_LineSplicing.ts +0 -36
- package/src/utils/utils.ts +0 -280
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { FileJp, Program, Call, FunctionJp, Joinpoint } from "@specs-feup/clava/api/Joinpoints.js";
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a file compiles correctly after adding a statement by rebuilding it.
|
|
4
|
+
* If rebuilding fails, the file is considered invalid with the new statement.
|
|
5
|
+
*
|
|
6
|
+
* @param fileJp - The file to validate.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isValidFile(fileJp: FileJp, jpType?: typeof Joinpoint, index?: number): boolean | Joinpoint | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Checks if the rebuilt version of the file compiles and if the provided call is no longer implicit.
|
|
11
|
+
*
|
|
12
|
+
* @param fileJp The file to analyze
|
|
13
|
+
* @param funcName The function name to search the call
|
|
14
|
+
* @param callIndex The index of the call
|
|
15
|
+
*/
|
|
16
|
+
export declare function isValidFileWithExplicitCall(fileJp: FileJp, funcName: string, callIndex: number, checkNumParams?: boolean): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves the list of header files included in the given file
|
|
19
|
+
*
|
|
20
|
+
* @param fileJp The file join point
|
|
21
|
+
* @returns An array of strings with the names of the includes
|
|
22
|
+
*/
|
|
23
|
+
export declare function getIncludesOfFile(fileJp: FileJp): Set<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Removes a specific include directive from the given file, if it exists
|
|
26
|
+
*
|
|
27
|
+
* @param includeName The name of the include to remove
|
|
28
|
+
* @param fileJp The file from which the include should be removed
|
|
29
|
+
*/
|
|
30
|
+
export declare function removeIncludeFromFile(includeName: string, fileJp: FileJp): void;
|
|
31
|
+
/**
|
|
32
|
+
* Returns all files in the program that include a given header file using the `#include` directive
|
|
33
|
+
*
|
|
34
|
+
* @param headerName - The name of the header file to search for
|
|
35
|
+
* @returns An array of files that include the specified header
|
|
36
|
+
*/
|
|
37
|
+
export declare function findFilesReferencingHeader(headerName: string): FileJp[];
|
|
38
|
+
/**
|
|
39
|
+
* Returns all files in the program that contain at least one call to an implicit function
|
|
40
|
+
*
|
|
41
|
+
* @param programJp - The program to analyze
|
|
42
|
+
* @returns A list of files with implicit function calls
|
|
43
|
+
*/
|
|
44
|
+
export declare function getFilesWithCallToImplicitFunction(programJp: Program): FileJp[];
|
|
45
|
+
/**
|
|
46
|
+
* Inserts an extern declaration of the given function into the file.
|
|
47
|
+
*
|
|
48
|
+
* @param fileJp The file to modify.
|
|
49
|
+
* @param functionJp The function to declare as extern.
|
|
50
|
+
* @returns The inserted join point, or undefined if the function has no external linkage.
|
|
51
|
+
*/
|
|
52
|
+
export declare function addExternFunctionDecl(fileJp: FileJp, functionJp: FunctionJp): Joinpoint | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Returns all extern function declarations in the given file
|
|
55
|
+
* @param fileJp The file join point
|
|
56
|
+
* @returns An array of functions declared with 'extern'
|
|
57
|
+
*/
|
|
58
|
+
export declare function getExternFunctionDecls(fileJp: FileJp): FunctionJp[];
|
|
59
|
+
/**
|
|
60
|
+
* Returns function calls from a file that are defined in the provided library header. Optionally filters by function names.
|
|
61
|
+
*
|
|
62
|
+
* @param fileJp The file join point
|
|
63
|
+
* @param libraryName Header filename
|
|
64
|
+
* @param functionNames Optional list of function names to filter
|
|
65
|
+
*/
|
|
66
|
+
export declare function getCallsToLibrary(fileJp: FileJp, libraryName: string, functionNames?: Set<string>): Call[];
|
|
67
|
+
//# sourceMappingURL=FileUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileUtils.d.ts","sourceRoot":"","sources":["../../src/utils/FileUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAW,IAAI,EAAE,UAAU,EAAE,SAAS,EAAgB,MAAM,qCAAqC,CAAC;AAM1H;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,SAAS,EAAE,KAAK,CAAC,EAAE,MAAM,GAAI,OAAO,GAAG,SAAS,GAAG,SAAS,CAuBvH;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,GAAE,OAAe,GAAG,OAAO,CA4BzI;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAE7D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAGxE;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAEvE;AAED;;;;;GAKG;AACH,wBAAgB,kCAAkC,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM,EAAE,CAQ/E;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,SAAS,CAenG;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,EAAE,CAEnE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,GAAE,GAAG,CAAC,MAAM,CAAa,GAAG,IAAI,EAAE,CAMrH"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import ClavaJoinPoints from "@specs-feup/clava/api/clava/ClavaJoinPoints.js";
|
|
2
|
+
import { FileJp, Include, Call, FunctionJp, StorageClass } from "@specs-feup/clava/api/Joinpoints.js";
|
|
3
|
+
import Query from "@specs-feup/lara/api/weaver/Query.js";
|
|
4
|
+
import { isCallToImplicitFunction } from "./CallUtils.js";
|
|
5
|
+
import { isExternalLinkageIdentifier } from "./IdentifierUtils.js";
|
|
6
|
+
import path from "path";
|
|
7
|
+
/**
|
|
8
|
+
* Checks if a file compiles correctly after adding a statement by rebuilding it.
|
|
9
|
+
* If rebuilding fails, the file is considered invalid with the new statement.
|
|
10
|
+
*
|
|
11
|
+
* @param fileJp - The file to validate.
|
|
12
|
+
*/
|
|
13
|
+
export function isValidFile(fileJp, jpType, index) {
|
|
14
|
+
let result = true;
|
|
15
|
+
// Create a temporary copy of the file for validation
|
|
16
|
+
const programJp = fileJp.parent;
|
|
17
|
+
let copyFile = ClavaJoinPoints.fileWithSource(`temp_misra_${fileJp.name}`, fileJp.code, fileJp.relativeFolderpath);
|
|
18
|
+
copyFile = programJp.addFile(copyFile);
|
|
19
|
+
try {
|
|
20
|
+
const rebuiltFile = copyFile.rebuild();
|
|
21
|
+
if (jpType && index) { // If requested, return a specific join point inside the rebuilt file
|
|
22
|
+
result = Query.searchFrom(rebuiltFile, jpType).get()[index];
|
|
23
|
+
}
|
|
24
|
+
// Remove the temporary file
|
|
25
|
+
const fileToRemove = Query.searchFrom(programJp, FileJp, { filepath: rebuiltFile.filepath }).first();
|
|
26
|
+
fileToRemove?.detach();
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
// On rebuild failure, delete copy file and return false
|
|
31
|
+
copyFile.detach();
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Checks if the rebuilt version of the file compiles and if the provided call is no longer implicit.
|
|
37
|
+
*
|
|
38
|
+
* @param fileJp The file to analyze
|
|
39
|
+
* @param funcName The function name to search the call
|
|
40
|
+
* @param callIndex The index of the call
|
|
41
|
+
*/
|
|
42
|
+
export function isValidFileWithExplicitCall(fileJp, funcName, callIndex, checkNumParams = false) {
|
|
43
|
+
const programJp = fileJp.parent;
|
|
44
|
+
// Create a temporary copy of the file for validation
|
|
45
|
+
let copyFile = ClavaJoinPoints.fileWithSource(`temp_misra_${fileJp.name}`, fileJp.code, fileJp.relativeFolderpath);
|
|
46
|
+
copyFile = programJp.addFile(copyFile);
|
|
47
|
+
try {
|
|
48
|
+
// Rebuild the file to check validity
|
|
49
|
+
const rebuiltFile = copyFile.rebuild();
|
|
50
|
+
const fileToRemove = Query.searchFrom(programJp, FileJp, { filepath: rebuiltFile.filepath }).first();
|
|
51
|
+
// Locate the function call and check if it is implicit
|
|
52
|
+
const callJp = Query.searchFrom(fileToRemove, Call, { name: funcName }).get().at(callIndex);
|
|
53
|
+
let isExplicitCall = callJp !== undefined && !isCallToImplicitFunction(callJp);
|
|
54
|
+
if (checkNumParams && isExplicitCall) {
|
|
55
|
+
isExplicitCall = isExplicitCall && callJp.args.length === callJp.directCallee.params.length;
|
|
56
|
+
}
|
|
57
|
+
// Remove the temporary file
|
|
58
|
+
fileToRemove?.detach();
|
|
59
|
+
return isExplicitCall;
|
|
60
|
+
}
|
|
61
|
+
catch (error) { // On rebuild failure, delete copy file and return false
|
|
62
|
+
copyFile.detach();
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Retrieves the list of header files included in the given file
|
|
68
|
+
*
|
|
69
|
+
* @param fileJp The file join point
|
|
70
|
+
* @returns An array of strings with the names of the includes
|
|
71
|
+
*/
|
|
72
|
+
export function getIncludesOfFile(fileJp) {
|
|
73
|
+
return new Set(fileJp.includes.map(includeJp => includeJp.isAngled ? includeJp.name : path.basename(includeJp.name)));
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Removes a specific include directive from the given file, if it exists
|
|
77
|
+
*
|
|
78
|
+
* @param includeName The name of the include to remove
|
|
79
|
+
* @param fileJp The file from which the include should be removed
|
|
80
|
+
*/
|
|
81
|
+
export function removeIncludeFromFile(includeName, fileJp) {
|
|
82
|
+
const include = Query.searchFrom(fileJp, Include, { name: includeName }).first();
|
|
83
|
+
include?.detach();
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Returns all files in the program that include a given header file using the `#include` directive
|
|
87
|
+
*
|
|
88
|
+
* @param headerName - The name of the header file to search for
|
|
89
|
+
* @returns An array of files that include the specified header
|
|
90
|
+
*/
|
|
91
|
+
export function findFilesReferencingHeader(headerName) {
|
|
92
|
+
return Query.search(FileJp, (jp) => { return getIncludesOfFile(jp).has(headerName); }).get();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Returns all files in the program that contain at least one call to an implicit function
|
|
96
|
+
*
|
|
97
|
+
* @param programJp - The program to analyze
|
|
98
|
+
* @returns A list of files with implicit function calls
|
|
99
|
+
*/
|
|
100
|
+
export function getFilesWithCallToImplicitFunction(programJp) {
|
|
101
|
+
const files = Query.searchFrom(programJp, FileJp).get();
|
|
102
|
+
return files.filter((fileJp) => Query.searchFrom(fileJp, Call, (callJp) => isCallToImplicitFunction(callJp)).get().length > 0);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Inserts an extern declaration of the given function into the file.
|
|
106
|
+
*
|
|
107
|
+
* @param fileJp The file to modify.
|
|
108
|
+
* @param functionJp The function to declare as extern.
|
|
109
|
+
* @returns The inserted join point, or undefined if the function has no external linkage.
|
|
110
|
+
*/
|
|
111
|
+
export function addExternFunctionDecl(fileJp, functionJp) {
|
|
112
|
+
if (!isExternalLinkageIdentifier(functionJp)) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
let childAfterExtern = fileJp.firstChild;
|
|
116
|
+
while (childAfterExtern instanceof Include) {
|
|
117
|
+
childAfterExtern = childAfterExtern.siblingsRight[0];
|
|
118
|
+
}
|
|
119
|
+
const externStr = `extern ${functionJp.getDeclaration(true)};`;
|
|
120
|
+
const externStmt = ClavaJoinPoints.stmtLiteral(externStr);
|
|
121
|
+
const newExternStmt = childAfterExtern.insertBefore(externStmt);
|
|
122
|
+
return newExternStmt;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Returns all extern function declarations in the given file
|
|
126
|
+
* @param fileJp The file join point
|
|
127
|
+
* @returns An array of functions declared with 'extern'
|
|
128
|
+
*/
|
|
129
|
+
export function getExternFunctionDecls(fileJp) {
|
|
130
|
+
return Query.searchFrom(fileJp, FunctionJp, { storageClass: StorageClass.EXTERN }).get();
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Returns function calls from a file that are defined in the provided library header. Optionally filters by function names.
|
|
134
|
+
*
|
|
135
|
+
* @param fileJp The file join point
|
|
136
|
+
* @param libraryName Header filename
|
|
137
|
+
* @param functionNames Optional list of function names to filter
|
|
138
|
+
*/
|
|
139
|
+
export function getCallsToLibrary(fileJp, libraryName, functionNames = new Set()) {
|
|
140
|
+
return Query.searchFrom(fileJp, Call, (callJp) => callJp.function?.isInSystemHeader &&
|
|
141
|
+
callJp.function?.filepath.endsWith(libraryName) &&
|
|
142
|
+
(functionNames.size === 0 || functionNames.has(callJp.name))).get();
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=FileUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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AAa,CAAC,IAAI,KAAK,CAAC,IAAI,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAC/D,CAAC,GAAG,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Param, Varref, FunctionJp, LabelStmt } from "@specs-feup/clava/api/Joinpoints.js";
|
|
2
|
+
/**
|
|
3
|
+
* Gets direct references to a parameter within a function
|
|
4
|
+
* @param $param Parameter to find references for
|
|
5
|
+
* @param functionJp Function joinpoint to search in
|
|
6
|
+
*/
|
|
7
|
+
export declare function getDirectParamReferences($param: Param, functionJp: FunctionJp): Varref[];
|
|
8
|
+
/**
|
|
9
|
+
* Gets variable references to a parameter inside Variable-Length Array (VLA) fields
|
|
10
|
+
* @param $param Parameter to find references for
|
|
11
|
+
* @param functionJp Function joinpoint to search in
|
|
12
|
+
*/
|
|
13
|
+
export declare function getVLAFieldParamReferences($param: Param, functionJp: FunctionJp): Varref[];
|
|
14
|
+
/**
|
|
15
|
+
* Gets all unique variable references to a parameter in a function.
|
|
16
|
+
* @param $param Parameter to find references for
|
|
17
|
+
* @param functionJp Function joinpoint to search in
|
|
18
|
+
* @returns Array of unique Varref references
|
|
19
|
+
*/
|
|
20
|
+
export declare function getParamReferences($param: Param, functionJp: FunctionJp): Varref[];
|
|
21
|
+
/**
|
|
22
|
+
* Gets all label statements in the given function that are never referenced
|
|
23
|
+
* @param func The function to analyze
|
|
24
|
+
* @returns An array of unused labels statements
|
|
25
|
+
*/
|
|
26
|
+
export declare function getUnusedLabels(func: FunctionJp): LabelStmt[];
|
|
27
|
+
/**
|
|
28
|
+
* Returns the first function definition matching the given name and file path suffix
|
|
29
|
+
*
|
|
30
|
+
* @param functionName Name of the function
|
|
31
|
+
* @param pathSuffix File path suffix
|
|
32
|
+
* @returns The function definition, or undefined if not found
|
|
33
|
+
*/
|
|
34
|
+
export declare function findFunctionDef(functionName: string, pathSuffix: string): FunctionJp | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Finds extern declarations for the given function
|
|
37
|
+
* @param functionJp The function join point
|
|
38
|
+
* @returns List of extern function declarations
|
|
39
|
+
*/
|
|
40
|
+
export declare function findExternalFunctionDecl(functionJp: FunctionJp): FunctionJp[];
|
|
41
|
+
/**
|
|
42
|
+
* Checks if the given function is called anywhere in the project
|
|
43
|
+
* @param functionJp The function to evaluate
|
|
44
|
+
* @returns True if the function is used, false otherwise
|
|
45
|
+
*/
|
|
46
|
+
export declare function isFunctionUsed(functionJp: FunctionJp): boolean;
|
|
47
|
+
//# sourceMappingURL=FunctionUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FunctionUtils.d.ts","sourceRoot":"","sources":["../../src/utils/FunctionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAA0B,SAAS,EAAmC,MAAM,qCAAqC,CAAC;AAKpJ;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,GAAG,MAAM,EAAE,CAExF;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,GAAG,MAAM,EAAE,CAK1F;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,GAAG,MAAM,EAAE,CAMlF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,EAAE,CAI7D;AAED;;;;;;GAMG;AAEH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,0BASvE;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,EAAE,CAG7E;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAW9D"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Varref, FunctionJp, StorageClass, GotoStmt, LabelStmt, Call, VariableArrayType } from "@specs-feup/clava/api/Joinpoints.js";
|
|
2
|
+
import Query from "@specs-feup/lara/api/weaver/Query.js";
|
|
3
|
+
import { findFilesReferencingHeader } from "./FileUtils.js";
|
|
4
|
+
import { hasDefinedType } from "./JoinpointUtils.js";
|
|
5
|
+
/**
|
|
6
|
+
* Gets direct references to a parameter within a function
|
|
7
|
+
* @param $param Parameter to find references for
|
|
8
|
+
* @param functionJp Function joinpoint to search in
|
|
9
|
+
*/
|
|
10
|
+
export function getDirectParamReferences($param, functionJp) {
|
|
11
|
+
return Query.searchFrom(functionJp, Varref, (ref) => { return ref.decl && ref.decl.astId === $param.astId; }).get();
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Gets variable references to a parameter inside Variable-Length Array (VLA) fields
|
|
15
|
+
* @param $param Parameter to find references for
|
|
16
|
+
* @param functionJp Function joinpoint to search in
|
|
17
|
+
*/
|
|
18
|
+
export function getVLAFieldParamReferences($param, functionJp) {
|
|
19
|
+
const vlaJoinpoints = functionJp.descendants.filter(jp => hasDefinedType(jp) && jp.type instanceof VariableArrayType);
|
|
20
|
+
const fieldsInVLAs = vlaJoinpoints.flatMap(jp => jp.jpFields(true).flatMap(field => [field, ...field.descendants]));
|
|
21
|
+
return fieldsInVLAs.filter(field => field instanceof Varref && field.decl?.astId === $param.astId);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Gets all unique variable references to a parameter in a function.
|
|
25
|
+
* @param $param Parameter to find references for
|
|
26
|
+
* @param functionJp Function joinpoint to search in
|
|
27
|
+
* @returns Array of unique Varref references
|
|
28
|
+
*/
|
|
29
|
+
export function getParamReferences($param, functionJp) {
|
|
30
|
+
const directRefs = getDirectParamReferences($param, functionJp);
|
|
31
|
+
const refsInVLAFields = getVLAFieldParamReferences($param, functionJp);
|
|
32
|
+
// Remove duplicated nodes
|
|
33
|
+
return Array.from(new Map([...directRefs, ...refsInVLAFields].map(ref => [ref.ast, ref])).values());
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Gets all label statements in the given function that are never referenced
|
|
37
|
+
* @param func The function to analyze
|
|
38
|
+
* @returns An array of unused labels statements
|
|
39
|
+
*/
|
|
40
|
+
export function getUnusedLabels(func) {
|
|
41
|
+
return Query.searchFrom(func, LabelStmt).get().filter(label => Query.searchFrom(func, GotoStmt, { label: jp => jp.astId === label.decl.astId }).get().length === 0);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Returns the first function definition matching the given name and file path suffix
|
|
45
|
+
*
|
|
46
|
+
* @param functionName Name of the function
|
|
47
|
+
* @param pathSuffix File path suffix
|
|
48
|
+
* @returns The function definition, or undefined if not found
|
|
49
|
+
*/
|
|
50
|
+
export function findFunctionDef(functionName, pathSuffix) {
|
|
51
|
+
const funcDefs = Query.search(FunctionJp, (func) => {
|
|
52
|
+
try {
|
|
53
|
+
return func.name === functionName && func.isImplementation && func.filepath.endsWith(pathSuffix);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}).get();
|
|
59
|
+
return funcDefs.length > 0 ? funcDefs[0] : undefined;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Finds extern declarations for the given function
|
|
63
|
+
* @param functionJp The function join point
|
|
64
|
+
* @returns List of extern function declarations
|
|
65
|
+
*/
|
|
66
|
+
export function findExternalFunctionDecl(functionJp) {
|
|
67
|
+
return functionJp.declarationJps
|
|
68
|
+
.filter((declJp) => declJp.storageClass === StorageClass.EXTERN);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Checks if the given function is called anywhere in the project
|
|
72
|
+
* @param functionJp The function to evaluate
|
|
73
|
+
* @returns True if the function is used, false otherwise
|
|
74
|
+
*/
|
|
75
|
+
export function isFunctionUsed(functionJp) {
|
|
76
|
+
const fileJp = functionJp.getAncestor("file");
|
|
77
|
+
let referencingFiles;
|
|
78
|
+
if (fileJp.isHeader) {
|
|
79
|
+
const filesWithInclude = findFilesReferencingHeader(fileJp.name);
|
|
80
|
+
referencingFiles = [fileJp, ...filesWithInclude];
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
referencingFiles = [fileJp];
|
|
84
|
+
}
|
|
85
|
+
return referencingFiles.some(fileJp => Query.searchFrom(fileJp, Call, { name: functionJp.name, directCallee: (jp) => jp?.ast === functionJp.ast }).get().length > 0);
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=FunctionUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FunctionUtils.js","sourceRoot":"","sources":["../../src/utils/FunctionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAU,IAAI,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACpJ,OAAO,KAAK,MAAM,sCAAsC,CAAC;AACzD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAAa,EAAE,UAAsB;IAC1E,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,CAAA,CAAA,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AACtH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,MAAa,EAAE,UAAsB;IAC5E,MAAM,aAAa,GAAG,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,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,CAAC;IAChC,CAAC;IACD,OAAO,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,EAAC,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,YAAY,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,GAAG,KAAK,UAAU,CAAC,GAAG,EAAC,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;AACtK,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Joinpoint, Vardecl, FunctionJp } from "@specs-feup/clava/api/Joinpoints.js";
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the given joinpoint is an identifier declaration (variable, function, typedef, label, or tag)
|
|
4
|
+
*
|
|
5
|
+
* @param $jp The joinpoint to evaluate
|
|
6
|
+
* @returns True if the join point is an identifier declaration, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
export declare function isIdentifierDecl($jp: Joinpoint): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves the name of the given joinpoint
|
|
11
|
+
* @param $jp The joinpoint to evaluate
|
|
12
|
+
* @returns The name of the identifier, or undefined if the join point does not represent an identifier
|
|
13
|
+
*/
|
|
14
|
+
export declare function getIdentifierName($jp: Joinpoint): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Checks if two joinpoints represent different identifiers with the same name
|
|
17
|
+
* @param identifier1 The first joinpoint to evaluate
|
|
18
|
+
* @param identifier2 The second joinpoint to evaluate
|
|
19
|
+
* @returns True if names match and the nodes differ, otherwise returns false
|
|
20
|
+
*/
|
|
21
|
+
export declare function areIdentifierNamesEqual(identifier1: Joinpoint, identifier2: Joinpoint): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Updates the name of an identifier joinpoint
|
|
24
|
+
* @param $jp The joinpoint to rename
|
|
25
|
+
* @param newName the new identifier name
|
|
26
|
+
* @returns True if renaming was successful, false otherwise
|
|
27
|
+
*/
|
|
28
|
+
export declare function renameIdentifier($jp: Joinpoint, newName: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Checks if a given joinpoint represents an identifier with external linkage
|
|
31
|
+
*
|
|
32
|
+
* @param $jp The joinpoint to evaluate
|
|
33
|
+
* @returns True if the joinpoint has external linkage, false otherwise
|
|
34
|
+
*/
|
|
35
|
+
export declare function isExternalLinkageIdentifier($jp: Joinpoint): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Checks if a given joinpoint represents an identifier with internal linkage
|
|
38
|
+
*
|
|
39
|
+
* @param $jp The joinpoint to evaluate
|
|
40
|
+
* @returns True if the joinpoint has internal linkage, false otherwise
|
|
41
|
+
*/
|
|
42
|
+
export declare function isInternalLinkageIdentifier($jp: Joinpoint): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Determines if an identifier is duplicated in a collection of join points
|
|
45
|
+
*
|
|
46
|
+
* @param $jp The identifier to evaluate
|
|
47
|
+
* @param $others Other join points to compare with
|
|
48
|
+
* @returns True if a duplicate exists, false otherwise
|
|
49
|
+
*/
|
|
50
|
+
export declare function isIdentifierDuplicated($jp: Joinpoint, $others: Joinpoint[]): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Checks if another identifier with the same name is declared before the given joinpoint
|
|
53
|
+
*
|
|
54
|
+
* @param $jp The identifier join point to check
|
|
55
|
+
* @param $others The list of other identifiers to compare with
|
|
56
|
+
* @returns True if a matching identifier is declared earlier, false otherwise.
|
|
57
|
+
*/
|
|
58
|
+
export declare function isIdentifierNameDeclaredBefore($jp: Joinpoint, $others: Joinpoint[]): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* @returns Returns true if the identifiers represent different AST nodes but are not distinct within the first 31 characters. Otherwise returns false.
|
|
61
|
+
*/
|
|
62
|
+
export declare function areDistinctIdentifiers($jp1: Vardecl | FunctionJp, $jp2: Vardecl | FunctionJp): boolean;
|
|
63
|
+
//# sourceMappingURL=IdentifierUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdentifierUtils.d.ts","sourceRoot":"","sources":["../../src/utils/IdentifierUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAgB,UAAU,EAAqC,MAAM,qCAAqC,CAAC;AAItI;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAMxD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAOpE;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,WAMrF;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAkBzE;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CASnE;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAUnE;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,WAE1E;AAED;;;;;;GAMG;AAEH,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,WAIlF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,OAAO,GAAG,UAAU,EAAE,IAAI,EAAE,OAAO,GAAG,UAAU,GAAG,OAAO,CAMtG"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Vardecl, StorageClass, FunctionJp, TypedefDecl, LabelStmt, NamedDecl } from "@specs-feup/clava/api/Joinpoints.js";
|
|
2
|
+
import { compareLocation, isTagDecl } from "./JoinpointUtils.js";
|
|
3
|
+
import { findDuplicateVarDefinition, findExternalVarRefs, isSameVarDecl } from "./VarUtils.js";
|
|
4
|
+
/**
|
|
5
|
+
* Checks if the given joinpoint is an identifier declaration (variable, function, typedef, label, or tag)
|
|
6
|
+
*
|
|
7
|
+
* @param $jp The joinpoint to evaluate
|
|
8
|
+
* @returns True if the join point is an identifier declaration, false otherwise
|
|
9
|
+
*/
|
|
10
|
+
export function isIdentifierDecl($jp) {
|
|
11
|
+
return ($jp instanceof Vardecl && $jp.storageClass !== StorageClass.EXTERN) ||
|
|
12
|
+
($jp instanceof FunctionJp && $jp.isImplementation) ||
|
|
13
|
+
$jp instanceof TypedefDecl ||
|
|
14
|
+
$jp instanceof LabelStmt ||
|
|
15
|
+
isTagDecl($jp);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves the name of the given joinpoint
|
|
19
|
+
* @param $jp The joinpoint to evaluate
|
|
20
|
+
* @returns The name of the identifier, or undefined if the join point does not represent an identifier
|
|
21
|
+
*/
|
|
22
|
+
export function getIdentifierName($jp) {
|
|
23
|
+
if ($jp instanceof NamedDecl) {
|
|
24
|
+
return $jp.name;
|
|
25
|
+
}
|
|
26
|
+
else if ($jp instanceof LabelStmt) {
|
|
27
|
+
return $jp.decl.name;
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Checks if two joinpoints represent different identifiers with the same name
|
|
33
|
+
* @param identifier1 The first joinpoint to evaluate
|
|
34
|
+
* @param identifier2 The second joinpoint to evaluate
|
|
35
|
+
* @returns True if names match and the nodes differ, otherwise returns false
|
|
36
|
+
*/
|
|
37
|
+
export function areIdentifierNamesEqual(identifier1, identifier2) {
|
|
38
|
+
const name1 = getIdentifierName(identifier1);
|
|
39
|
+
const name2 = getIdentifierName(identifier2);
|
|
40
|
+
if (!name1 || !name2)
|
|
41
|
+
return false;
|
|
42
|
+
return identifier1.ast !== identifier2.ast && name1 === name2;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Updates the name of an identifier joinpoint
|
|
46
|
+
* @param $jp The joinpoint to rename
|
|
47
|
+
* @param newName the new identifier name
|
|
48
|
+
* @returns True if renaming was successful, false otherwise
|
|
49
|
+
*/
|
|
50
|
+
export function renameIdentifier($jp, newName) {
|
|
51
|
+
if ($jp instanceof LabelStmt) {
|
|
52
|
+
$jp.decl.setName(newName);
|
|
53
|
+
}
|
|
54
|
+
else if ($jp instanceof Vardecl) {
|
|
55
|
+
const externalRefs = findExternalVarRefs($jp);
|
|
56
|
+
const duplicateDefs = findDuplicateVarDefinition($jp);
|
|
57
|
+
$jp.setName(newName);
|
|
58
|
+
if (isExternalLinkageIdentifier($jp)) {
|
|
59
|
+
externalRefs.forEach((varRef) => varRef.setName(newName));
|
|
60
|
+
duplicateDefs.forEach((defJp) => defJp.setName(newName));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else if ($jp instanceof NamedDecl) {
|
|
64
|
+
$jp.setName(newName);
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Checks if a given joinpoint represents an identifier with external linkage
|
|
70
|
+
*
|
|
71
|
+
* @param $jp The joinpoint to evaluate
|
|
72
|
+
* @returns True if the joinpoint has external linkage, false otherwise
|
|
73
|
+
*/
|
|
74
|
+
export function isExternalLinkageIdentifier($jp) {
|
|
75
|
+
if (!($jp instanceof FunctionJp || $jp instanceof Vardecl)) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
let result = $jp.storageClass !== StorageClass.STATIC && $jp.storageClass !== StorageClass.EXTERN && $jp.getAncestor("function") === undefined;
|
|
79
|
+
if ($jp instanceof FunctionJp) {
|
|
80
|
+
result = result && $jp.isImplementation;
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Checks if a given joinpoint represents an identifier with internal linkage
|
|
86
|
+
*
|
|
87
|
+
* @param $jp The joinpoint to evaluate
|
|
88
|
+
* @returns True if the joinpoint has internal linkage, false otherwise
|
|
89
|
+
*/
|
|
90
|
+
export function isInternalLinkageIdentifier($jp) {
|
|
91
|
+
if (!($jp instanceof FunctionJp || $jp instanceof Vardecl)) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
let result = $jp.storageClass === StorageClass.STATIC && $jp.getAncestor("function") === undefined;
|
|
95
|
+
if ($jp instanceof FunctionJp) {
|
|
96
|
+
result = result && $jp.isImplementation;
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Determines if an identifier is duplicated in a collection of join points
|
|
102
|
+
*
|
|
103
|
+
* @param $jp The identifier to evaluate
|
|
104
|
+
* @param $others Other join points to compare with
|
|
105
|
+
* @returns True if a duplicate exists, false otherwise
|
|
106
|
+
*/
|
|
107
|
+
export function isIdentifierDuplicated($jp, $others) {
|
|
108
|
+
return $others.some((identifier) => identifier.astId !== $jp.astId && !isSameVarDecl($jp, identifier) && areIdentifierNamesEqual($jp, identifier));
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Checks if another identifier with the same name is declared before the given joinpoint
|
|
112
|
+
*
|
|
113
|
+
* @param $jp The identifier join point to check
|
|
114
|
+
* @param $others The list of other identifiers to compare with
|
|
115
|
+
* @returns True if a matching identifier is declared earlier, false otherwise.
|
|
116
|
+
*/
|
|
117
|
+
export function isIdentifierNameDeclaredBefore($jp, $others) {
|
|
118
|
+
return $others.some((identifier) => {
|
|
119
|
+
return identifier.astId !== $jp.astId && !isSameVarDecl($jp, identifier) && compareLocation(identifier, $jp) < 0 && areIdentifierNamesEqual(identifier, $jp);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @returns Returns true if the identifiers represent different AST nodes but are not distinct within the first 31 characters. Otherwise returns false.
|
|
124
|
+
*/
|
|
125
|
+
export function areDistinctIdentifiers($jp1, $jp2) {
|
|
126
|
+
try {
|
|
127
|
+
return $jp1.astId !== $jp2.ast && $jp1.name.substring(0, 31) !== $jp2.name.substring(0, 31);
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=IdentifierUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdentifierUtils.js","sourceRoot":"","sources":["../../src/utils/IdentifierUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AACtI,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE/F;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAc;IAC3C,OAAQ,CAAC,GAAG,YAAY,OAAO,IAAI,GAAG,CAAC,YAAY,KAAK,YAAY,CAAC,MAAM,CAAC;QACpE,CAAC,GAAG,YAAY,UAAU,IAAI,GAAG,CAAC,gBAAgB,CAAC;QACnD,GAAG,YAAY,WAAW;QAC1B,GAAG,YAAY,SAAS;QACxB,SAAS,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAc;IAC5C,IAAI,GAAG,YAAY,SAAS,EAAE,CAAC;QAC3B,OAAO,GAAG,CAAC,IAAI,CAAC;IACpB,CAAC;SAAM,IAAI,GAAG,YAAY,SAAS,EAAE,CAAC;QAClC,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;IACzB,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,WAAsB,EAAE,WA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;QAC/B,OAAO,UAAU,CAAC,KAAK,KAAK,GAAG,CAAC,KAAK,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,eAAe,CAAC,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC,IAAI,uBAAuB,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;IAChK,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAA0B,EAAE,IAA0B;IACzF,IAAI,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChG,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Joinpoint, Type, RecordJp, EnumDecl } from "@specs-feup/clava/api/Joinpoints.js";
|
|
2
|
+
export type TagDecl = RecordJp | EnumDecl;
|
|
3
|
+
export declare function isTagDecl($jp: Joinpoint): $jp is TagDecl;
|
|
4
|
+
/**
|
|
5
|
+
* Checks if the provided node has a defined type
|
|
6
|
+
* @param $jp The joinpoint to check its type
|
|
7
|
+
* @returns true if the joinpoint has a defined type, otherwise false
|
|
8
|
+
*/
|
|
9
|
+
export declare function hasDefinedType($jp: Joinpoint): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves the base type of the provided joinpoint.
|
|
12
|
+
* @param $jp The joinpoint to retrieve its type
|
|
13
|
+
* @returns The base type of the joinpoint, or undefined if the joinpoint does not have a type
|
|
14
|
+
*/
|
|
15
|
+
export declare function getBaseType($jp: Joinpoint): Type | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Gets the file path of the given join point.
|
|
18
|
+
* @param $jp The join point
|
|
19
|
+
* @returns The file path string
|
|
20
|
+
*/
|
|
21
|
+
export declare function getFilepath($jp: Joinpoint): string;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the exact location of a given join point
|
|
24
|
+
* @param $jp The joinpoint to evaluate
|
|
25
|
+
* @returns A location string containing the filepath, line and column in the format "filepath@line:column"
|
|
26
|
+
*/
|
|
27
|
+
export declare function getFileLocation($jp: Joinpoint): string;
|
|
28
|
+
/**
|
|
29
|
+
* Orders two join points by their source location: filepath, line, and column
|
|
30
|
+
*
|
|
31
|
+
* @param $jp1 The first join point
|
|
32
|
+
* @param $jp2 The second join point
|
|
33
|
+
* @returns A negative value if $jp1 comes before $jp2, positive if after, or 0 if equal.
|
|
34
|
+
*/
|
|
35
|
+
export declare function compareLocation($jp1: Joinpoint, $jp2: Joinpoint): number;
|
|
36
|
+
//# sourceMappingURL=JoinpointUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JoinpointUtils.d.ts","sourceRoot":"","sources":["../../src/utils/JoinpointUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAA0B,QAAQ,EAAE,QAAQ,EAAwC,MAAM,qCAAqC,CAAC;AAExJ,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE1C,wBAAgB,SAAS,CAAC,GAAG,EAAE,SAAS,GAAI,GAAG,IAAI,OAAO,CAEzD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,CAQ5D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,CAElD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,SAAS,UAK7C;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CASxE"}
|