| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,7 +26,11 @@ private module FlowTestImpl implements InputSig<CsharpDataFlow> { | |||
| 26 | 26 | } | |
| 27 | 27 | ||
| 28 | 28 | string getArgString(DataFlow::Node src, DataFlow::Node sink) { | |
| 29 | - (if exists(getSourceArgString(src)) then result = getSourceArgString(src) else result = "") and | ||
| 29 | + ( | ||
| 30 | + result = getSourceArgString(src) | ||
| 31 | + or | ||
| 32 | + not exists(getSourceArgString(src)) and result = "line:" + src.getLocation().getStartLine() | ||
| 33 | + ) and | ||
| 30 | 34 | exists(sink) | |
| 31 | 35 | } | |
| 32 | 36 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,7 +13,7 @@ class C : B<int> { } | |||
| 13 | 13 | ||
| 14 | 14 | class D : B<string> | |
| 15 | 15 | { | |
| 16 | - public override void M() => Sink(this); | ||
| 16 | + public override void M() => Sink(this); // $ hasValueFlow=line:32 $ hasValueFlow=line:33 $ hasValueFlow=line:40 | ||
| 17 | 17 | } | |
| 18 | 18 | ||
| 19 | 19 | static void M1() | |
@@ -41,32 +41,32 @@ static void M1() | |||
| 41 | 41 | M9(new D()); // no flow | |
| 42 | 42 | ||
| 43 | 43 | object o = null; // flow | |
| 44 | - Sink(o); | ||
| 44 | + Sink(o); // $ hasValueFlow=line:43 | ||
| 45 | 45 | } | |
| 46 | 46 | ||
| 47 | 47 | static void M2(A a) | |
| 48 | 48 | { | |
| 49 | 49 | if (a is C c) | |
| 50 | - Sink(c); | ||
| 50 | + Sink(c); // $ hasValueFlow=line:23 | ||
| 51 | 51 | } | |
| 52 | 52 | ||
| 53 | 53 | static void M3(A a) | |
| 54 | 54 | { | |
| 55 | 55 | switch (a) | |
| 56 | 56 | { | |
| 57 | 57 | case D d: | |
| 58 | - Sink(d); | ||
| 58 | + Sink(d); // $ hasValueFlow=line:35 | ||
| 59 | 59 | break; | |
| 60 | 60 | } | |
| 61 | 61 | } | |
| 62 | 62 | ||
| 63 | - static void M4(A a) => Sink((C)a); | ||
| 63 | + static void M4(A a) => Sink((C)a); // $ hasValueFlow=line:25 | ||
| 64 | 64 | ||
| 65 | - static void M5<T>(T x) => Sink(x); | ||
| 65 | + static void M5<T>(T x) => Sink(x); // $ hasValueFlow=line:26 $ hasValueFlow=line:37 | ||
| 66 | 66 | ||
| 67 | - static void M6<T>(T x) where T : A => Sink(x); | ||
| 67 | + static void M6<T>(T x) where T : A => Sink(x); // $ hasValueFlow=line:27 $ hasValueFlow=line:38 | ||
| 68 | 68 | ||
| 69 | - static void M7<T>(T x) where T : class => Sink(x); | ||
| 69 | + static void M7<T>(T x) where T : class => Sink(x); // $ hasValueFlow=line:28 $ hasValueFlow=line:39 | ||
| 70 | 70 | ||
| 71 | 71 | static void M8<T>(T x) | |
| 72 | 72 | { | |
@@ -77,7 +77,7 @@ static void M8<T>(T x) | |||
| 77 | 77 | static void M9(A a) | |
| 78 | 78 | { | |
| 79 | 79 | if (a is B<int> b) | |
| 80 | - Sink(b); | ||
| 80 | + Sink(b); // $ hasValueFlow=line:30 | ||
| 81 | 81 | } | |
| 82 | 82 | ||
| 83 | 83 | static void Sink<T>(T x) { } | |
@@ -112,15 +112,15 @@ void M3() | |||
| 112 | 112 | ||
| 113 | 113 | public override void M() | |
| 114 | 114 | { | |
| 115 | - Sink(this.Field); | ||
| 115 | + Sink(this.Field); // $ hasValueFlow=line:110 | ||
| 116 | 116 | } | |
| 117 | 117 | ||
| 118 | 118 | void M10() | |
| 119 | 119 | { | |
| 120 | 120 | var a = new A(); | |
| 121 | 121 | var e2 = new E2(); | |
| 122 | - Sink(Through(a)); // flow | ||
| 123 | - Sink(Through(e2)); // flow | ||
| 122 | + Sink(Through(a)); // $ hasValueFlow=line:120 | ||
| 123 | + Sink(Through(e2)); // $ hasValueFlow=line:121 | ||
| 124 | 124 | Sink((E2)Through(a)); // no flow | |
| 125 | 125 | Sink((A)Through(e2)); // no flow | |
| 126 | 126 | } | |
@@ -150,6 +150,6 @@ class FieldB : FieldA { } | |||
| 150 | 150 | ||
| 151 | 151 | class FieldC : FieldA | |
| 152 | 152 | { | |
| 153 | - public override void M() => Sink(this.Field); | ||
| 153 | + public override void M() => Sink(this.Field); // $ hasValueFlow=line:144 | ||
| 154 | 154 | } | |
| 155 | 155 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,4 @@ | |||
| 1 | + testFailures | ||
| 1 | 2 | edges | |
| 2 | 3 | | Types.cs:7:21:7:25 | this : D | Types.cs:7:32:7:35 | this access : D | | |
| 3 | 4 | | Types.cs:7:32:7:35 | this access : D | Types.cs:16:30:16:30 | this : D | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,8 @@ | |||
| 3 | 3 | */ | |
| 4 | 4 | ||
| 5 | 5 | import csharp | |
| 6 | - import Types::PathGraph | ||
| 6 | + import TestUtilities.InlineFlowTest | ||
| 7 | + import PathGraph | ||
| 7 | 8 | ||
| 8 | 9 | module TypesConfig implements DataFlow::ConfigSig { | |
| 9 | 10 | predicate isSource(DataFlow::Node src) { | |
@@ -17,10 +18,12 @@ module TypesConfig implements DataFlow::ConfigSig { | |||
| 17 | 18 | mc.getAnArgument() = sink.asExpr() | |
| 18 | 19 | ) | |
| 19 | 20 | } | |
| 21 | + | ||
| 22 | + int fieldFlowBranchLimit() { result = 1000 } | ||
| 20 | 23 | } | |
| 21 | 24 | ||
| 22 | - module Types = DataFlow::Global<TypesConfig>; | ||
| 25 | + import ValueFlowTest<TypesConfig> | ||
| 23 | 26 | ||
| 24 | - from Types::PathNode source, Types::PathNode sink | ||
| 25 | - where Types::flowPath(source, sink) | ||
| 27 | + from PathNode source, PathNode sink | ||
| 28 | + where flowPath(source, sink) | ||
| 26 | 29 | select source, source, sink, "$@", sink, sink.toString() | |
| Back | FazBrowse Home | New Git URL |
0 commit comments