Skip to content

Commit 7a11b9a

Browse files
debuginfo: Fix an ICE related to local variables in unreachable code.
1 parent c594959 commit 7a11b9a

File tree

2 files changed

+91
-5
lines changed

2 files changed

+91
-5
lines changed

src/librustc_trans/trans/debuginfo.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ pub fn create_global_var_metadata(cx: &CrateContext,
853853
/// local in `bcx.fcx.lllocals`.
854854
/// Adds the created metadata nodes directly to the crate's IR.
855855
pub fn create_local_var_metadata(bcx: Block, local: &ast::Local) {
856-
if fn_should_be_ignored(bcx.fcx) {
856+
if bcx.unreachable.get() || fn_should_be_ignored(bcx.fcx) {
857857
return;
858858
}
859859

@@ -897,7 +897,7 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
897897
env_index: uint,
898898
captured_by_ref: bool,
899899
span: Span) {
900-
if fn_should_be_ignored(bcx.fcx) {
900+
if bcx.unreachable.get() || fn_should_be_ignored(bcx.fcx) {
901901
return;
902902
}
903903

@@ -980,7 +980,7 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
980980
pub fn create_match_binding_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
981981
variable_ident: ast::Ident,
982982
binding: BindingInfo<'tcx>) {
983-
if fn_should_be_ignored(bcx.fcx) {
983+
if bcx.unreachable.get() || fn_should_be_ignored(bcx.fcx) {
984984
return;
985985
}
986986

@@ -1020,7 +1020,7 @@ pub fn create_match_binding_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
10201020
/// argument in `bcx.fcx.lllocals`.
10211021
/// Adds the created metadata nodes directly to the crate's IR.
10221022
pub fn create_argument_metadata(bcx: Block, arg: &ast::Arg) {
1023-
if fn_should_be_ignored(bcx.fcx) {
1023+
if bcx.unreachable.get() || fn_should_be_ignored(bcx.fcx) {
10241024
return;
10251025
}
10261026

@@ -1074,7 +1074,7 @@ pub fn create_argument_metadata(bcx: Block, arg: &ast::Arg) {
10741074
/// loop variable in `bcx.fcx.lllocals`.
10751075
/// Adds the created metadata nodes directly to the crate's IR.
10761076
pub fn create_for_loop_var_metadata(bcx: Block, pat: &ast::Pat) {
1077-
if fn_should_be_ignored(bcx.fcx) {
1077+
if bcx.unreachable.get() || fn_should_be_ignored(bcx.fcx) {
10781078
return;
10791079
}
10801080

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// ignore-android: FIXME(#10381)
12+
// min-lldb-version: 310
13+
14+
// compile-flags:-g
15+
16+
#![allow(unused_variables)]
17+
#![omit_gdb_pretty_printer_section]
18+
19+
// No need to actually run the debugger, just make sure that the compiler can
20+
// handle locals in unreachable code.
21+
22+
fn after_return() {
23+
return;
24+
let x = "0";
25+
let (ref y,z) = (1i32, 2u32);
26+
match (20i32, 'c') {
27+
(a, ref b) => {}
28+
}
29+
for a in [111i32].iter() {}
30+
}
31+
32+
fn after_panic() {
33+
panic!();
34+
let x = "0";
35+
let (ref y,z) = (1i32, 2u32);
36+
match (20i32, 'c') {
37+
(a, ref b) => {}
38+
}
39+
for a in [111i32].iter() {}
40+
}
41+
42+
fn after_diverging_function() {
43+
diverge();
44+
let x = "0";
45+
let (ref y,z) = (1i32, 2u32);
46+
match (20i32, 'c') {
47+
(a, ref b) => {}
48+
}
49+
for a in [111i32].iter() {}
50+
}
51+
52+
fn after_break() {
53+
loop {
54+
break;
55+
let x = "0";
56+
let (ref y,z) = (1i32, 2u32);
57+
match (20i32, 'c') {
58+
(a, ref b) => {}
59+
}
60+
for a in [111i32].iter() {}
61+
}
62+
}
63+
64+
fn after_continue() {
65+
for _ in range(0, 10i32) {
66+
break;
67+
let x = "0";
68+
let (ref y,z) = (1i32, 2u32);
69+
match (20i32, 'c') {
70+
(a, ref b) => {}
71+
}
72+
for a in [111i32].iter() {}
73+
}
74+
}
75+
76+
fn main() {
77+
after_return();
78+
after_panic();
79+
after_diverging_function();
80+
after_break();
81+
after_continue();
82+
}
83+
84+
fn diverge() -> ! {
85+
panic!();
86+
}

0 commit comments

Comments
 (0)