import { Joinpoint } from "@specs-feup/clava/api/Joinpoints.js"; import MISRARule from "../../MISRARule.js"; import { AnalysisType, MISRATransformationReport } from "../../MISRA.js"; /** * MISRA-C Rule 16.2: A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement */ export default class Rule_16_2_TopLevelSwitch extends MISRARule { #private; /** * Scope of analysis */ readonly analysisType = AnalysisType.SINGLE_TRANSLATION_UNIT; /** * A positive integer starting from 1 that indicates the rule's priority, determining the order in which rules are applied. */ readonly priority = 4; /** * @returns Rule identifier according to MISRA-C:2012 */ get name(): string; /** * Checks if the given joinpoint is a switch statement with any misplaced case labels. * A case label is considered misplaced if it is not a direct child of the switch body. * * @param $jp - Joinpoint to analyze * @param logErrors - [logErrors=false] - Whether to log errors if a violation is detected * @returns Returns true if the joinpoint violates the rule, false otherwise */ match($jp: Joinpoint, logErrors?: boolean): boolean; /** * Transforms the joinpoint if it represents a switch with any misplaced case labels. * For that, each case label is moved to a new location within the switch. * * @param $jp - Joinpoint to transform * @returns Report detailing the transformation result */ apply($jp: Joinpoint): MISRATransformationReport; /** * Relocates a inner case to a new position while preserving control flow. * First, copies the instructions to be executed (direct siblings and fall-through code). * Then, moves the case to the new position and finally appends the copied instructions after the case. * * @param caseLabel The inner case to relocate */ private changeCaseLocation; /** * Retrieves the top-level case that contains a given inner case label. * * @param caseLabel - The inner case joinpoint * @returns The ancestor case that contains the given inner case */ private getCaseAncestor; } //# sourceMappingURL=Rule_16_2_TopLevelSwitch.d.ts.map