Add further hints that the range of possible addressed fields, and therefore the interesting selector expressions, are small

This commit is contained in:
Chris Smowton
2021-03-16 10:45:25 +00:00
committed by Owen Mansel-Chan
parent 22a3fccf79
commit 9444774895

View File

@@ -48,13 +48,13 @@ private predicate isCond(Expr e) {
e = any(ParenExpr par | isCond(par)).getExpr()
}
private class PromotedField extends Field {
PromotedField() { this = any(StructType t).getFieldOfEmbedded(_, _, _, _) }
private Type getSelectedStructType(PromotedFieldSelector e) {
pragma[only_bind_into](result) = e.getBase().getType().getBaseType*().getUnderlyingType()
}
private predicate implicitFieldSelection(SelectorExpr e, int i, Field implicitField) {
private predicate implicitFieldSelection(PromotedFieldSelector e, int i, Field implicitField) {
exists(StructType baseType, PromotedField child |
baseType = e.getBase().getType().getBaseType*().getUnderlyingType() and
baseType = getSelectedStructType(e) and
(
e.refersTo(child)
or
@@ -65,6 +65,14 @@ private predicate implicitFieldSelection(SelectorExpr e, int i, Field implicitFi
)
}
private class PromotedFieldSelector extends SelectorExpr {
PromotedFieldSelector() { this.refersTo(any(PromotedField f)) }
}
private class PromotedField extends Field {
PromotedField() { this = any(StructType t).getFieldOfEmbedded(_, _, _, _) }
}
/**
* A node in the intra-procedural control-flow graph of a Go function or file.
*