mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
C#: Introduce type for Synthetic fields.
This commit is contained in:
@@ -759,7 +759,8 @@ private module Cached {
|
||||
newtype TContent =
|
||||
TFieldContent(Field f) { f.isUnboundDeclaration() } or
|
||||
TPropertyContent(Property p) { p.isUnboundDeclaration() } or
|
||||
TElementContent()
|
||||
TElementContent() or
|
||||
TSyntheticFieldContent(SyntheticField f)
|
||||
|
||||
pragma[nomagic]
|
||||
private predicate commonSubTypeGeneral(DataFlowTypeOrUnifiable t1, RelevantDataFlowType t2) {
|
||||
@@ -2038,3 +2039,10 @@ predicate additionalLambdaFlowStep(Node nodeFrom, Node nodeTo, boolean preserves
|
||||
predicate allowParameterReturnInSelf(ParameterNode p) {
|
||||
FlowSummaryImpl::Private::summaryAllowParameterReturnInSelf(p)
|
||||
}
|
||||
|
||||
abstract class SyntheticField extends string {
|
||||
bindingset[this]
|
||||
SyntheticField() { any() }
|
||||
|
||||
Type getType() { result instanceof ObjectType }
|
||||
}
|
||||
|
||||
@@ -224,6 +224,16 @@ class FieldContent extends Content, TFieldContent {
|
||||
deprecated override Gvn::GvnType getType() { result = Gvn::getGlobalValueNumber(f.getType()) }
|
||||
}
|
||||
|
||||
class SyntheticFieldContent extends Content, TSyntheticFieldContent {
|
||||
private SyntheticField f;
|
||||
|
||||
SyntheticFieldContent() { this = TSyntheticFieldContent(f) }
|
||||
|
||||
SyntheticField getField() { result = f }
|
||||
|
||||
override string toString() { result = "synthetic " + f.toString() }
|
||||
}
|
||||
|
||||
/** A reference to a property. */
|
||||
class PropertyContent extends Content, TPropertyContent {
|
||||
private Property p;
|
||||
|
||||
@@ -29,6 +29,8 @@ DataFlowType getContentType(Content c) {
|
||||
or
|
||||
t = c.(PropertyContent).getProperty().getType()
|
||||
or
|
||||
t = c.(SyntheticFieldContent).getField().getType()
|
||||
or
|
||||
c instanceof ElementContent and
|
||||
t instanceof ObjectType // we don't know what the actual element type is
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user