diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2018-01-29 12:20:32 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-29 12:20:32 -0600 |
commit | 6adb00247896c7c1102e14c8a87d6a1a2e9031f9 (patch) | |
tree | e74ace939b26d2acbabf01321070bddcaf99c96e /src | |
parent | 821b133702b7fd8e719ae62382aa9579f802867a (diff) | |
parent | 29705c24aa998436bcd013387a2798b519374c78 (diff) |
Auto merge of #1240 - emilio:virtual-dtor-fix, r=fitzgen
ir: Choose the right mangling for destructors on all codepaths.
Fixes #1133.
Diffstat (limited to 'src')
-rw-r--r-- | src/codegen/mod.rs | 1 | ||||
-rw-r--r-- | src/ir/function.rs | 11 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 0ad4e805..f9e5e77c 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -1991,6 +1991,7 @@ impl MethodCodegen for Method { } }); + // TODO(emilio): We could generate final stuff at least. if self.is_virtual() { return; // FIXME } diff --git a/src/ir/function.rs b/src/ir/function.rs index b39c92b7..f027e47c 100644 --- a/src/ir/function.rs +++ b/src/ir/function.rs @@ -245,6 +245,7 @@ pub fn cursor_mangling( cursor: &clang::Cursor, ) -> Option<String> { use clang_sys; + if !ctx.options().enable_mangling { return None; } @@ -256,8 +257,14 @@ pub fn cursor_mangling( return None; } + let is_destructor = cursor.kind() == clang_sys::CXCursor_Destructor; if let Ok(mut manglings) = cursor.cxx_manglings() { - if let Some(m) = manglings.pop() { + while let Some(m) = manglings.pop() { + // Only generate the destructor group 1, see below. + if is_destructor && !m.ends_with("D1Ev") { + continue; + } + return Some(m); } } @@ -267,7 +274,7 @@ pub fn cursor_mangling( return None; } - if cursor.kind() == clang_sys::CXCursor_Destructor { + if is_destructor { // With old (3.8-) libclang versions, and the Itanium ABI, clang returns // the "destructor group 0" symbol, which means that it'll try to free // memory, which definitely isn't what we want. |