C++: Fix join ordering

This commit is contained in:
Mathias Vorreiter Pedersen
2020-04-21 13:25:06 +02:00
parent 8be1bfe8d0
commit a49d22e6e4

View File

@@ -423,6 +423,15 @@ predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo) {
simpleInstructionLocalFlowStep(nodeFrom.asInstruction(), nodeTo.asInstruction())
}
pragma[noinline]
private predicate getFieldSizeOfClass(Class c, Type type, int size) {
exists(Field f |
f.getDeclaringType() = c and
f.getType() = type and
type.getSize() = size
)
}
cached
private predicate simpleInstructionLocalFlowStep(Instruction iFrom, Instruction iTo) {
iTo.(CopyInstruction).getSourceValue() = iFrom
@@ -472,12 +481,11 @@ private predicate simpleInstructionLocalFlowStep(Instruction iFrom, Instruction
)
or
// Flow from stores to structs with a single field to a load of that field.
iTo.(LoadInstruction).getSourceValueOperand().getAnyDef() = iFrom.(StoreInstruction) and
exists(Class c, Type t |
c = iTo.getResultType() and
t = iFrom.getResultType() and
c.getAField().getUnspecifiedType() = t and
c.getSize() = t.getSize()
iTo.(LoadInstruction).getSourceValueOperand().getAnyDef() = iFrom and
exists(int size, Type type |
type = iFrom.getResultType() and
iTo.getResultType().getSize() = size and
getFieldSizeOfClass(iTo.getResultType(), type, size)
)
or
// Flow through modeled functions