C++: Add an 'EdgeKind' column to 'getChildSuccessor'.

This commit is contained in:
Mathias Vorreiter Pedersen
2024-01-30 11:26:46 +00:00
parent a391f7802d
commit d2e8b88b24
9 changed files with 413 additions and 352 deletions

View File

@@ -52,28 +52,32 @@ abstract class TranslatedCall extends TranslatedExpr {
resultType = getTypeForPRValue(this.getCallResultType())
}
override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getQualifier() and
result = this.getFirstCallTargetInstruction()
or
child = this.getCallTarget() and
result = this.getFirstArgumentOrCallInstruction()
or
exists(int argIndex |
child = this.getArgument(argIndex) and
if exists(this.getArgument(argIndex + 1))
then result = this.getArgument(argIndex + 1).getFirstInstruction()
else result = this.getInstruction(CallTag())
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
kind instanceof GotoEdge and
(
child = this.getQualifier() and
result = this.getFirstCallTargetInstruction()
or
child = this.getCallTarget() and
result = this.getFirstArgumentOrCallInstruction()
or
exists(int argIndex |
child = this.getArgument(argIndex) and
if exists(this.getArgument(argIndex + 1))
then result = this.getArgument(argIndex + 1).getFirstInstruction()
else result = this.getInstruction(CallTag())
)
)
or
child = this.getSideEffects() and
if this.isNoReturn()
then
kind instanceof GotoEdge and
result =
any(UnreachedInstruction instr |
this.getEnclosingFunction().getFunction() = instr.getEnclosingFunction()
)
else result = this.getParent().getChildSuccessor(this)
else result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
@@ -203,12 +207,12 @@ abstract class TranslatedSideEffects extends TranslatedElement {
)
}
final override Instruction getChildSuccessor(TranslatedElement te) {
final override Instruction getChildSuccessor(TranslatedElement te, EdgeKind kind) {
exists(int i |
this.getChild(i) = te and
if exists(this.getChild(i + 1))
then result = this.getChild(i + 1).getFirstInstruction()
else result = this.getParent().getChildSuccessor(this)
then kind instanceof GotoEdge and result = this.getChild(i + 1).getFirstInstruction()
else result = this.getParent().getChildSuccessor(this, kind)
)
}
@@ -220,7 +224,8 @@ abstract class TranslatedSideEffects extends TranslatedElement {
result = this.getChild(0).getFirstInstruction()
or
// Some functions, like `std::move()`, have no side effects whatsoever.
not exists(this.getChild(0)) and result = this.getParent().getChildSuccessor(this)
not exists(this.getChild(0)) and
result = this.getParent().getChildSuccessor(this, any(GotoEdge edge))
}
final override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) { none() }
@@ -376,7 +381,7 @@ private int initializeAllocationGroup() { result = 3 }
abstract class TranslatedSideEffect extends TranslatedElement {
final override TranslatedElement getChild(int n) { none() }
final override Instruction getChildSuccessor(TranslatedElement child) { none() }
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) { none() }
final override Instruction getFirstInstruction() {
result = this.getInstruction(OnlyInstructionTag())
@@ -388,9 +393,8 @@ abstract class TranslatedSideEffect extends TranslatedElement {
}
final override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
result = this.getParent().getChildSuccessor(this) and
tag = OnlyInstructionTag() and
kind instanceof GotoEdge
result = this.getParent().getChildSuccessor(this, kind) and
tag = OnlyInstructionTag()
}
final override Declaration getFunction() { result = this.getParent().getFunction() }

View File

@@ -54,7 +54,7 @@ abstract class TranslatedFlexibleCondition extends TranslatedCondition, Conditio
final override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) { none() }
final override Instruction getChildSuccessor(TranslatedElement child) { none() }
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) { none() }
abstract TranslatedCondition getOperand();
}
@@ -80,7 +80,7 @@ class TranslatedParenthesisCondition extends TranslatedFlexibleCondition {
abstract class TranslatedNativeCondition extends TranslatedCondition, TTranslatedNativeCondition {
TranslatedNativeCondition() { this = TTranslatedNativeCondition(expr) }
final override Instruction getChildSuccessor(TranslatedElement child) { none() }
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) { none() }
}
abstract class TranslatedBinaryLogicalOperation extends TranslatedNativeCondition, ConditionContext {
@@ -158,9 +158,10 @@ class TranslatedValueCondition extends TranslatedCondition, TTranslatedValueCond
resultType = getVoidType()
}
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getValueExpr() and
result = this.getInstruction(ValueConditionConditionalBranchTag())
result = this.getInstruction(ValueConditionConditionalBranchTag()) and
kind instanceof GotoEdge
}
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {

View File

@@ -68,7 +68,7 @@ abstract class TranslatedLocalVariableDeclaration extends TranslatedVariableInit
}
final override Instruction getInitializationSuccessor() {
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, any(GotoEdge edge))
}
final override IRVariable getIRVariable() {
@@ -163,7 +163,7 @@ class TranslatedStaticLocalVariableDeclarationEntry extends TranslatedDeclaratio
tag = DynamicInitializationConditionalBranchTag() and
(
kind instanceof TrueEdge and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, any(GotoEdge edge))
or
kind instanceof FalseEdge and
result = this.getInitialization().getFirstInstruction()
@@ -174,13 +174,13 @@ class TranslatedStaticLocalVariableDeclarationEntry extends TranslatedDeclaratio
result = this.getInstruction(DynamicInitializationFlagStoreTag())
or
tag = DynamicInitializationFlagStoreTag() and
kind instanceof GotoEdge and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
}
final override Instruction getChildSuccessor(TranslatedElement child) {
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getInitialization() and
result = this.getInstruction(DynamicInitializationFlagConstantTag())
result = this.getInstruction(DynamicInitializationFlagConstantTag()) and
kind instanceof GotoEdge
}
final override IRDynamicInitializationFlag getInstructionVariable(InstructionTag tag) {

View File

@@ -904,9 +904,10 @@ abstract class TranslatedElement extends TTranslatedElement {
/**
* Gets the successor instruction to which control should flow after the
* child element specified by `child` has finished execution.
* child element specified by `child` has finished execution. The successor
* edge kind is specified by `kind`.
*/
abstract Instruction getChildSuccessor(TranslatedElement child);
abstract Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind);
/**
* Gets the instruction to which control should flow if an exception is thrown

View File

@@ -233,10 +233,10 @@ class TranslatedConditionValue extends TranslatedCoreExpr, ConditionContext,
or
tag = ConditionValueResultTempAddressTag() and
result = this.getInstruction(ConditionValueResultLoadTag())
or
tag = ConditionValueResultLoadTag() and
result = this.getParent().getChildSuccessor(this)
)
or
tag = ConditionValueResultLoadTag() and
result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getInstructionRegisterOperand(InstructionTag tag, OperandTag operandTag) {
@@ -287,7 +287,7 @@ class TranslatedConditionValue extends TranslatedCoreExpr, ConditionContext,
override Instruction getResult() { result = this.getInstruction(ConditionValueResultLoadTag()) }
override Instruction getChildSuccessor(TranslatedElement child) { none() }
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) { none() }
override Instruction getChildTrueSuccessor(TranslatedCondition child) {
child = this.getCondition() and
@@ -343,12 +343,13 @@ class TranslatedLoad extends TranslatedValueCategoryAdjustment, TTranslatedLoad
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = LoadTag() and
result = this.getParent().getChildSuccessor(this) and
kind instanceof GotoEdge
result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getOperand() and result = this.getInstruction(LoadTag())
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getOperand() and
result = this.getInstruction(LoadTag()) and
kind instanceof GotoEdge
}
override Instruction getResult() { result = this.getInstruction(LoadTag()) }
@@ -394,12 +395,13 @@ class TranslatedSyntheticTemporaryObject extends TranslatedValueCategoryAdjustme
kind instanceof GotoEdge
or
tag = InitializerStoreTag() and
result = this.getParent().getChildSuccessor(this) and
kind instanceof GotoEdge
result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getOperand() and result = this.getInstruction(InitializerVariableAddressTag())
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getOperand() and
result = this.getInstruction(InitializerVariableAddressTag()) and
kind instanceof GotoEdge
}
override Instruction getResult() { result = this.getInstruction(InitializerVariableAddressTag()) }
@@ -448,12 +450,13 @@ class TranslatedResultCopy extends TranslatedExpr, TTranslatedResultCopy {
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = ResultCopyTag() and
result = this.getParent().getChildSuccessor(this) and
kind instanceof GotoEdge
result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getOperand() and result = this.getInstruction(ResultCopyTag())
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getOperand() and
result = this.getInstruction(ResultCopyTag()) and
kind instanceof GotoEdge
}
override Instruction getResult() { result = this.getInstruction(ResultCopyTag()) }
@@ -486,11 +489,12 @@ class TranslatedCommaExpr extends TranslatedNonConstantExpr {
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) { none() }
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getLeftOperand() and
result = this.getRightOperand().getFirstInstruction()
result = this.getRightOperand().getFirstInstruction() and
kind instanceof GotoEdge
or
child = this.getRightOperand() and result = this.getParent().getChildSuccessor(this)
child = this.getRightOperand() and result = this.getParent().getChildSuccessor(this, kind)
}
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
@@ -591,14 +595,16 @@ abstract class TranslatedCrementOperation extends TranslatedNonConstantExpr {
or
tag = CrementOpTag() and
result = this.getInstruction(CrementStoreTag())
or
tag = CrementStoreTag() and
result = this.getParent().getChildSuccessor(this)
)
or
tag = CrementStoreTag() and
result = this.getParent().getChildSuccessor(this, kind)
}
final override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getLoadedOperand() and result = this.getInstruction(CrementConstantTag())
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getLoadedOperand() and
result = this.getInstruction(CrementConstantTag()) and
kind instanceof GotoEdge
}
final override int getInstructionElementSize(InstructionTag tag) {
@@ -692,16 +698,18 @@ class TranslatedArrayExpr extends TranslatedNonConstantExpr {
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = OnlyInstructionTag() and
result = this.getParent().getChildSuccessor(this) and
kind instanceof GotoEdge
result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getBaseOperand() and
result = this.getOffsetOperand().getFirstInstruction()
or
child = this.getOffsetOperand() and
result = this.getInstruction(OnlyInstructionTag())
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
kind instanceof GotoEdge and
(
child = this.getBaseOperand() and
result = this.getOffsetOperand().getFirstInstruction()
or
child = this.getOffsetOperand() and
result = this.getInstruction(OnlyInstructionTag())
)
}
override Instruction getResult() { result = this.getInstruction(OnlyInstructionTag()) }
@@ -746,8 +754,8 @@ abstract class TranslatedTransparentExpr extends TranslatedNonConstantExpr {
final override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) { none() }
final override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getOperand() and result = this.getParent().getChildSuccessor(this)
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getOperand() and result = this.getParent().getChildSuccessor(this, kind)
}
final override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
@@ -822,12 +830,11 @@ class TranslatedThisExpr extends TranslatedNonConstantExpr {
tag = ThisAddressTag() and
result = this.getInstruction(ThisLoadTag())
or
kind instanceof GotoEdge and
tag = ThisLoadTag() and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
}
final override Instruction getChildSuccessor(TranslatedElement child) { none() }
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) { none() }
final override Instruction getInstructionRegisterOperand(InstructionTag tag, OperandTag operandTag) {
tag = ThisLoadTag() and
@@ -856,12 +863,13 @@ abstract class TranslatedVariableAccess extends TranslatedNonConstantExpr {
final override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = OnlyInstructionTag() and
result = this.getParent().getChildSuccessor(this) and
kind instanceof GotoEdge
result = this.getParent().getChildSuccessor(this, kind)
}
final override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getQualifier() and result = this.getInstruction(OnlyInstructionTag())
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getQualifier() and
result = this.getInstruction(OnlyInstructionTag()) and
kind instanceof GotoEdge
}
}
@@ -958,11 +966,10 @@ class TranslatedStructuredBindingVariableAccess extends TranslatedNonConstantExp
result = this.getInstruction(LoadTag())
or
tag = LoadTag() and
kind instanceof GotoEdge and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getChildSuccessor(TranslatedElement child) { none() }
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) { none() }
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
tag = StructuredBindingAccessTag() and
@@ -1012,8 +1019,7 @@ class TranslatedFunctionAccess extends TranslatedNonConstantExpr {
final override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = OnlyInstructionTag() and
result = this.getParent().getChildSuccessor(this) and
kind instanceof GotoEdge
result = this.getParent().getChildSuccessor(this, kind)
}
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
@@ -1027,8 +1033,10 @@ class TranslatedFunctionAccess extends TranslatedNonConstantExpr {
result = expr.getTarget()
}
override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getQualifier() and result = this.getInstruction(OnlyInstructionTag())
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getQualifier() and
result = this.getInstruction(OnlyInstructionTag()) and
kind instanceof GotoEdge
}
}
@@ -1073,11 +1081,10 @@ abstract class TranslatedConstantExpr extends TranslatedCoreExpr, TTranslatedVal
final override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = OnlyInstructionTag() and
result = this.getParent().getChildSuccessor(this) and
kind instanceof GotoEdge
result = this.getParent().getChildSuccessor(this, kind)
}
final override Instruction getChildSuccessor(TranslatedElement child) { none() }
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) { none() }
abstract Opcode getOpcode();
}
@@ -1139,12 +1146,13 @@ class TranslatedUnaryExpr extends TranslatedSingleInstructionExpr {
final override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = OnlyInstructionTag() and
result = this.getParent().getChildSuccessor(this) and
kind instanceof GotoEdge
result = this.getParent().getChildSuccessor(this, kind)
}
final override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getOperand() and result = this.getInstruction(OnlyInstructionTag())
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getOperand() and
result = this.getInstruction(OnlyInstructionTag()) and
kind instanceof GotoEdge
}
final override Instruction getInstructionRegisterOperand(InstructionTag tag, OperandTag operandTag) {
@@ -1185,12 +1193,13 @@ abstract class TranslatedConversion extends TranslatedNonConstantExpr {
abstract class TranslatedSingleInstructionConversion extends TranslatedConversion {
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = OnlyInstructionTag() and
result = this.getParent().getChildSuccessor(this) and
kind instanceof GotoEdge
result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getOperand() and result = this.getInstruction(OnlyInstructionTag())
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getOperand() and
result = this.getInstruction(OnlyInstructionTag()) and
kind instanceof GotoEdge
}
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
@@ -1286,17 +1295,17 @@ class TranslatedBoolConversion extends TranslatedConversion {
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
kind instanceof GotoEdge and
(
tag = BoolConversionConstantTag() and
result = this.getInstruction(BoolConversionCompareTag())
or
tag = BoolConversionCompareTag() and
result = this.getParent().getChildSuccessor(this)
)
tag = BoolConversionConstantTag() and
result = this.getInstruction(BoolConversionCompareTag())
or
tag = BoolConversionCompareTag() and
result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getOperand() and result = this.getInstruction(BoolConversionConstantTag())
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getOperand() and
result = this.getInstruction(BoolConversionConstantTag()) and
kind instanceof GotoEdge
}
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
@@ -1435,14 +1444,14 @@ class TranslatedBinaryOperation extends TranslatedSingleInstructionExpr {
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = OnlyInstructionTag() and
result = this.getParent().getChildSuccessor(this) and
kind instanceof GotoEdge
result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getLeftOperand() and
result = this.getRightOperand().getFirstInstruction()
result = this.getRightOperand().getFirstInstruction(kind)
or
kind instanceof GotoEdge and
child = this.getRightOperand() and
result = this.getInstruction(OnlyInstructionTag())
}
@@ -1532,15 +1541,15 @@ class TranslatedAssignExpr extends TranslatedNonConstantExpr {
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = AssignmentStoreTag() and
result = this.getParent().getChildSuccessor(this) and
kind instanceof GotoEdge
result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
// Operands are evaluated right-to-left.
child = this.getRightOperand() and
result = this.getLeftOperand().getFirstInstruction()
result = this.getLeftOperand().getFirstInstruction(kind)
or
kind instanceof GotoEdge and
child = this.getLeftOperand() and
result = this.getInstruction(AssignmentStoreTag())
}
@@ -1593,11 +1602,10 @@ class TranslatedBlockAssignExpr extends TranslatedNonConstantExpr {
kind instanceof GotoEdge
or
tag = AssignmentStoreTag() and
result = this.getParent().getChildSuccessor(this) and
kind instanceof GotoEdge
result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getLeftOperand() and
result = this.getRightOperand().getFirstInstruction()
or
@@ -1697,13 +1705,13 @@ class TranslatedAssignOperation extends TranslatedNonConstantExpr {
or
tag = AssignOperationConvertResultTag() and
result = this.getInstruction(AssignmentStoreTag())
or
tag = AssignmentStoreTag() and
result = this.getParent().getChildSuccessor(this)
)
or
tag = AssignmentStoreTag() and
result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
// Operands are evaluated right-to-left.
child = this.getRightOperand() and
result = this.getLoadedLeftOperand().getFirstInstruction()
@@ -1880,13 +1888,12 @@ class TranslatedConstantAllocationSize extends TranslatedAllocationSize {
final override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = AllocationSizeTag() and
kind instanceof GotoEdge and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
}
final override TranslatedElement getChild(int id) { none() }
final override Instruction getChildSuccessor(TranslatedElement child) { none() }
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) { none() }
final override string getInstructionConstantValue(InstructionTag tag) {
tag = AllocationSizeTag() and
@@ -1933,16 +1940,17 @@ class TranslatedNonConstantAllocationSize extends TranslatedAllocationSize {
or
tag = AllocationElementSizeTag() and
result = this.getInstruction(AllocationSizeTag())
or
tag = AllocationSizeTag() and
result = this.getParent().getChildSuccessor(this)
)
or
tag = AllocationSizeTag() and
result = this.getParent().getChildSuccessor(this, kind)
}
final override TranslatedElement getChild(int id) { id = 0 and result = this.getExtent() }
final override Instruction getChildSuccessor(TranslatedElement child) {
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getExtent() and
kind instanceof GotoEdge and
if this.extentNeedsConversion()
then result = this.getInstruction(AllocationExtentConvertTag())
else result = this.getInstruction(AllocationElementSizeTag())
@@ -2135,9 +2143,9 @@ class TranslatedDestructorFieldDestruction extends TranslatedNonConstantExpr, St
result = this.getDestructorCall().getFirstInstruction()
}
final override Instruction getChildSuccessor(TranslatedElement child) {
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getDestructorCall() and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
}
final override Instruction getResult() { none() }
@@ -2216,9 +2224,9 @@ abstract class TranslatedConditionalExpr extends TranslatedNonConstantExpr {
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
not this.resultIsVoid() and
kind instanceof GotoEdge and
(
not this.thenIsVoid() and
kind instanceof GotoEdge and
(
tag = ConditionValueTrueTempAddressTag() and
result = this.getInstruction(ConditionValueTrueStoreTag())
@@ -2228,6 +2236,7 @@ abstract class TranslatedConditionalExpr extends TranslatedNonConstantExpr {
)
or
not this.elseIsVoid() and
kind instanceof GotoEdge and
(
tag = ConditionValueFalseTempAddressTag() and
result = this.getInstruction(ConditionValueFalseStoreTag())
@@ -2239,16 +2248,20 @@ abstract class TranslatedConditionalExpr extends TranslatedNonConstantExpr {
tag = ConditionValueResultTempAddressTag() and
if isExtractorFrontendVersion65OrHigher()
then
kind instanceof GotoEdge and
not expr.hasLValueToRValueConversion() and
result = this.getInstruction(ConditionValueResultLoadTag())
or
expr.hasLValueToRValueConversion() and
result = this.getParent().getChildSuccessor(this)
else result = this.getInstruction(ConditionValueResultLoadTag())
result = this.getParent().getChildSuccessor(this, kind)
else (
kind instanceof GotoEdge and
result = this.getInstruction(ConditionValueResultLoadTag())
)
or
(not expr.hasLValueToRValueConversion() or not isExtractorFrontendVersion65OrHigher()) and
tag = ConditionValueResultLoadTag() and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
)
}
@@ -2317,11 +2330,13 @@ abstract class TranslatedConditionalExpr extends TranslatedNonConstantExpr {
else result = this.getInstruction(ConditionValueResultLoadTag())
}
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getElse() and
if this.elseIsVoid()
then result = this.getParent().getChildSuccessor(this)
else result = this.getInstruction(ConditionValueFalseTempAddressTag())
then result = this.getParent().getChildSuccessor(this, kind)
else (
kind instanceof GotoEdge and result = this.getInstruction(ConditionValueFalseTempAddressTag())
)
}
/**
@@ -2372,14 +2387,17 @@ class TranslatedTernaryConditionalExpr extends TranslatedConditionalExpr, Condit
override Instruction getFirstInstruction() { result = this.getCondition().getFirstInstruction() }
override Instruction getChildSuccessor(TranslatedElement child) {
result = TranslatedConditionalExpr.super.getChildSuccessor(child)
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
result = TranslatedConditionalExpr.super.getChildSuccessor(child, kind)
or
(
child = this.getThen() and
if this.thenIsVoid()
then result = this.getParent().getChildSuccessor(this)
else result = this.getInstruction(ConditionValueTrueTempAddressTag())
then result = this.getParent().getChildSuccessor(this, kind)
else (
kind instanceof GotoEdge and
result = this.getInstruction(ConditionValueTrueTempAddressTag())
)
)
}
@@ -2452,9 +2470,10 @@ class TranslatedBinaryConditionalExpr extends TranslatedConditionalExpr {
result = this.getCondition().getResult()
}
override Instruction getChildSuccessor(TranslatedElement child) {
result = super.getChildSuccessor(child)
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
result = super.getChildSuccessor(child, kind)
or
kind instanceof GotoEdge and
child = this.getCondition() and
result = this.getInstruction(ValueConditionConditionalBranchTag())
}
@@ -2502,7 +2521,7 @@ class TranslatedTemporaryObjectExpr extends TranslatedNonConstantExpr,
}
final override Instruction getInitializationSuccessor() {
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, any(GotoEdge edge))
}
final override Instruction getResult() { result = this.getTargetAddress() }
@@ -2600,7 +2619,7 @@ class TranslatedReThrowExpr extends TranslatedThrowExpr {
override Instruction getFirstInstruction() { result = this.getInstruction(ThrowTag()) }
override Instruction getChildSuccessor(TranslatedElement child) { none() }
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) { none() }
final override Opcode getThrowOpcode() { result instanceof Opcode::ReThrow }
}
@@ -2635,11 +2654,11 @@ class TranslatedBuiltInOperation extends TranslatedNonConstantExpr {
final override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = OnlyInstructionTag() and
kind instanceof GotoEdge and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
}
final override Instruction getChildSuccessor(TranslatedElement child) {
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
kind instanceof GotoEdge and
exists(int id |
child = this.getChild(id) and
(
@@ -2762,13 +2781,13 @@ class TranslatedVarArgsStart extends TranslatedNonConstantExpr {
result = this.getVAList().getFirstInstruction()
or
tag = VarArgsVAListStoreTag() and
kind instanceof GotoEdge and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
}
final override Instruction getChildSuccessor(TranslatedElement child) {
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getVAList() and
result = this.getInstruction(VarArgsVAListStoreTag())
result = this.getInstruction(VarArgsVAListStoreTag()) and
kind instanceof GotoEdge
}
final override IRVariable getInstructionVariable(InstructionTag tag) {
@@ -2840,13 +2859,13 @@ class TranslatedVarArg extends TranslatedNonConstantExpr {
result = this.getInstruction(VarArgsVAListStoreTag())
or
tag = VarArgsVAListStoreTag() and
kind instanceof GotoEdge and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
}
final override Instruction getChildSuccessor(TranslatedElement child) {
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getVAList() and
result = this.getInstruction(VarArgsVAListLoadTag())
result = this.getInstruction(VarArgsVAListLoadTag()) and
kind instanceof GotoEdge
}
final override Instruction getInstructionRegisterOperand(InstructionTag tag, OperandTag operandTag) {
@@ -2900,13 +2919,13 @@ class TranslatedVarArgsEnd extends TranslatedNonConstantExpr {
final override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = OnlyInstructionTag() and
kind instanceof GotoEdge and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
}
final override Instruction getChildSuccessor(TranslatedElement child) {
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getVAList() and
result = this.getInstruction(OnlyInstructionTag())
result = this.getInstruction(OnlyInstructionTag()) and
kind instanceof GotoEdge
}
final override Instruction getInstructionRegisterOperand(InstructionTag tag, OperandTag operandTag) {
@@ -2958,11 +2977,10 @@ class TranslatedVarArgCopy extends TranslatedNonConstantExpr {
result = this.getDestinationVAList().getFirstInstruction()
or
tag = VarArgsVAListStoreTag() and
kind instanceof GotoEdge and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
}
final override Instruction getChildSuccessor(TranslatedElement child) {
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getSourceVAList() and
result = this.getInstruction(VarArgsVAListLoadTag())
or
@@ -3015,14 +3033,16 @@ abstract class TranslatedNewOrNewArrayExpr extends TranslatedNonConstantExpr, In
kind instanceof GotoEdge and
tag = OnlyInstructionTag() and
if exists(this.getInitialization())
then result = this.getInitialization().getFirstInstruction()
else result = this.getParent().getChildSuccessor(this)
then kind instanceof GotoEdge and result = this.getInitialization().getFirstInstruction()
else result = this.getParent().getChildSuccessor(this, kind)
}
final override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getAllocatorCall() and result = this.getInstruction(OnlyInstructionTag())
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
kind instanceof GotoEdge and
child = this.getAllocatorCall() and
result = this.getInstruction(OnlyInstructionTag())
or
child = this.getInitialization() and result = this.getParent().getChildSuccessor(this)
child = this.getInitialization() and result = this.getParent().getChildSuccessor(this, kind)
}
final override Instruction getInstructionRegisterOperand(InstructionTag tag, OperandTag operandTag) {
@@ -3090,11 +3110,12 @@ class TranslatedConditionDeclExpr extends TranslatedNonConstantExpr {
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) { none() }
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
kind instanceof GotoEdge and
child = this.getDecl() and
result = this.getConditionExpr().getFirstInstruction()
or
child = this.getConditionExpr() and result = this.getParent().getChildSuccessor(this)
child = this.getConditionExpr() and result = this.getParent().getChildSuccessor(this, kind)
}
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
@@ -3137,13 +3158,13 @@ class TranslatedLambdaExpr extends TranslatedNonConstantExpr, InitializationCont
)
or
tag = LoadTag() and
kind instanceof GotoEdge and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getInitialization() and
result = this.getInstruction(LoadTag())
result = this.getInstruction(LoadTag()) and
kind instanceof GotoEdge
}
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
@@ -3211,13 +3232,13 @@ class TranslatedStmtExpr extends TranslatedNonConstantExpr {
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag instanceof OnlyInstructionTag and
kind instanceof GotoEdge and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getStmt() and
result = this.getInstruction(OnlyInstructionTag())
result = this.getInstruction(OnlyInstructionTag()) and
kind instanceof GotoEdge
}
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
@@ -3248,11 +3269,10 @@ class TranslatedErrorExpr extends TranslatedSingleInstructionExpr {
final override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = OnlyInstructionTag() and
result = this.getParent().getChildSuccessor(this) and
kind instanceof GotoEdge
result = this.getParent().getChildSuccessor(this, kind)
}
final override Instruction getChildSuccessor(TranslatedElement child) { none() }
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) { none() }
final override Instruction getInstructionRegisterOperand(InstructionTag tag, OperandTag operandTag) {
none()
@@ -3342,9 +3362,8 @@ class TranslatedAssumeExpr extends TranslatedSingleInstructionExpr {
final override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = OnlyInstructionTag() and
result = this.getParent().getChildSuccessor(this) and
kind instanceof GotoEdge
result = this.getParent().getChildSuccessor(this, kind)
}
final override Instruction getChildSuccessor(TranslatedElement child) { none() }
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) { none() }
}

View File

@@ -146,29 +146,32 @@ class TranslatedFunction extends TranslatedRootElement, TTranslatedFunction {
)
}
final override Instruction getChildSuccessor(TranslatedElement child) {
exists(int paramIndex |
child = this.getParameter(paramIndex) and
if
exists(func.getParameter(paramIndex + 1)) or
getEllipsisParameterIndexForFunction(func) = paramIndex + 1
then result = this.getParameter(paramIndex + 1).getFirstInstruction()
else result = this.getConstructorInitList().getFirstInstruction()
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
kind instanceof GotoEdge and
(
exists(int paramIndex |
child = this.getParameter(paramIndex) and
if
exists(func.getParameter(paramIndex + 1)) or
getEllipsisParameterIndexForFunction(func) = paramIndex + 1
then result = this.getParameter(paramIndex + 1).getFirstInstruction()
else result = this.getConstructorInitList().getFirstInstruction()
)
or
child = this.getConstructorInitList() and
result = this.getBody().getFirstInstruction()
or
child = this.getBody() and
result = this.getReturnSuccessorInstruction()
or
child = this.getDestructorDestructionList() and
result = this.getReadEffects().getFirstInstruction()
or
child = this.getReadEffects() and
if this.hasReturnValue()
then result = this.getInstruction(ReturnValueAddressTag())
else result = this.getInstruction(ReturnTag())
)
or
child = this.getConstructorInitList() and
result = this.getBody().getFirstInstruction()
or
child = this.getBody() and
result = this.getReturnSuccessorInstruction()
or
child = this.getDestructorDestructionList() and
result = this.getReadEffects().getFirstInstruction()
or
child = this.getReadEffects() and
if this.hasReturnValue()
then result = this.getInstruction(ReturnValueAddressTag())
else result = this.getInstruction(ReturnTag())
}
final override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
@@ -375,24 +378,23 @@ abstract class TranslatedParameter extends TranslatedElement {
final override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
kind instanceof GotoEdge and
(
tag = InitializerVariableAddressTag() and
result = this.getInstruction(InitializerStoreTag())
or
tag = InitializerStoreTag() and
if this.hasIndirection()
then result = this.getInstruction(InitializerIndirectAddressTag())
else result = this.getParent().getChildSuccessor(this)
or
tag = InitializerIndirectAddressTag() and
result = this.getInstruction(InitializerIndirectStoreTag())
or
tag = InitializerIndirectStoreTag() and
result = this.getParent().getChildSuccessor(this)
)
tag = InitializerVariableAddressTag() and
result = this.getInstruction(InitializerStoreTag())
or
tag = InitializerStoreTag() and
if this.hasIndirection()
then kind instanceof GotoEdge and result = this.getInstruction(InitializerIndirectAddressTag())
else result = this.getParent().getChildSuccessor(this, kind)
or
kind instanceof GotoEdge and
tag = InitializerIndirectAddressTag() and
result = this.getInstruction(InitializerIndirectStoreTag())
or
tag = InitializerIndirectStoreTag() and
result = this.getParent().getChildSuccessor(this, kind)
}
final override Instruction getChildSuccessor(TranslatedElement child) { none() }
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) { none() }
final override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
tag = InitializerVariableAddressTag() and
@@ -603,7 +605,7 @@ class TranslatedConstructorInitList extends TranslatedElement, InitializationCon
override Instruction getFirstInstruction() {
if exists(this.getChild(0))
then result = this.getChild(0).getFirstInstruction()
else result = this.getParent().getChildSuccessor(this)
else result = this.getParent().getChildSuccessor(this, any(GotoEdge edge))
}
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
@@ -614,12 +616,12 @@ class TranslatedConstructorInitList extends TranslatedElement, InitializationCon
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) { none() }
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
exists(int id |
child = this.getChild(id) and
if exists(this.getChild(id + 1))
then result = this.getChild(id + 1).getFirstInstruction()
else result = this.getParent().getChildSuccessor(this)
then kind instanceof GotoEdge and result = this.getChild(id + 1).getFirstInstruction()
else result = this.getParent().getChildSuccessor(this, kind)
)
}
@@ -670,7 +672,7 @@ class TranslatedDestructorDestructionList extends TranslatedElement,
override Instruction getFirstInstruction() {
if exists(this.getChild(0))
then result = this.getChild(0).getFirstInstruction()
else result = this.getParent().getChildSuccessor(this)
else result = this.getParent().getChildSuccessor(this, any(GotoEdge edge))
}
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
@@ -681,12 +683,12 @@ class TranslatedDestructorDestructionList extends TranslatedElement,
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) { none() }
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
exists(int id |
child = this.getChild(id) and
if exists(this.getChild(id + 1))
then result = this.getChild(id + 1).getFirstInstruction()
else result = this.getParent().getChildSuccessor(this)
then kind instanceof GotoEdge and result = this.getChild(id + 1).getFirstInstruction()
else result = this.getParent().getChildSuccessor(this, kind)
)
}
}
@@ -720,20 +722,21 @@ class TranslatedReadEffects extends TranslatedElement, TTranslatedReadEffects {
result =
min(TranslatedElement child, int id | child = this.getChild(id) | child order by id)
.getFirstInstruction()
else result = this.getParent().getChildSuccessor(this)
else result = this.getParent().getChildSuccessor(this, any(GotoEdge edge))
}
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
exists(int id | child = this.getChild(id) |
if exists(TranslatedReadEffect child2, int id2 | id2 > id and child2 = this.getChild(id2))
then
kind instanceof GotoEdge and
result =
min(TranslatedReadEffect child2, int id2 |
child2 = this.getChild(id2) and id2 > id
|
child2 order by id2
).getFirstInstruction()
else result = this.getParent().getChildSuccessor(this)
else result = this.getParent().getChildSuccessor(this, kind)
)
}
@@ -755,12 +758,11 @@ private TranslatedParameterReadEffect getTranslatedParameterReadEffect(Parameter
abstract class TranslatedReadEffect extends TranslatedElement {
override TranslatedElement getChild(int id) { none() }
override Instruction getChildSuccessor(TranslatedElement child) { none() }
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) { none() }
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = OnlyInstructionTag() and
kind = EdgeKind::gotoEdge() and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getFirstInstruction() { result = this.getInstruction(OnlyInstructionTag()) }

View File

@@ -75,9 +75,10 @@ class TranslatedStaticStorageDurationVarInit extends TranslatedRootElement,
)
}
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getChild(1) and
result = this.getInstruction(ReturnTag())
result = this.getInstruction(ReturnTag()) and
kind instanceof GotoEdge
}
final override CppType getInstructionMemoryOperandType(

View File

@@ -71,8 +71,10 @@ abstract class TranslatedVariableInitialization extends TranslatedElement, Initi
)
}
final override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getInitialization() and result = this.getInitializationSuccessor()
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getInitialization() and
result = this.getInitializationSuccessor() and
kind instanceof GotoEdge
}
override Instruction getInstructionRegisterOperand(InstructionTag tag, OperandTag operandTag) {
@@ -171,15 +173,16 @@ abstract class TranslatedListInitialization extends TranslatedInitialization, In
override Instruction getFirstInstruction() {
result = this.getChild(0).getFirstInstruction()
or
not exists(this.getChild(0)) and result = this.getParent().getChildSuccessor(this)
not exists(this.getChild(0)) and
result = this.getParent().getChildSuccessor(this, any(GotoEdge edge))
}
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
exists(int index |
child = this.getChild(index) and
if exists(this.getChild(index + 1))
then result = this.getChild(index + 1).getFirstInstruction()
else result = this.getParent().getChildSuccessor(this)
then kind instanceof GotoEdge and result = this.getChild(index + 1).getFirstInstruction()
else result = this.getParent().getChildSuccessor(this, kind)
)
}
@@ -265,12 +268,13 @@ class TranslatedSimpleDirectInitialization extends TranslatedDirectInitializatio
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = InitializerStoreTag() and
result = this.getParent().getChildSuccessor(this) and
kind instanceof GotoEdge
result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getInitializer() and result = this.getInstruction(InitializerStoreTag())
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getInitializer() and
result = this.getInstruction(InitializerStoreTag()) and
kind instanceof GotoEdge
}
override Instruction getInstructionRegisterOperand(InstructionTag tag, OperandTag operandTag) {
@@ -335,12 +339,13 @@ class TranslatedStringLiteralInitialization extends TranslatedDirectInitializati
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
kind instanceof GotoEdge and
(
tag = InitializerLoadStringTag() and
result = this.getInstruction(InitializerStoreTag())
or
if this.zeroInitRange(_, _)
then (
tag = InitializerLoadStringTag() and
result = this.getInstruction(InitializerStoreTag())
or
if this.zeroInitRange(_, _)
then (
kind instanceof GotoEdge and
(
tag = InitializerStoreTag() and
result = this.getInstruction(ZeroPadStringConstantTag())
or
@@ -352,18 +357,20 @@ class TranslatedStringLiteralInitialization extends TranslatedDirectInitializati
or
tag = ZeroPadStringElementAddressTag() and
result = this.getInstruction(ZeroPadStringStoreTag())
or
tag = ZeroPadStringStoreTag() and
result = this.getParent().getChildSuccessor(this)
) else (
tag = InitializerStoreTag() and
result = this.getParent().getChildSuccessor(this)
)
or
tag = ZeroPadStringStoreTag() and
result = this.getParent().getChildSuccessor(this, kind)
) else (
tag = InitializerStoreTag() and
result = this.getParent().getChildSuccessor(this, kind)
)
}
override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getInitializer() and result = this.getInstruction(InitializerLoadStringTag())
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getInitializer() and
result = this.getInstruction(InitializerLoadStringTag()) and
kind instanceof GotoEdge
}
override Instruction getInstructionRegisterOperand(InstructionTag tag, OperandTag operandTag) {
@@ -456,8 +463,8 @@ class TranslatedConstructorInitialization extends TranslatedDirectInitialization
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) { none() }
override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getInitializer() and result = this.getParent().getChildSuccessor(this)
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getInitializer() and result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getInstructionRegisterOperand(InstructionTag tag, OperandTag operandTag) {
@@ -562,8 +569,8 @@ class TranslatedExplicitFieldInitialization extends TranslatedFieldInitializatio
kind instanceof GotoEdge
}
override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getInitialization() and result = this.getParent().getChildSuccessor(this)
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getInitialization() and result = this.getParent().getChildSuccessor(this, kind)
}
override TranslatedElement getChild(int id) { id = 0 and result = this.getInitialization() }
@@ -608,10 +615,10 @@ class TranslatedFieldValueInitialization extends TranslatedFieldInitialization,
or
tag = this.getFieldDefaultValueTag() and
result = this.getInstruction(this.getFieldDefaultValueStoreTag())
or
tag = this.getFieldDefaultValueStoreTag() and
result = this.getParent().getChildSuccessor(this)
)
or
tag = this.getFieldDefaultValueStoreTag() and
result = this.getParent().getChildSuccessor(this, kind)
}
override string getInstructionConstantValue(InstructionTag tag) {
@@ -632,7 +639,7 @@ class TranslatedFieldValueInitialization extends TranslatedFieldInitialization,
)
}
override Instruction getChildSuccessor(TranslatedElement child) { none() }
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) { none() }
override TranslatedElement getChild(int id) { none() }
@@ -749,8 +756,8 @@ class TranslatedExplicitElementInitialization extends TranslatedElementInitializ
kind instanceof GotoEdge
}
override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getInitialization() and result = this.getParent().getChildSuccessor(this)
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getInitialization() and result = this.getParent().getChildSuccessor(this, kind)
}
override TranslatedElement getChild(int id) { id = 0 and result = this.getInitialization() }
@@ -803,10 +810,10 @@ class TranslatedElementValueInitialization extends TranslatedElementInitializati
or
tag = this.getElementDefaultValueTag() and
result = this.getInstruction(this.getElementDefaultValueStoreTag())
or
tag = this.getElementDefaultValueStoreTag() and
result = this.getParent().getChildSuccessor(this)
)
or
tag = this.getElementDefaultValueStoreTag() and
result = this.getParent().getChildSuccessor(this, kind)
}
override string getInstructionConstantValue(InstructionTag tag) {
@@ -829,7 +836,7 @@ class TranslatedElementValueInitialization extends TranslatedElementInitializati
)
}
override Instruction getChildSuccessor(TranslatedElement child) { none() }
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) { none() }
override TranslatedElement getChild(int id) { none() }
@@ -869,9 +876,9 @@ abstract class TranslatedStructorCallFromStructor extends TranslatedElement, Str
final override Function getFunction() { result = getEnclosingFunction(call) }
final override Instruction getChildSuccessor(TranslatedElement child) {
final override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getStructorCall() and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
}
final TranslatedExpr getStructorCall() { result = getTranslatedExpr(call) }
@@ -998,7 +1005,9 @@ class TranslatedConstructorBareInit extends TranslatedElement, TTranslatedConstr
final override string toString() { result = "construct base (no constructor)" }
override Instruction getFirstInstruction() { result = this.getParent().getChildSuccessor(this) }
override Instruction getFirstInstruction() {
result = this.getParent().getChildSuccessor(this, any(GotoEdge edge))
}
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
none()
@@ -1010,7 +1019,7 @@ class TranslatedConstructorBareInit extends TranslatedElement, TTranslatedConstr
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) { none() }
override Instruction getChildSuccessor(TranslatedElement child) { none() }
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) { none() }
}
TranslatedConstructorBareInit getTranslatedConstructorBareInit(ConstructorInit init) {

View File

@@ -199,16 +199,16 @@ class TranslatedMicrosoftTryExceptHandler extends TranslatedElement,
or
// Unwind -> Parent
tag = UnwindTag() and
kind instanceof GotoEdge and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
kind instanceof GotoEdge and
child = this.getTranslatedCondition() and
result = this.getInstruction(TryExceptGenerateNegativeOne())
or
child = this.getTranslatedHandler() and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
}
private TranslatedExpr getTranslatedCondition() {
@@ -264,11 +264,10 @@ class TranslatedEmptyStmt extends TranslatedStmt {
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = OnlyInstructionTag() and
result = this.getParent().getChildSuccessor(this) and
kind instanceof GotoEdge
result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getChildSuccessor(TranslatedElement child) { none() }
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) { none() }
}
/**
@@ -288,7 +287,8 @@ class TranslatedDeclStmt extends TranslatedStmt {
override Instruction getFirstInstruction() {
result = this.getDeclarationEntry(0).getFirstInstruction()
or
not exists(this.getDeclarationEntry(0)) and result = this.getParent().getChildSuccessor(this)
not exists(this.getDeclarationEntry(0)) and
result = this.getParent().getChildSuccessor(this, any(GotoEdge edge))
}
private int getChildCount() { result = count(this.getDeclarationEntry(_)) }
@@ -317,12 +317,15 @@ class TranslatedDeclStmt extends TranslatedStmt {
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) { none() }
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
exists(int index |
child = this.getDeclarationEntry(index) and
if index = (this.getChildCount() - 1)
then result = this.getParent().getChildSuccessor(this)
else result = this.getDeclarationEntry(index + 1).getFirstInstruction()
then result = this.getParent().getChildSuccessor(this, kind)
else (
kind instanceof GotoEdge and
result = this.getDeclarationEntry(index + 1).getFirstInstruction()
)
)
}
}
@@ -342,9 +345,9 @@ class TranslatedExprStmt extends TranslatedStmt {
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) { none() }
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getExpr() and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
}
}
@@ -404,9 +407,10 @@ class TranslatedReturnVoidExpressionStmt extends TranslatedReturnStmt {
kind instanceof GotoEdge
}
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getExpr() and
result = this.getInstruction(OnlyInstructionTag())
result = this.getInstruction(OnlyInstructionTag()) and
kind instanceof GotoEdge
}
private TranslatedExpr getExpr() { result = getTranslatedExpr(stmt.getExpr()) }
@@ -437,7 +441,7 @@ class TranslatedReturnVoidStmt extends TranslatedReturnStmt {
kind instanceof GotoEdge
}
override Instruction getChildSuccessor(TranslatedElement child) { none() }
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) { none() }
}
/**
@@ -526,21 +530,22 @@ class TranslatedTryStmt extends TranslatedStmt {
override Instruction getFirstInstruction() { result = this.getBody().getFirstInstruction() }
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
// All non-finally children go to the successor of the `try` if
// there is no finally block, but if there is a finally block
// then we go to that one.
child = [this.getBody(), this.getHandler(_)] and
(
not exists(this.getFinally()) and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
or
kind instanceof GotoEdge and
result = this.getFinally().getFirstInstruction()
)
or
// And after the finally block we go to the successor of the `try`.
child = this.getFinally() and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
}
final Instruction getNextHandler(TranslatedHandler handler) {
@@ -593,16 +598,17 @@ class TranslatedBlock extends TranslatedStmt {
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = OnlyInstructionTag() and
result = this.getParent().getChildSuccessor(this) and
kind instanceof GotoEdge
result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
exists(int index |
child = this.getStmt(index) and
if index = (this.getStmtCount() - 1)
then result = this.getParent().getChildSuccessor(this)
else result = this.getStmt(index + 1).getFirstInstruction()
then result = this.getParent().getChildSuccessor(this, kind)
else (
kind instanceof GotoEdge and result = this.getStmt(index + 1).getFirstInstruction()
)
)
}
}
@@ -617,8 +623,8 @@ abstract class TranslatedHandler extends TranslatedStmt {
override Instruction getFirstInstruction() { result = this.getInstruction(CatchTag()) }
override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getBlock() and result = this.getParent().getChildSuccessor(this)
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getBlock() and result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getExceptionSuccessorInstruction() {
@@ -649,10 +655,12 @@ class TranslatedCatchByTypeHandler extends TranslatedHandler {
id = 0 and result = this.getParameter()
}
override Instruction getChildSuccessor(TranslatedElement child) {
result = super.getChildSuccessor(child)
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
result = super.getChildSuccessor(child, kind)
or
child = this.getParameter() and result = this.getBlock().getFirstInstruction()
kind instanceof GotoEdge and
child = this.getParameter() and
result = this.getBlock().getFirstInstruction()
}
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
@@ -745,15 +753,16 @@ class TranslatedIfStmt extends TranslatedStmt, ConditionContext {
child = this.getCondition() and
if this.hasElse()
then result = this.getElse().getFirstInstruction()
else result = this.getParent().getChildSuccessor(this)
else result = this.getParent().getChildSuccessor(this, any(GotoEdge edge))
}
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
kind instanceof GotoEdge and
child = this.getInitialization() and
result = this.getFirstConditionInstruction()
or
(child = this.getThen() or child = this.getElse()) and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
}
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
@@ -795,7 +804,8 @@ abstract class TranslatedLoop extends TranslatedStmt, ConditionContext {
}
final override Instruction getChildFalseSuccessor(TranslatedCondition child) {
child = this.getCondition() and result = this.getParent().getChildSuccessor(this)
child = this.getCondition() and
result = this.getParent().getChildSuccessor(this, any(GotoEdge edge))
}
}
@@ -804,8 +814,10 @@ class TranslatedWhileStmt extends TranslatedLoop {
override Instruction getFirstInstruction() { result = this.getFirstConditionInstruction() }
override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getBody() and result = this.getFirstConditionInstruction()
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getBody() and
result = this.getFirstConditionInstruction() and
kind instanceof GotoEdge
}
}
@@ -814,8 +826,10 @@ class TranslatedDoStmt extends TranslatedLoop {
override Instruction getFirstInstruction() { result = this.getBody().getFirstInstruction() }
override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getBody() and result = this.getFirstConditionInstruction()
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getBody() and
result = this.getFirstConditionInstruction() and
kind instanceof GotoEdge
}
}
@@ -848,18 +862,21 @@ class TranslatedForStmt extends TranslatedLoop {
else result = this.getFirstConditionInstruction()
}
override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getInitialization() and
result = this.getFirstConditionInstruction()
or
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
kind instanceof GotoEdge and
(
child = this.getBody() and
if this.hasUpdate()
then result = this.getUpdate().getFirstInstruction()
else result = this.getFirstConditionInstruction()
child = this.getInitialization() and
result = this.getFirstConditionInstruction()
or
(
child = this.getBody() and
if this.hasUpdate()
then result = this.getUpdate().getFirstInstruction()
else result = this.getFirstConditionInstruction()
)
or
child = this.getUpdate() and result = this.getFirstConditionInstruction()
)
or
child = this.getUpdate() and result = this.getFirstConditionInstruction()
}
}
@@ -892,21 +909,24 @@ class TranslatedRangeBasedForStmt extends TranslatedStmt, ConditionContext {
result = this.getRangeVariableDeclStmt().getFirstInstruction()
}
override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getRangeVariableDeclStmt() and
result = this.getBeginEndVariableDeclStmt().getFirstInstruction()
or
child = this.getBeginEndVariableDeclStmt() and
result = this.getCondition().getFirstInstruction()
or
child = this.getVariableDeclStmt() and
result = this.getBody().getFirstInstruction()
or
child = this.getBody() and
result = this.getUpdate().getFirstInstruction()
or
child = this.getUpdate() and
result = this.getCondition().getFirstInstruction()
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
kind instanceof GotoEdge and
(
child = this.getRangeVariableDeclStmt() and
result = this.getBeginEndVariableDeclStmt().getFirstInstruction()
or
child = this.getBeginEndVariableDeclStmt() and
result = this.getCondition().getFirstInstruction()
or
child = this.getVariableDeclStmt() and
result = this.getBody().getFirstInstruction()
or
child = this.getBody() and
result = this.getUpdate().getFirstInstruction()
or
child = this.getUpdate() and
result = this.getCondition().getFirstInstruction()
)
}
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
@@ -920,7 +940,8 @@ class TranslatedRangeBasedForStmt extends TranslatedStmt, ConditionContext {
}
override Instruction getChildFalseSuccessor(TranslatedCondition child) {
child = this.getCondition() and result = this.getParent().getChildSuccessor(this)
child = this.getCondition() and
result = this.getParent().getChildSuccessor(this, any(GotoEdge edge))
}
private TranslatedDeclStmt getRangeVariableDeclStmt() {
@@ -976,7 +997,7 @@ class TranslatedJumpStmt extends TranslatedStmt {
result = getTranslatedStmt(stmt.getTarget()).getFirstInstruction()
}
override Instruction getChildSuccessor(TranslatedElement child) { none() }
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) { none() }
}
private EdgeKind getCaseEdge(SwitchCase switchCase) {
@@ -1042,15 +1063,19 @@ class TranslatedSwitchStmt extends TranslatedStmt {
not stmt.hasDefaultCase() and
tag = SwitchBranchTag() and
kind instanceof DefaultEdge and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, any(GotoEdge edge))
}
override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getInitialization() and result = this.getFirstExprInstruction()
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
kind instanceof GotoEdge and
child = this.getInitialization() and
result = this.getFirstExprInstruction()
or
child = this.getExpr() and result = this.getInstruction(SwitchBranchTag())
kind instanceof GotoEdge and
child = this.getExpr() and
result = this.getInstruction(SwitchBranchTag())
or
child = this.getBody() and result = this.getParent().getChildSuccessor(this)
child = this.getBody() and result = this.getParent().getChildSuccessor(this, kind)
}
}
@@ -1091,11 +1116,11 @@ class TranslatedAsmStmt extends TranslatedStmt {
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = AsmTag() and
result = this.getParent().getChildSuccessor(this) and
kind instanceof GotoEdge
result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
kind instanceof GotoEdge and
exists(int index |
child = this.getChild(index) and
if exists(this.getChild(index + 1))
@@ -1121,9 +1146,9 @@ class TranslatedVlaDimensionStmt extends TranslatedStmt {
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) { none() }
override Instruction getChildSuccessor(TranslatedElement child) {
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
child = this.getChild(0) and
result = this.getParent().getChildSuccessor(this)
result = this.getParent().getChildSuccessor(this, kind)
}
}
@@ -1144,9 +1169,8 @@ class TranslatedVlaDeclarationStmt extends TranslatedStmt {
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = OnlyInstructionTag() and
result = this.getParent().getChildSuccessor(this) and
kind instanceof GotoEdge
result = this.getParent().getChildSuccessor(this, kind)
}
override Instruction getChildSuccessor(TranslatedElement child) { none() }
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) { none() }
}