summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2017-04-17Use `trace!` instead of `debug!` logging in the template analysisNick Fitzgerald
These logs are pretty loud, so let's knock em down a log level.
2017-04-17Move the TemplateParameters trait from ir::ty to ir::templateNick Fitzgerald
Organizationally, it makes more sense.
2017-04-17Rename the `TemplateDeclaration` trait to `TemplateParameters`Nick Fitzgerald
The trait is all about accessing template parameters, and is also implemented for things that are not template declarations or definitions, but do end up using template parameters one way or another. The new name makes more sense.
2017-04-17Fix template usage analysis doc commentNick Fitzgerald
It had some incorrectness where there was a difference between the abstract `self_template_param_usage` and `template_param_usage` functions. In reality, they are different cases of the same function. The comment was misleading in that it implied that we run both on the same IR item, when in fact we will only run one or the other. I've tried to make it more clear in the new version of the comment.
2017-04-17Factor the `UsedTemplateParameters::constrain` method into smaller functionsNick Fitzgerald
The method was getting fairly large, and it is a little easier to read if we break it down into smaller parts.
2017-04-17Resolve through type refs and aliases when marking type params usedNick Fitzgerald
In stylo bindings generation, we were hitting bugs where the analysis saw a template type parameter behind a type ref to a type alias, and this was then used as an argument to a template instantiation. Because of the indirection, the analysis got confused and ignored the template argument because it was "not" a named template type, and therefore we didn't care about its usage. This commit makes sure that we keep resolving through type references and aliases to find the inner named template type parameter to add to the current item's usage set. Fixes #638.
2017-04-17Add debug!(..) logging for the template type parameters analysisNick Fitzgerald
This commit adds a bunch of debug logging to the template type parameters analysis. I've essentially adding this same code and then never committed it, like three or four different times. Because I keep re-writing it, I think it is worth keeping around in a more permanent fashion.
2017-04-17Make a builder for item resolution optionsNick Fitzgerald
We have a couple knobs to turn for item resolution, such as whether we keep going through type references and type aliases. It makes sense to have a single, easy place to configure these knobs.
2017-04-17Ensure that every item we `constrain` has a set of used template parametersNick Fitzgerald
This is a follow up to c8a206a, and the support for blacklisting in the named template parameter usage analysis. This ensures that ever item we ever call `constrain` on has an entry in `used` for the set of template parameters it uses. Additionally, it adds extra assertions to enforce the invariant. We cannot completely avoid analyzing blacklisted items because we want to consider all of a blacklisted template's parameters as used. This is why we ensure that blacklisted items have a used template parameter set rather than ensuring that blacklisted items never end up in the worklist.
2017-04-17Fix the command line flags dumper for clang argsNick Fitzgerald
...and trailing whitespace.
2017-04-17Add Builder::clang_args (plural)Simon Sapin
Use AsRef<str> rather than Into<String> because &&str (what you get when iterating &[&str]) does not implement the latter.
2017-04-14code reviewDavid Hotham
2017-04-14Option to avoid generating layout testsDavid Hotham
2017-04-13Three Changes introduced:bidit
1. Added new method `command_line_flags` to `Builder` to generate list of command line arguments supplied.[file: src/lib.rs] 2. Added new method `get_set` and `get_items` method to `RegexSet` to return immutable reference to it's fields.[file: src/regex_set.rs] 3. Added simple test case for `command_line_flags` method.[file: src/lib.rs]
2017-04-10Auto merge of #623 - ↵bors-servo
fitzgen:issue-584-stylo-blacklisting-in-template-analysis, r=emilio Correctly handle blacklisted items in the template analysis The template analysis operates on whitelisted items, and uses our tracing infrastructure to move between them. Usually, that means we can only reach other whitelisted items by tracing, because the set of whitelisted items is the transitive closure of all the items explicitly whitelisted. The exception is when some type is explicitly blacklisted. It could still be reachable via tracing from a whitelisted item, but is not considered whitelisted due to the blacklisting. The easy fix is to run the template analysis on the whole IR graph rather than just the whitelisted set. This is an approximately one line change in the analysis, however is not desirable due to performance concerns. The whole point of whitelisting is that there may be *many* types in a header, but only a *few* the user cares about, or there might be types that aren't explicitly needed and that are too complicated for bindgen to handle generally (often in `<type_traits>`). In these situations, we don't want to waste cycles or even confuse ourselves by considering such types! Instead, we keep the whitelisted item set around and check by hand whether any given item is in it during the template type parameter analysis. Additionally, we make the decision that blacklisted template definitions use all of their type parameters. This seems like a reasonable choice because the type will likely be ported to Rust manually by the bindgen user, and they will be looking at the C++ definition with all of its type parameters. They can always insert `PhantomData`s manually, so it also gives the most flexibility. Fixes #584 r? @emilio
2017-04-10Correctly handle blacklisted items in the template analysisNick Fitzgerald
The template analysis operates on whitelisted items, and uses our tracing infrastructure to move between them. Usually, that means we can only reach other whitelisted items by tracing, because the set of whitelisted items is the transitive closure of all the items explicitly whitelisted. The exception is when some type is explicitly blacklisted. It could still be reachable via tracing from a whitelisted item, but is not considered whitelisted due to the blacklisting. The easy fix is to run the template analysis on the whole IR graph rather than just the whitelisted set. This is an approximately one line change in the analysis, however is not desirable due to performance concerns. The whole point of whitelisting is that there may be *many* types in a header, but only a *few* the user cares about, or there might be types that aren't explicitly needed and that are too complicated for bindgen to handle generally (often in `<type_traits>`). In these situations, we don't want to waste cycles or even confuse ourselves by considering such types! Instead, we keep the whitelisted item set around and check by hand whether any given item is in it during the template type parameter analysis. Additionally, we make the decision that blacklisted template definitions use all of their type parameters. This seems like a reasonable choice because the type will likely be ported to Rust manually by the bindgen user, and they will be looking at the C++ definition with all of its type parameters. They can always insert `PhantomData`s manually, so it also gives the most flexibility. Fixes #584
2017-04-08update dependenciesDavid Hotham
2017-04-07Auto merge of #622 - Tiwalun:fix-570, r=fitzgenbors-servo
Don't generate accessor methods for large bitfields This fixes #570, by not generating accessor methods for large methods.
2017-04-07Auto merge of #618 - fitzgen:extra-assertions, r=emiliobors-servo
Extra assertions and cargo features * Clean up testing-only cargo features This commit ensures that all of the cargo features we have that only exist for CI/testing purposes, and aren't for external consumption, have a "testing_only_" prefix. * Define extra assertion macros This commit defines a new set of assertion macros that are only checked in testing/CI when the `testing_only_extra_assertions` feature is enabled. This makes it so that *users* of bindgen that happen to be making a debug build don't enable all these extra and expensive assertions. Additionally, this removes the `testing_only_assert_no_dangling_items` feature, and runs the assertions that were previously gated on that feature when the new `testing_only_extra_assertions` feature is enabled. r? @emilio
2017-04-08Move check for field size outside loopDominik Boehi
2017-04-08Omit accessor functions for large bitfieldsDominik Boehi
2017-04-07Provide better diagnostics for assertions in the template analysisNick Fitzgerald
This replaces various `unwrap` calls with `expect` calls that have better diagnostic messages if/when they fail.
2017-04-07Define extra assertion macrosNick Fitzgerald
This commit defines a new set of assertion macros that are only checked in testing/CI when the `testing_only_extra_assertions` feature is enabled. This makes it so that *users* of bindgen that happen to be making a debug build don't enable all these extra and expensive assertions. Additionally, this removes the `testing_only_assert_no_dangling_items` feature, and runs the assertions that were previously gated on that feature when the new `testing_only_extra_assertions` feature is enabled.
2017-04-06Clean up testing-only cargo featuresNick Fitzgerald
This commit ensures that all of the cargo features we have that only exist for CI/testing purposes, and aren't for external consumption, have a "testing_only_" prefix.
2017-04-04Warn when we can't find a template definitionNick Fitzgerald
But only if the type is not a builtin type. If it is a builtin type, then it's expected that we won't have a definition.
2017-04-04Generalize fallibility template instantiation fallibilityNick Fitzgerald
Return `None` whenever we can't find a template definition, not only when the template is a builtin.
2017-04-04Auto merge of #613 - fitzgen:upsuper-libclang-4, r=emiliobors-servo
Handle when we can't instantiate templates because we can't find a template definition https://github.com/servo/rust-bindgen/pull/594 + my review commetn about using opaque types
2017-04-04Use opaque types rather than continuing when template instantiation failsNick Fitzgerald
2017-04-04Ignore builtin template when parsing.Xidorn Quan
This should fix #584.
2017-04-04Auto merge of #612 - fitzgen:fallback-to-opaque, r=emiliobors-servo
Fall back to opaque types rather than panicking on parse failure Getting closer to figuring out some of the other template related issues in clang 4.0, but not quite ready to land them yet. Figure this should probably land in the meantime. This is just a better fallback in the face of the unknown for panics that we've had reports of in the wild, but which I haven't had time to creduce. r? @emilio
2017-04-04Add warning when we fall back to opaque blobsNick Fitzgerald
2017-04-04Tidy up handling of charDavid Hotham
2017-04-03Fall back to opaque types rather than panicking on parse failureNick Fitzgerald
2017-04-04ir: Handle char in a more cross-platform way when possible.Emilio Cobos Álvarez
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-04-04ir: Add a note about cpp_demangle.Emilio Cobos Álvarez
2017-04-04codegen: Simplify method implementations.Emilio Cobos Álvarez
2017-04-04codegen: Rename the destructor methods to "destruct".Emilio Cobos Álvarez
2017-04-04options: Allow configuring destructors via CLI.Emilio Cobos Álvarez
2017-04-04Refactor a bit and do not generate virtual destructors.Emilio Cobos Álvarez
2017-04-04Add codegen for destructors.Nikhil Shagrithaya
2017-04-04ir: Force the D1 destructor symbol even in older libclang versions.Emilio Cobos Álvarez
2017-04-03options: Allow configuring the generation of constructors.Emilio Cobos Álvarez
2017-03-31#571: Allow ast_dump to print builtins; filter builtins locallyTai Sassen-Liang
2017-03-31Merge pull request #602 from emilio/clang-5Emilio Cobos Álvarez
clang: Fix most of the clang 5.0 regressions in our tests.
2017-03-30 clang: Fix most of the clang 5.0 regressions in our tests.Emilio Cobos Álvarez
2017-03-27Auto merge of #601 - luser:string-input, r=emiliobors-servo
Add a `Builder::header_contents` method to allow passing source code as a string to a Builder Currently the Builder API requires input as header files on disk. This allows passing C source directly to clang using the existing UnsavedFile struct. I'm going to take a shot at implementing a webapp that lets users paste in C source and get the bindgen output. It would make life easier if I didn't have to write the source out to a temp file. This patch allows passing the source in as a `&str`. I wasn't quite sure where to put the new test, but it seems to work in tests.rs.
2017-03-27Add a `Builder::header_contents` method to allow passing source code as a ↵Ted Mielczarek
string to a Builder Currently the Builder API requires input as header files on disk. This allows passing C source directly to clang using the existing UnsavedFile struct.
2017-03-27Auto merge of #600 - emilio:fwd-enum, r=upsuperbors-servo
ir: Prefer the enum definition instead of the declaration when looking for variants. Fixes #599
2017-03-23ir: Prefer the enum definition instead of the declaration when looking for ↵Emilio Cobos Álvarez
variants.
2017-03-21Make vtables non-zero-size to fix a rustc warning.Simon Sapin
``` warning: found non-foreign-function-safe member in struct marked #[repr(C)]: found zero-size struct in foreign module, consider adding a member to this struct ```