diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedStmt.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedStmt.qll index da4183ca25c..064425476f7 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedStmt.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedStmt.qll @@ -1105,3 +1105,49 @@ class TranslatedAsmStmt extends TranslatedStmt { ) } } + +class TranslatedVlaDimensionStmt extends TranslatedStmt { + override VlaDimensionStmt stmt; + + override TranslatedExpr getChild(int id) { + id = 0 and + result = getTranslatedExpr(stmt.getDimensionExpr().getFullyConverted()) + } + + override Instruction getFirstInstruction() { result = getChild(0).getFirstInstruction() } + + override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) { + none() + } + + override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) { none() } + + override Instruction getChildSuccessor(TranslatedElement child) { + child = getChild(0) and + result = getParent().getChildSuccessor(this) + } +} + +class TranslatedVlaDeclarationStmt extends TranslatedStmt { + override VlaDeclStmt stmt; + + override TranslatedExpr getChild(int id) { none() } + + override Instruction getFirstInstruction() { result = getInstruction(OnlyInstructionTag()) } + + override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) { + // TODO: This needs a new kind of instruction that represents initialization of a VLA. + // For now we just emit a `NoOp` instruction so that the CFG isn't incomplete. + tag = OnlyInstructionTag() and + opcode instanceof Opcode::NoOp and + resultType = getVoidType() + } + + override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) { + tag = OnlyInstructionTag() and + result = getParent().getChildSuccessor(this) and + kind instanceof GotoEdge + } + + override Instruction getChildSuccessor(TranslatedElement child) { none() } +}