Commit 5d14093
committed
C#: Add field initializers to CFG for constructors
This commit adds field initializers to the CFG for non-static constructors. For
example, in
```
class C
{
int Field1 = 0;
int Field2 = Field1 + 1;
int Field3;
public C()
{
Field3 = 2;
}
public C(int i)
{
Field3 = 3;
}
}
```
the initializer expressions `Field1 = 0` and `Field2 = Field1 + 1` are added
to the two constructors, mimicking
```
public C()
{
Field1 = 0;
Field2 = Field1 + 1;
Field3 = 2;
}
```
and
```
public C()
{
Field1 = 0;
Field2 = Field1 + 1;
Field3 = 3;
}
```
respectively. This means that we no longer have to synthesize calls, callables,
parameters, and arguments in the data flow library, so much of the work from
d175550 can be simplified.1 parent eb97d7b commit 5d14093
File tree
21 files changed
+4061
-466
lines changed- csharp/ql
- src/semmle/code/csharp
- controlflow
- internal
- dataflow/internal
- test/library-tests
- controlflow/graph
- csharp7
- csharp8
- dataflow/fields
21 files changed
+4061
-466
lines changedLines changed: 1 addition & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
349 | | - | |
350 | | - | |
351 | 349 | | |
352 | 350 | | |
353 | 351 | | |
| |||
Lines changed: 36 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
291 | 295 | | |
292 | 296 | | |
293 | 297 | | |
| |||
1756 | 1760 | | |
1757 | 1761 | | |
1758 | 1762 | | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
1759 | 1779 | | |
1760 | 1780 | | |
1761 | 1781 | | |
| |||
1831 | 1851 | | |
1832 | 1852 | | |
1833 | 1853 | | |
1834 | | - | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
1835 | 1861 | | |
1836 | 1862 | | |
1837 | 1863 | | |
1838 | | - | |
| 1864 | + | |
| 1865 | + | |
1839 | 1866 | | |
1840 | 1867 | | |
1841 | 1868 | | |
| |||
1845 | 1872 | | |
1846 | 1873 | | |
1847 | 1874 | | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
1848 | 1881 | | |
1849 | 1882 | | |
1850 | 1883 | | |
| |||
0 commit comments