diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2018-05-15 19:31:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-15 19:31:50 -0400 |
commit | d6d097cc1a662ef8131e47eaea72bc0c863e43b2 (patch) | |
tree | 10ab032849549f0e74e39caa5ac4551515317e70 /src/ir/context.rs | |
parent | 74dcb202e398f8101a5bb387628d21ed0f781359 (diff) | |
parent | 716d53b02d363880184c05e80f8bf4982ee1ed23 (diff) |
Auto merge of #1312 - emilio:constness-woes, r=fitzgen
ir: Handle *const T at the codegen level.
Followup to #1311.
Diffstat (limited to 'src/ir/context.rs')
-rw-r--r-- | src/ir/context.rs | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/ir/context.rs b/src/ir/context.rs index bbcc5698..ccb7b75a 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -1926,8 +1926,43 @@ impl BindgenContext { parent_id: Option<ItemId>, ty: &clang::Type, ) -> TypeId { + self.build_wrapper( + with_id, + wrapped_id, + parent_id, + ty, + ty.is_const(), + ) + } + + /// A wrapper over a type that adds a const qualifier explicitly. + /// + /// Needed to handle const methods in C++, wrapping the type . + pub fn build_const_wrapper( + &mut self, + with_id: ItemId, + wrapped_id: TypeId, + parent_id: Option<ItemId>, + ty: &clang::Type, + ) -> TypeId { + self.build_wrapper( + with_id, + wrapped_id, + parent_id, + ty, + /* is_const = */ true, + ) + } + + fn build_wrapper( + &mut self, + with_id: ItemId, + wrapped_id: TypeId, + parent_id: Option<ItemId>, + ty: &clang::Type, + is_const: bool, + ) -> TypeId { let spelling = ty.spelling(); - let is_const = ty.is_const(); let layout = ty.fallible_layout().ok(); let type_kind = TypeKind::ResolvedTypeRef(wrapped_id); let ty = Type::new(Some(spelling), layout, type_kind, is_const); |