mirror of
https://github.com/github/codeql.git
synced 2025-12-21 19:26:31 +01:00
C++: Emit a NoOp during CFG construction for VLAs.
This commit is contained in:
@@ -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() }
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user