[LLVMbugs] [Bug 124] [llvmg++] ?: expressions do not run correct number of destructors!
bugzilla-daemon at zion.cs.uiuc.edu
bugzilla-daemon at zion.cs.uiuc.edu
Tue Nov 25 18:46:02 PST 2003
http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=124
sabre at nondot.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
------- Additional Comments From sabre at nondot.org 2003-11-25 20:46 -------
Fixed. Testcase: test/Programs/SingleSource/Regression/C++/EH/ConditionalExpr.cpp
The patch:
$ diff -u llvm-expand.c~ llvm-expand.c
--- llvm-expand.c~ 2003-11-25 19:13:56.000000000 -0600
+++ llvm-expand.c 2003-11-25 20:43:57.000000000 -0600
@@ -4847,9 +4847,6 @@
break;
case COND_EXPR: { /* ?: expression */
- /* FIXME: This does not correctly conditionalize CLEANUP expressions because
- no scopes are created!!! */
-
/* Allocate a new temporary to hold the result of the expression */
llvm_basicblock *TrueBlock = llvm_basicblock_new("cond_true");
llvm_basicblock *FalseBlock = llvm_basicblock_new("cond_false");
@@ -4866,6 +4863,9 @@
/* Add the true block as the fall through */
llvm_ilist_push_back(llvm_basicblock, Fn->BasicBlocks, TrueBlock);
+ /* Start a region for the conditional expression destructors */
+ llvm_expand_start_bindings(Fn);
+
/* One branch of the cond can be void, if it never returns. For
example A ? throw : E */
if (TREE_TYPE(TREE_OPERAND(exp, 1)) != void_type_node) {
@@ -4879,12 +4879,18 @@
llvm_expand_expr(Fn, TREE_OPERAND (exp, 1), 0);
}
+ /* Stop the scope */
+ llvm_expand_end_bindings(Fn, NULL_TREE);
+
/* Branch to the mainline computation */
append_inst(Fn, create_uncond_branch(ContinueBlock));
/* Add the false block next */
llvm_ilist_push_back(llvm_basicblock, Fn->BasicBlocks, FalseBlock);
+ /* Start a region for the conditional expression destructors */
+ llvm_expand_start_bindings(Fn);
+
/* One branch of the cond can be void, if it never returns. For
example A ? throw : E */
if (TREE_TYPE(TREE_OPERAND(exp, 2)) != void_type_node) {
@@ -4898,6 +4904,9 @@
llvm_expand_expr(Fn, TREE_OPERAND (exp, 2), 0);
}
+ /* Stop the scope */
+ llvm_expand_end_bindings(Fn, NULL_TREE);
+
/* Add the branch and continue block */
llvm_emit_label(Fn, ContinueBlock);
@@ -5508,9 +5517,6 @@
break;
}
case COND_EXPR: { /* ?: expression */
- /* FIXME: This does not correctly conditionalize CLEANUP expressions because
- no scopes are created!!! */
-
/* Allocate a new temporary to hold the result of the expression */
llvm_basicblock *TrueBlock = llvm_basicblock_new("cond_true");
llvm_basicblock *FalseBlock = llvm_basicblock_new("cond_false");
@@ -5529,6 +5535,9 @@
/* Add the true block as the fall through */
llvm_ilist_push_back(llvm_basicblock, Fn->BasicBlocks, TrueBlock);
+ /* Start a region for the conditional expression destructors */
+ llvm_expand_start_bindings(Fn);
+
/* One branch of the cond can be void, if it never returns. For
example A ? throw : E */
if (Result && TREE_TYPE(TREE_OPERAND(exp, 1)) != void_type_node)
@@ -5536,17 +5545,26 @@
else
llvm_expand_expr(Fn, TREE_OPERAND (exp, 1), 0);
+ /* Stop the scope */
+ llvm_expand_end_bindings(Fn, NULL_TREE);
+
/* Branch to the mainline computation */
append_inst(Fn, create_uncond_branch(ContinueBlock));
/* Add the false block next */
llvm_ilist_push_back(llvm_basicblock, Fn->BasicBlocks, FalseBlock);
+ /* Start a region for the conditional expression destructors */
+ llvm_expand_start_bindings(Fn);
+
if (Result && TREE_TYPE(TREE_OPERAND(exp, 2)) != void_type_node)
llvm_store_expr(Fn, TREE_OPERAND(exp, 2), Result, 0, 0, 0, 0);
else
llvm_expand_expr(Fn, TREE_OPERAND (exp, 2), 0);
+ /* Stop the scope */
+ llvm_expand_end_bindings(Fn, NULL_TREE);
+
/* Add the branch and continue block */
llvm_emit_label(Fn, ContinueBlock);
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
More information about the llvm-bugs
mailing list