diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-09-29 09:14:30 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-29 09:14:30 -0500 |
commit | 48586e84394890c70f2a6817368b22b057702ed5 (patch) | |
tree | 33e2978f247ea77e06fa8dacf69eb89f575cff50 | |
parent | 2034f77fee7cace15afc549eb8397276c38973cc (diff) | |
parent | dd5962b35ffcb7c9da640de655a7d9fa1015a841 (diff) |
Auto merge of #69 - upsuper:mangling-tpl-member, r=emilio
Avoid mangling name for tpl class member. Fix #68
Not sure whether it is the right thing to do.
-rw-r--r-- | src/clang.rs | 15 | ||||
-rw-r--r-- | src/ir/function.rs | 7 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/clang.rs b/src/clang.rs index defdf547..ec6dbbe5 100644 --- a/src/clang.rs +++ b/src/clang.rs @@ -56,7 +56,7 @@ impl Cursor { } pub fn mangling(&self) -> String { - unsafe { + unsafe { String_ { x: clang_Cursor_getMangling(self.x) }.to_string() } } @@ -136,6 +136,19 @@ impl Cursor { self.specialized().is_valid() } + pub fn is_fully_specialized_template(&self) -> bool { + self.is_template() && self.num_template_args() > 0 + } + + pub fn is_in_non_fully_specialized_template(&self) -> bool { + if self.is_toplevel() { + return false; + } + let parent = self.semantic_parent(); + (parent.is_template() && !parent.is_fully_specialized_template()) || + parent.is_in_non_fully_specialized_template() + } + pub fn is_valid(&self) -> bool { unsafe { clang_isInvalid(self.kind()) == 0 diff --git a/src/ir/function.rs b/src/ir/function.rs index b95ac57b..af170935 100644 --- a/src/ir/function.rs +++ b/src/ir/function.rs @@ -75,6 +75,13 @@ fn get_abi(cc: Enum_CXCallingConv) -> abi::Abi { } pub fn cursor_mangling(cursor: &clang::Cursor) -> Option<String> { + // We early return here because libclang may crash in some case + // if we pass in a variable inside a partial specialized template. + // See servo/rust-bindgen#67. + if cursor.is_in_non_fully_specialized_template() { + return None; + } + let mut mangling = cursor.mangling(); // Try to undo backend linkage munging (prepended _, generally) |