C# IR: Fix for init

This commit is contained in:
AndreiDiaconu1
2019-09-16 11:57:15 +01:00
parent e330d5a6c6
commit fcb3d99351
3 changed files with 13 additions and 9 deletions

View File

@@ -660,8 +660,10 @@ class TranslatedForStmt extends TranslatedLoop {
id = initializersNo() + updatesNo() + 1 and result = this.getBody()
}
private TranslatedLocalDeclaration getDeclAndInit(int index) {
result = getTranslatedLocalDeclaration(stmt.getInitializer(index))
private TranslatedElement getDeclAndInit(int index) {
if stmt.getInitializer(index) instanceof LocalVariableDeclExpr
then result = getTranslatedLocalDeclaration(stmt.getInitializer(index))
else result = getTranslatedExpr(stmt.getInitializer(index))
}
private predicate hasInitialization() { exists(stmt.getAnInitializer()) }

View File

@@ -1089,11 +1089,13 @@ stmts.cs:
# 76| Block 4
# 76| r4_0(glval<Int32>) = VariableAddress[a] :
# 76| r4_1(Int32) = Constant[0] :
# 76| mu4_2(Int32) = Store : &:r4_0, r4_1
# 76| r4_3(glval<Int32>) = VariableAddress[b] :
# 76| r4_4(Int32) = Constant[10] :
# 76| mu4_5(Int32) = Store : &:r4_3, r4_4
# 76| mu4_1(Int32) = Uninitialized[a] : &:r4_0
# 76| r4_2(glval<Int32>) = VariableAddress[b] :
# 76| r4_3(Int32) = Constant[10] :
# 76| mu4_4(Int32) = Store : &:r4_2, r4_3
# 77| r4_5(Int32) = Constant[0] :
# 77| r4_6(glval<Int32>) = VariableAddress[a] :
# 77| mu4_7(Int32) = Store : &:r4_6, r4_5
#-----| Goto -> Block 5
# 77| Block 5

View File

@@ -73,8 +73,8 @@ public class test_stmts
x = x - 1;
}
int a = 0, b = 10;
for (; a < b; )
int a, b = 10;
for (a = 0; a < b; )
{
a++;
}