Skip to content

Commit fd317c2

Browse files
committed
C#: Move RecordConstructorFlow.
1 parent fb95084 commit fd317c2

File tree

2 files changed

+37
-37
lines changed

2 files changed

+37
-37
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/FlowSummary.qll

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,29 @@ module SummaryComponentStack {
111111

112112
class SummarizedCallable = Impl::Public::SummarizedCallable;
113113

114+
private predicate recordConstructorFlow(Constructor c, int i, Property p) {
115+
c = any(Record r).getAMember() and
116+
exists(string name |
117+
c.getParameter(i).getName() = name and
118+
c.getDeclaringType().getAMember(name) = p
119+
)
120+
}
121+
122+
private class RecordConstructorFlow extends SummarizedCallable {
123+
RecordConstructorFlow() { recordConstructorFlow(this, _, _) }
124+
125+
override predicate propagatesFlow(
126+
SummaryComponentStack input, SummaryComponentStack output, boolean preservesValue
127+
) {
128+
exists(int i, Property p |
129+
recordConstructorFlow(this, i, p) and
130+
input = SummaryComponentStack::argument(i) and
131+
output = SummaryComponentStack::propertyOf(p, SummaryComponentStack::return()) and
132+
preservesValue = true
133+
)
134+
}
135+
}
136+
114137
private class SummarizedCallableDefaultClearsContent extends Impl::Public::SummarizedCallable {
115138
SummarizedCallableDefaultClearsContent() {
116139
this instanceof Impl::Public::SummarizedCallable or none()
@@ -129,3 +152,17 @@ private class SummarizedCallableDefaultClearsContent extends Impl::Public::Summa
129152
}
130153

131154
class RequiredSummaryComponentStack = Impl::Public::RequiredSummaryComponentStack;
155+
156+
private class RecordConstructorFlowRequiredSummaryComponentStack extends RequiredSummaryComponentStack {
157+
private SummaryComponent head;
158+
159+
RecordConstructorFlowRequiredSummaryComponentStack() {
160+
exists(Property p |
161+
recordConstructorFlow(_, _, p) and
162+
head = SummaryComponent::property(p) and
163+
this = SummaryComponentStack::singleton(SummaryComponent::return())
164+
)
165+
}
166+
167+
override predicate required(SummaryComponent c) { c = head }
168+
}

csharp/ql/lib/semmle/code/csharp/dataflow/LibraryTypeDataFlow.qll

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -156,40 +156,3 @@ class IEnumerableFlow extends LibraryTypeDataFlow, RefType {
156156
content instanceof ElementContent
157157
}
158158
}
159-
160-
private predicate recordConstructorFlow(Constructor c, int i, Property p) {
161-
c = any(Record r).getAMember() and
162-
exists(string name |
163-
c.getParameter(i).getName() = name and
164-
c.getDeclaringType().getAMember(name) = p
165-
)
166-
}
167-
168-
private class RecordConstructorFlowRequiredSummaryComponentStack extends RequiredSummaryComponentStack {
169-
private SummaryComponent head;
170-
171-
RecordConstructorFlowRequiredSummaryComponentStack() {
172-
exists(Property p |
173-
recordConstructorFlow(_, _, p) and
174-
head = SummaryComponent::property(p) and
175-
this = SummaryComponentStack::singleton(SummaryComponent::return())
176-
)
177-
}
178-
179-
override predicate required(SummaryComponent c) { c = head }
180-
}
181-
182-
private class RecordConstructorFlow extends SummarizedCallable {
183-
RecordConstructorFlow() { recordConstructorFlow(this, _, _) }
184-
185-
override predicate propagatesFlow(
186-
SummaryComponentStack input, SummaryComponentStack output, boolean preservesValue
187-
) {
188-
exists(int i, Property p |
189-
recordConstructorFlow(this, i, p) and
190-
input = SummaryComponentStack::argument(i) and
191-
output = SummaryComponentStack::propertyOf(p, SummaryComponentStack::return()) and
192-
preservesValue = true
193-
)
194-
}
195-
}

0 commit comments

Comments
 (0)