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 @@ -1089,11 +1089,13 @@ stmts.cs:
10891089
10901090# 76| Block 4
10911091# 76| r4_0(glval<Int32>) = VariableAddress[a] :
1092- # 76| r4_1(Int32) = Constant[0] :
1093- # 76| mu4_2(Int32) = Store : &:r4_0, r4_1
1094- # 76| r4_3(glval<Int32>) = VariableAddress[b] :
1095- # 76| r4_4(Int32) = Constant[10] :
1096- # 76| mu4_5(Int32) = Store : &:r4_3, r4_4
1092+ # 76| mu4_1(Int32) = Uninitialized[a] : &:r4_0
1093+ # 76| r4_2(glval<Int32>) = VariableAddress[b] :
1094+ # 76| r4_3(Int32) = Constant[10] :
1095+ # 76| mu4_4(Int32) = Store : &:r4_2, r4_3
1096+ # 77| r4_5(Int32) = Constant[0] :
1097+ # 77| r4_6(glval<Int32>) = VariableAddress[a] :
1098+ # 77| mu4_7(Int32) = Store : &:r4_6, r4_5
10971099#-----| Goto -> Block 5
10981100
10991101# 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