File tree Expand file tree Collapse file tree 3 files changed +13
-9
lines changed
src/semmle/code/csharp/ir/implementation/raw/internal Expand file tree Collapse file tree 3 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -660,8 +660,10 @@ class TranslatedForStmt extends TranslatedLoop {
660660 id = initializersNo ( ) + updatesNo ( ) + 1 and result = this .getBody ( )
661661 }
662662
663- private TranslatedLocalDeclaration getDeclAndInit ( int index ) {
664- result = getTranslatedLocalDeclaration ( stmt .getInitializer ( index ) )
663+ private TranslatedElement getDeclAndInit ( int index ) {
664+ if stmt .getInitializer ( index ) instanceof LocalVariableDeclExpr
665+ then result = getTranslatedLocalDeclaration ( stmt .getInitializer ( index ) )
666+ else result = getTranslatedExpr ( stmt .getInitializer ( index ) )
665667 }
666668
667669 private predicate hasInitialization ( ) { exists ( stmt .getAnInitializer ( ) ) }
Original file line number Diff line number Diff line change @@ -1263,11 +1263,13 @@ stmts.cs:
12631263
12641264# 76| Block 4
12651265# 76| r4_0(glval<Int32>) = VariableAddress[a] :
1266- # 76| r4_1(Int32) = Constant[0] :
1267- # 76| mu4_2(Int32) = Store : &:r4_0, r4_1
1268- # 76| r4_3(glval<Int32>) = VariableAddress[b] :
1269- # 76| r4_4(Int32) = Constant[10] :
1270- # 76| mu4_5(Int32) = Store : &:r4_3, r4_4
1266+ # 76| mu4_1(Int32) = Uninitialized[a] : &:r4_0
1267+ # 76| r4_2(glval<Int32>) = VariableAddress[b] :
1268+ # 76| r4_3(Int32) = Constant[10] :
1269+ # 76| mu4_4(Int32) = Store : &:r4_2, r4_3
1270+ # 77| r4_5(Int32) = Constant[0] :
1271+ # 77| r4_6(glval<Int32>) = VariableAddress[a] :
1272+ # 77| mu4_7(Int32) = Store : &:r4_6, r4_5
12711273#-----| Goto -> Block 5
12721274
12731275# 77| Block 5
Original file line number Diff line number Diff line change @@ -73,8 +73,8 @@ public static void forStmt()
7373 x = x - 1 ;
7474 }
7575
76- int a = 0 , b = 10 ;
77- for ( ; a < b ; )
76+ int a , b = 10 ;
77+ for ( a = 0 ; a < b ; )
7878 {
7979 a ++ ;
8080 }
You can’t perform that action at this time.
0 commit comments