mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
C# IR: Fix for init
This commit is contained in:
@@ -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()) }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user