Skip to content

Commit

Permalink
Merge pull request #84 from AjayBrahmakshatriya/master
Browse files Browse the repository at this point in the history
Fixed sample58, removed the test case that's dependent of RVO
  • Loading branch information
AjayBrahmakshatriya authored Oct 29, 2024
2 parents 8c8aba8 + 8e156a2 commit 2b8eed0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 129 deletions.
56 changes: 0 additions & 56 deletions samples/outputs.var_names/sample58
Original file line number Diff line number Diff line change
Expand Up @@ -11,64 +11,8 @@ FUNC_DECL
SCALAR_TYPE (INT)
VAR (y_1)
NO_INITIALIZATION
DECL_STMT
SCALAR_TYPE (INT)
VAR (c_2)
VAR_EXPR
VAR (var0)
IF_STMT
EQUALS_EXPR
INT_CONST (0)
VAR_EXPR
VAR (c_2)
STMT_BLOCK
DECL_STMT
SCALAR_TYPE (FLOAT)
VAR (c_3)
FLOAT_CONST (2)
STMT_BLOCK
IF_STMT
EQUALS_EXPR
INT_CONST (1)
VAR_EXPR
VAR (c_2)
STMT_BLOCK
DECL_STMT
SCALAR_TYPE (FLOAT)
VAR (c_4)
FLOAT_CONST (3)
STMT_BLOCK
IF_STMT
EQUALS_EXPR
INT_CONST (2)
VAR_EXPR
VAR (c_2)
STMT_BLOCK
DECL_STMT
SCALAR_TYPE (FLOAT)
VAR (c_5)
FLOAT_CONST (5)
STMT_BLOCK
DECL_STMT
SCALAR_TYPE (FLOAT)
VAR (c_6)
FLOAT_CONST (2)
void bar (int arg0) {
int var0 = arg0;
int y_1;
int c_2 = var0;
if (0 == c_2) {
float c_3 = 2.0f;
} else {
if (1 == c_2) {
float c_4 = 3.0f;
} else {
if (2 == c_2) {
float c_5 = 5.0f;
} else {
float c_6 = 2.0f;
}
}
}
}

56 changes: 0 additions & 56 deletions samples/outputs/sample58
Original file line number Diff line number Diff line change
Expand Up @@ -11,64 +11,8 @@ FUNC_DECL
SCALAR_TYPE (INT)
VAR (var1)
NO_INITIALIZATION
DECL_STMT
SCALAR_TYPE (INT)
VAR (var2)
VAR_EXPR
VAR (var0)
IF_STMT
EQUALS_EXPR
INT_CONST (0)
VAR_EXPR
VAR (var2)
STMT_BLOCK
DECL_STMT
SCALAR_TYPE (FLOAT)
VAR (var3)
FLOAT_CONST (2)
STMT_BLOCK
IF_STMT
EQUALS_EXPR
INT_CONST (1)
VAR_EXPR
VAR (var2)
STMT_BLOCK
DECL_STMT
SCALAR_TYPE (FLOAT)
VAR (var4)
FLOAT_CONST (3)
STMT_BLOCK
IF_STMT
EQUALS_EXPR
INT_CONST (2)
VAR_EXPR
VAR (var2)
STMT_BLOCK
DECL_STMT
SCALAR_TYPE (FLOAT)
VAR (var5)
FLOAT_CONST (5)
STMT_BLOCK
DECL_STMT
SCALAR_TYPE (FLOAT)
VAR (var6)
FLOAT_CONST (2)
void bar (int arg0) {
int var0 = arg0;
int var1;
int var2 = var0;
if (0 == var2) {
float var3 = 2.0f;
} else {
if (1 == var2) {
float var4 = 3.0f;
} else {
if (2 == var2) {
float var5 = 5.0f;
} else {
float var6 = 2.0f;
}
}
}
}

20 changes: 3 additions & 17 deletions samples/sample58.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@
using builder::dyn_var;
using builder::static_var;

static static_var<int> magic(dyn_var<int> x, int range) {
for (static_var<int> y = 0; y < range; y++) {
if (y == x) return y;
}
return 0;
}


float arr[] = {2.0, 3.0, 5.0};


static void bar(dyn_var<int> x) {
/* Test out of order deinitialization of static variables and arrays */
Expand All @@ -37,13 +27,9 @@ static void bar(dyn_var<int> x) {
delete sv2;
delete sva1;
delete sva2;


// Test case that breaks without out of order deinitialization
static_var<int> z = magic(x, 3);
dyn_var<float> c = arr[z];



// A realistic test is hard to get right (depends on rv-optimizations)
// so we will just stick with this simple one above

}

Expand Down

0 comments on commit 2b8eed0

Please sign in to comment.