summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
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-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-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-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-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
2017-02-14Add the `Item::is_named` helper methodNick Fitzgerald
2017-02-13Auto merge of #513 - emilio:const-fn-arg, r=fitzgenbors-servo
Use the constness of the inner type when converting array function args. Fixes https://github.com/servo/rust-bindgen/issues/509 I'm actually surprised we had no tests for this.
2017-02-14codegen: Use the constness of the inner type when converting array function ↵Emilio Cobos Álvarez
arguments. Fixes https://github.com/servo/rust-bindgen/issues/509 I'm actually surprised we had no tests for this. Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-02-13Run `cargo fmt`Nick Fitzgerald
2017-02-13Refactor IR graph traversal infrastructureNick Fitzgerald
This makes the IR traversal infrastructure generic. It makes it so we can use the same traversal code for whitelisting traversals and asserting no dangling item references. Therefore the queue of items to visit is generic (whitelisting uses DFS, while asserting against dangling uses BFS), the storage for the seen set (whitelisting uses a simple set, asserting against dangling uses a map from item to the item from which it was discovered). It also introduces the concept of different kinds of edges in the IR graph, and the ability to choose which edges to follow. This means we can simplify non-transitive whitelisting to a simple function that always returns "no do not follow this edge". It plays an important part for future analysis of which template declaration type parameters are used or not.
2017-02-13Rename ir::traversal::TypeCollector to ir::traversal::TraceNick Fitzgerald
And its `collect_types` method to `trace`.
2017-02-13Move TypeCollector to the ir::traversal moduleNick Fitzgerald
2017-02-13Rename WhitelistedItemsIter to ItemTraversalNick Fitzgerald
Also moves it out to its own ir::traversal module, and moves ItemSet to the ir::item module.
2017-02-10Auto merge of #504 - emilio:xidorn-template-specialization, r=emiliobors-servo
Don't mangle name in partial specification (with Cargo.lock update)
2017-02-10Don't mangle name in partial specificationXidorn Quan
2017-02-10ir: Cut the parenthood chain in pointers, references and arrays.Emilio Cobos Álvarez
2017-02-10Remove duplicated functions that had sneaked in.Emilio Cobos Álvarez
2017-02-10ir: Don't parse non-semantic-children cursor as inner structs.Emilio Cobos Álvarez
Fixes: https://github.com/servo/rust-bindgen/issues/482
2017-02-09Auto merge of #501 - faineance:master, r=fitzgenbors-servo
Rename llvm_stable feature and remove references from docs. Fixes: https://github.com/servo/rust-bindgen/issues/409
2017-02-09remove underscore prefix from feature namefaineance
2017-02-09rename llvm_stable feature, and remove references from docsfaineance
2017-02-09Auto merge of #491 - fitzgen:template-instantiation, r=emiliobors-servo
Template instantiation I very much suspect this needs a rebase, but I haven't done it yet. This is the majority of #446, although it doesn't have the name generation for anonymous named types patches yet (that will be a different PR).
2017-02-09Auto merge of #497 - emilio:clang-3.5, r=KiChjangbors-servo
ir: Remove unused call to clang_Cursor_isAnonymous. Fixes #496
2017-02-08Auto merge of #498 - pornel:clang35, r=emiliobors-servo
Clang 3.5 support Fixes #496
2017-02-08ir: Remove unused call to clang_Cursor_isAnonymous.Emilio Cobos Álvarez
Fixes #496
2017-02-08Run `cargo fmt`Nick Fitzgerald
2017-02-08Make instantiate_template fallibleNick Fitzgerald
2017-02-08Run `cargo fmt`Nick Fitzgerald
2017-02-08Refactor how template instantiation is performedNick Fitzgerald
This commit renames `build_template_wrapper` to `instantiate_template` because that is what it is really doing. Additionally, it completely reworks its logic. Sometimes clang gives us rather sorry ASTs for template instantiations (particularly when they involve incomplete template declarations) and we need to manually reconstruct the template argument nesting.
2017-02-08Create PartialType for types we are in the middle of parsingNick Fitzgerald
This commit create the PartialType type to represent types that we are in the middle of parsing and their cursor where we found them. Additionally, it fixes a long standing FIXME to make `currently_parsed_types` private. Finally, it implements `TemplateDeclaration` for `PartialType` so that we can get information about a partially parsed template declaration type's template parameters.
2017-02-08Introduce the TemplateDeclaration traitNick Fitzgerald
The TemplateDeclaration trait aggregates information about template declarations (separate from instantiations and specializations) and their template parameters into a single source of truth.
2017-02-08Rename TypeKind::TemplateRef to TypeKind::TemplateInstantiationNick Fitzgerald
2017-02-08Rustfmt on src/clang.rsNick Fitzgerald
2017-02-08Introduce a CanonicalDeclaration typeNick Fitzgerald
The `CanonicalTypeDeclaration` type exists as proof-by-construction that its cursor is the canonical declaration for its type. If you have a `CanonicalTypeDeclaration` instance, you know for sure that the type and cursor match up in a canonical declaration relationship, and it simply cannot be otherwise.
2017-02-08Add children-related helper methods to CursorNick Fitzgerald
This commit adds collect_children, has_children, and has_at_least_num_children methods to Cursor.