@@ -10,42 +10,15 @@ private import semmle.code.csharp.ExprOrStmtParent
1010private import semmle.code.csharp.commons.Compilation
1111
1212private module Initializers {
13- /**
14- * A non-static member with an initializer, for example a field `int Field = 0`.
15- */
16- class InitializedInstanceMember extends Member {
17- private AssignExpr ae ;
18-
19- InitializedInstanceMember ( ) {
20- not this .isStatic ( ) and
21- expr_parent_top_level ( ae , _, this ) and
22- not ae = any ( Callable c ) .getExpressionBody ( )
23- }
24-
25- /** Gets the initializer expression. */
26- AssignExpr getInitializer ( ) { result = ae }
27- }
28-
29- /**
30- * Holds if `obinit` is an object initializer method that performs the initialization
31- * of a member via assignment `init`.
32- */
33- predicate obinitInitializes ( ObjectInitMethod obinit , AssignExpr init ) {
34- exists ( InitializedInstanceMember m |
35- obinit .getDeclaringType ( ) .getAMember ( ) = m and
36- init = m .getInitializer ( )
37- )
38- }
39-
4013 /**
4114 * Gets the `i`th member initializer expression for object initializer method `obinit`
4215 * in compilation `comp`.
4316 */
4417 AssignExpr initializedInstanceMemberOrder ( ObjectInitMethod obinit , CompilationExt comp , int i ) {
45- obinitInitializes ( obinit , result ) and
18+ obinit . initializes ( result ) and
4619 result =
4720 rank [ i + 1 ] ( AssignExpr ae0 , Location l |
48- obinitInitializes ( obinit , ae0 ) and
21+ obinit . initializes ( ae0 ) and
4922 l = ae0 .getLocation ( ) and
5023 getCompilation ( l .getFile ( ) ) = comp
5124 |
@@ -74,7 +47,7 @@ class CfgScope extends Element, @top_level_exprorstmt_parent {
7447 any ( Callable c |
7548 c .( Constructor ) .hasInitializer ( )
7649 or
77- Initializers :: obinitInitializes ( c , _)
50+ c . ( ObjectInitMethod ) . initializes ( _)
7851 or
7952 c .hasBody ( )
8053 )
0 commit comments