File tree Expand file tree Collapse file tree 3 files changed +29
-24
lines changed
csharp/ql/lib/semmle/code/csharp Expand file tree Collapse file tree 3 files changed +29
-24
lines changed Original file line number Diff line number Diff line change @@ -132,27 +132,3 @@ private module FrameworkDataFlowAdaptor {
132132 override predicate required ( SummaryComponent c ) { c = head }
133133 }
134134}
135-
136- /** Data flow for `System.Text.StringBuilder`. */
137- class SystemTextStringBuilderFlow extends LibraryTypeDataFlow , SystemTextStringBuilderClass {
138- override predicate clearsContent (
139- CallableFlowSource source , Content content , SourceDeclarationCallable callable
140- ) {
141- source = TCallableFlowSourceQualifier ( ) and
142- callable = this .getAMethod ( "Clear" ) and
143- content instanceof ElementContent
144- }
145- }
146-
147- /** Data flow for `System.Collections.IEnumerable` (and sub types). */
148- class IEnumerableFlow extends LibraryTypeDataFlow , RefType {
149- IEnumerableFlow ( ) { this .getABaseType * ( ) instanceof SystemCollectionsIEnumerableInterface }
150-
151- override predicate clearsContent (
152- CallableFlowSource source , Content content , SourceDeclarationCallable callable
153- ) {
154- source = TCallableFlowSourceQualifier ( ) and
155- callable = this .getAMethod ( "Clear" ) and
156- content instanceof ElementContent
157- }
158- }
Original file line number Diff line number Diff line change 33import csharp
44private import semmle.code.csharp.frameworks.System
55private import semmle.code.csharp.dataflow.ExternalFlow
6+ private import semmle.code.csharp.dataflow.FlowSummary
67
78/** The `System.Collections` namespace. */
89class SystemCollectionsNamespace extends Namespace {
@@ -45,6 +46,20 @@ private class SystemCollectionIEnumerableFlowModelCsv extends SummaryModelCsv {
4546 }
4647}
4748
49+ /** Clear content for Clear methods in all subtypes of `System.Collections.IEnumerable`. */
50+ private class SystemCollectionsIEnumerableClearFlow extends SummarizedCallable {
51+ SystemCollectionsIEnumerableClearFlow ( ) {
52+ this .getDeclaringType ( ) .( RefType ) .getABaseType * ( ) instanceof
53+ SystemCollectionsIEnumerableInterface and
54+ this .hasName ( "Clear" )
55+ }
56+
57+ override predicate clearsContent ( ParameterPosition pos , DataFlow:: Content content ) {
58+ pos .getPosition ( ) = - 1 and
59+ content instanceof DataFlow:: ElementContent
60+ }
61+ }
62+
4863/** The `System.Collections.IEnumerator` interface. */
4964class SystemCollectionsIEnumeratorInterface extends SystemCollectionsInterface {
5065 SystemCollectionsIEnumeratorInterface ( ) { this .hasName ( "IEnumerator" ) }
Original file line number Diff line number Diff line change 33import csharp
44private import semmle.code.csharp.frameworks.System
55private import semmle.code.csharp.dataflow.ExternalFlow
6+ private import semmle.code.csharp.dataflow.FlowSummary
67
78/** The `System.Text` namespace. */
89class SystemTextNamespace extends Namespace {
@@ -25,6 +26,19 @@ class SystemTextStringBuilderClass extends SystemTextClass {
2526 Method getAppendFormatMethod ( ) { result = this .getAMethod ( "AppendFormat" ) }
2627}
2728
29+ /** Clear content for `System.Text.StringBuilder.Clear`. */
30+ private class SystemTextStringBuilderClearFlow extends SummarizedCallable {
31+ SystemTextStringBuilderClearFlow ( ) {
32+ this .getDeclaringType ( ) instanceof SystemTextStringBuilderClass and
33+ this .hasName ( "Clear" )
34+ }
35+
36+ override predicate clearsContent ( ParameterPosition pos , DataFlow:: Content content ) {
37+ pos .getPosition ( ) = - 1 and
38+ content instanceof DataFlow:: ElementContent
39+ }
40+ }
41+
2842/** Data flow for `System.Text.StringBuilder`. */
2943private class SystemTextStringBuilderFlowModelCsv extends SummaryModelCsv {
3044 override predicate row ( string row ) {
You can’t perform that action at this time.
0 commit comments