summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2017-02-27Auto merge of #543 - th0rex:master, r=emiliobors-servo
Add option to not add enum name to bitfield or constant variants Many C libraries prefix the variants of their enums already, because C enums are not scoped. That means if bindgen prefixes them again that can lead to ugly names like `cs_arch_CS_ARCH_ARM`. The `cs_arch_` part comes from the name of the enum itself and `CS_ARCH_ARM` is the name of the actual variant. This pull request introduces a variable for changing this behaviour, alongside command line flags and a test case. If `prepend_enum_names` is set to false the resulting variant name will be `CS_ARCH_ARM` instead of `cs_arch_CS_ARCH_ARM` as it is now. If there is anything that could be improved, or this toggle already exists (I have not found anything like that), please let me know.
2017-02-27Add tests for not prepending the enum nameth0rex
2017-02-27Add command line flag for prepend_enum_nameth0rex
2017-02-27Add toggle for prepending enum name to variantth0rex
Currently the name of a enum is always prepended to the beginning of a const or bitfield like variant. This can result in some quite unintuivite naming, if the library already prefixes its variants. For example hundreds of variants are named like this `cs_arch_CS_ARCH_ARM` when binding to the capstone library. This commit introduces a toggle for prepending the `cs_arch_` part. By default it is enabled to preserve current behaviour. It can be toggled with the `prepend_enum_name` function on the Builder.
2017-02-25Auto merge of #533 - emilio:simplify-static, r=fitzgenbors-servo
lib: Simplify the libclang setup. r? @fitzgen
2017-02-23Auto merge of #532 - emilio:random-bugfixes, r=fitzgenbors-servo
Add a workaround for #528, and fix #527 r? @fitzgen
2017-02-23Auto merge of #539 - fitzgen:gotta-land-some-of-this-stuff, r=emiliobors-servo
Gotta land some of this stuff... My patch queue is getting quite large, as I refactor templates in bindgen, so I figure I should land the stuff that is in good shape sooner rather than later :-P This stuff tweaks the named template parameter analysis, adds some edge kinds, stuff like that. This is still not used by codegen, yet. I have another branch where I de-dupe named types and all of that, and there is only two tests failing now, but still some clean up needed. This also contains the expanded documentation for te named template parameter analysis that I promised. See each commit message for details. r? @emilio
2017-02-23Auto merge of #535 - scoopr:objc, r=emiliobors-servo
More objective c features These changes implement the `id` and `SEL` type, `@class` forward declaration handling (though very superficially), and also renames the traits generated from protocols to have a `protocol_` prefix. With these, I'm able to parse and compile NSObject.h, but I haven't really tested using it yet.
2017-02-22Auto merge of #538 - emilio:testing, r=fitzgenbors-servo
Disable osx testing. Not only for the large build times, but also because builds have been stalled for long, and I had to merge a few PRs manually already. r? @fitzgen
2017-02-22Disable osx testing.Emilio Cobos Álvarez
Not only for the large build times, but also because builds have been stalled for long, and I had to merge a few PRs manually already.
2017-02-22objc: Rename protocol traits with prefixMikko Lehtonen
Apparently protocols and interface names live in a separate namespace, so there is a chance of collision, like the NSObject interface implements NSObject category
2017-02-22objc: Implement categories, id, selectorMikko Lehtonen
2017-02-21Find the set of template parameters used for any given IR nodeNick Fitzgerald
Rather than determining whether any given template parameter is used at all globally, determine the set of template parameters used by any given IR node.
2017-02-21Add more `EdgeKind`sNick Fitzgerald
2017-02-21Add TemplateDeclaration::all_template_parametersNick Fitzgerald
The all_template_parameters method gets the complete set of template parameters that can affect a given item. Note that this item doesn't need to be a template declaration itself for `Some` to be returned from this method (in contrast to `self_template_params`). If this item is a member of a template declaration, then the parent's template parameters are included here. See the example in TemplateDeclaration's doc comment for details.
2017-02-21Rename TemplateDeclaration::{template_params => self_template_params}Nick Fitzgerald
2017-02-20Merge pull request #530 from flier/padding_array_too_longEmilio Cobos Álvarez
limit padding bytes align less than structure’s
2017-02-20Merge pull request #517 from pornel/clang38Emilio Cobos Álvarez
Support older clang
2017-02-20Merge pull request #525 from fitzgen/dot-attributesEmilio Cobos Álvarez
Add more information to the graphviz output
2017-02-20Merge pull request #531 from flier/large_align_fieldEmilio Cobos Álvarez
force pad bytes before field with large aligement
2017-02-19lib: Simplify the libclang setup.Emilio Cobos Álvarez
2017-02-19ir: Parse cursor definitions in unions as children of the union.Emilio Cobos Álvarez
2017-02-19comp: parse definitions even when they aren't in the correct scope.Emilio Cobos Álvarez
2017-02-19clang: Print the semantic parent when dumping the AST.Emilio Cobos Álvarez
2017-02-19Add an option to distrust clang mangling.Emilio Cobos Álvarez
2017-02-19force pad bytes before large align fieldFlier Lu
2017-02-19fix wrong align lager than pointer sizeFlier Lu
2017-02-17Update the example graphviz imageNick Fitzgerald
2017-02-17Implement DotAttribute for a bunch of typesNick Fitzgerald
This gives us more debug information in the emitted graphviz dot files.
2017-02-17Make an ir::dot module and DotAttributes traitNick Fitzgerald
2017-02-17Auto merge of #523 - fitzgen:issue-template, r=emiliobors-servo
Create ISSUE_TEMPLATE.md Github will automatically fill this in when people file new issues. New PR because apparently I can't push to servo anymore... I think this is the same issue as with tags...
2017-02-17Auto merge of #524 - fitzgen:dot-image, r=emiliobors-servo
Add an example image of our IR rendered with graphviz This turned out really great! I can't wait to use this when debugging :) r? @emilio cc @impowski :) cc @jdm here is a screenshot for TWiS :)
2017-02-17Add an example image of our IR rendered with graphvizNick Fitzgerald
2017-02-17Create ISSUE_TEMPLATE.mdNick Fitzgerald
Github will automatically fill this in when people file new issues.
2017-02-15Auto merge of #512 - emilio:bitfields, r=fitzgenv0.22.0bors-servo
Rework how bitfields are handled. This fixes #111, and unblocks stylo. The problem with this as of right now is that it drops the accessors (though before that this code was buggy so I'm not sure it's a loss). I can probably try to re-implement those (though it'd be more complex). WDYT @fitzgen? Also, note that I changed the max_align_nonce because it was incorrect (we shouldn't generate padding, because `long double` was `128` bits).
2017-02-16Breaking version bump.Emilio Cobos Álvarez
2017-02-16Rework how bitfields are handled.Emilio Cobos Álvarez
2017-02-15Auto merge of #518 - pornel:typedefstruct, r=emiliobors-servo
typedef struct {} name Fixes #427 It looks like clang is doing the hard work of getting the right name from the typedef, but it falls back to arbitrary pretty-printed descriptions if it can't find a typedef. I couldn't find an API to check whether the name comes from a typedef, so I just filter out non-ident-like spellings.
2017-02-15Auto merge of #508 - impowski:graphviz_dot, r=fitzgenbors-servo
Graphviz implementation This will solve #484 . Right now it's really basic and I will change some of things in future commits like docs and other things. r? @fitzgen
2017-02-15Graphviz implementationArtem Biryukov
2017-02-15DocsKornel Lesiński
2017-02-15Reuse valid identifier checkKornel Lesiński
2017-02-15Test typedefed anon structs in C++Kornel Lesiński
2017-02-15Auto merge of #516 - emilio:clang-sys, r=fitzgenbors-servo
Update clang-sys. Fixes https://github.com/servo/rust-bindgen/issues/439 r? @fitzgen
2017-02-15Use typedef-derived name for anonymous enumsKornel Lesiński
2017-02-15Use typedef-derived name for anonymous structs and unionsKornel Lesiński
2017-02-15Support older clangKornel Lesiński
2017-02-15Update clang-sys.Emilio Cobos Álvarez
Fixes https://github.com/servo/rust-bindgen/issues/439
2017-02-15Auto merge of #515 - fitzgen:monotone-framework, r=emiliobors-servo
Discover which template type parameters are actually used This is just landing the initial analysis, and does not start leveraging this analysis's results instead of using the `Item::signature_contains_named_type` method yet. r? @emilio
2017-02-14Discover which template type parameters are actually usedNick Fitzgerald
C++ allows ignoring template parameters, while Rust does not. Usually we can blindly stick a `PhantomData<T>` inside a generic Rust struct to make up for this. That doesn't work for templated type aliases, however: ```C++ template <typename T> using Fml = int; ``` If we generate the naive Rust code for this alias, we get: ```ignore pub type Fml<T> = ::std::os::raw::int; ``` And this is rejected by `rustc` due to the unused type parameter. (Aside: in these simple cases, `libclang` will often just give us the aliased type directly, and we will never even know we were dealing with aliases, let alone templated aliases. It's the more convoluted scenarios where we get to have some fun...) For such problematic template aliases, we could generate a tuple whose second member is a `PhantomData<T>`. Or, if we wanted to go the extra mile, we could even generate some smarter wrapper that implements `Deref`, `DerefMut`, `From`, `Into`, `AsRef`, and `AsMut` to the actually aliased type. However, this is still lackluster: 1. Even with a billion conversion-trait implementations, using the generated bindings is rather un-ergonomic. 2. With either of these solutions, we need to keep track of which aliases we've transformed like this in order to generate correct uses of the wrapped type. Given that we have to properly track which template parameters ended up used for (2), we might as well leverage that information to make ergonomic bindings that don't contain any unused type parameters at all, and completely avoid the pain of (1). Determining which template parameters are actually used is a trickier problem than it might seem at a glance. On the one hand, trivial uses are easy to detect: ```C++ template <typename T> class Foo { T trivial_use_of_t; }; ``` It gets harder when determining if one template parameter is used depends on determining if another template parameter is used. In this example, whether `U` is used depends on whether `T` is used. ```C++ template <typename T> class DoesntUseT { int x; }; template <typename U> class Fml { DoesntUseT<U> lololol; }; ``` We can express the set of used template parameters as a constraint solving problem (where the set of template parameters used by a given IR item is the union of its sub-item's used template parameters) and iterate to a fixed-point. We use the "monotone framework" for this fix-point analysis where our lattice is the powerset of the template parameters that appear in the input C++ header, our join function is set union, and we use the `ir::traversal::Trace` trait to implement the work-list optimization so we don't have to revisit every node in the graph when for every iteration towards the fix-point. For a deeper introduction to the general form of this kind of analysis, see [Static Program Analysis by Anders Møller and Michael I. Schwartzbach][spa]. [spa]: https://cs.au.dk/~amoeller/spa/spa.pdf