summaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)Author
2017-06-20Ensure that every item is in some module's children listNick Fitzgerald
Previously, if an item's parent was not a module (eg a nested class definition whose parent it the outer class definition) and the parent was not whitelisted but the item was transitively whitelisted, then we could generate uses of the item without emitting any definition for it. This could happen because we were relying on the outer type calling for code generation on its inner types, but that relies on us doing code generation for the outer type, which won't happen if the outer type is not whitelisted. This commit avoids this gotcha by ensuring that all items end up in a module's children list, and so will be code generated even if their parent is not whitelisted. Fixes #769
2017-06-20codegen: Inline {read,write}_unaligned in order to support rust 1.15.Emilio Cobos Álvarez
... Which is what Firefox uses right now.
2017-06-20Allow path separators in test-one.shNick Fitzgerald
Before this commit, test-one.sh was unusable with tests/headers/template.hpp because there were too many things with "template.hpp" as a suffix. This allows us to specify "/template.hpp" to run the test.
2017-06-19Auto merge of #763 - rigelk:757-unstable-defaults, r=emilio,fitzgenbors-servo
switch defaults from generating unstable Rust to generating stable Rust As said in the issue: - changing the Builder::no_unstable_rust method to the Builder::unstable_rust method - changing the --no-unstable-rust flag to a --unstable-rust flag in src/options.rs - changing bindgen-flags header in the test headers to remove the --no-unstable-rust flag - removing --no-unstable-rust flag in ./test/test-one.sh Fixes #757 r? @fitzgen
2017-06-19switch defaults from generating unstable Rust to generating stable RustPierre-Antoine Rault
- changing the Builder::no_unstable_rust method to the Builder::unstable_rust method - changing the --no-unstable-rust flag to a --unstable-rust flag in src/options.rs - changing bindgen-flags header in the test headers to remove the --no-unstable-rust flag Fixes #757
2017-06-19Auto merge of #762 - emilio:much-brokenness, r=fitzgenbors-servo
Moar bitfield fixes Now with the right branch name. See individual commits for details.
2017-06-18Test const mod enum variants shadowing "Type"Travis Finkenauer
2017-06-18Fix recursive aliases to const module enumTravis Finkenauer
Item::is_constified_enum_module() only returns true for the base type, not for "layers" of aliases. Added a "simple alias" test and added content to the types test.
2017-06-18codegen: Fix bitfield getter/setters so they work with NPOT sizes.Emilio Cobos Álvarez
2017-06-17Refactor test scriptTravis Finkenauer
Check for correct arguments, quote variables, ensure exactly one test file matches the pattern, and print usage information.
2017-06-17ir: use a bigger integer for the bitfield mask in 32bit, to avoid overflows.Emilio Cobos Álvarez
Like the ones seen in https://bugzilla.mozilla.org/show_bug.cgi?id=1365254#c22
2017-06-17ir: Correct size calculation of a bitfield unit.Emilio Cobos Álvarez
Fixes #734
2017-06-17Auto merge of #756 - upsuper:mangling-win32, r=emiliobors-servo
Correct mangling hack for win32
2017-06-16Refactor namespace code and testTravis Finkenauer
2017-06-16codegen: Respect prepend_enum_name in constified variants.Emilio Cobos Álvarez
Fixes #755
2017-06-16Correct mangling hack for win32Xidorn Quan
2017-06-16Add constified module enum template testTravis Finkenauer
2017-06-16Add more constified module enum testsTravis Finkenauer
2017-06-15Auto merge of #750 - emilio:that-bug-is-going-to-hunt-me-down, r=fitzgenbors-servo
ir: Make the workaround for LLVM bug 9069 more reliable. Should fix https://github.com/zzeroo/libmodbus-rs/issues/4
2017-06-15ir: Correct mac target check.Emilio Cobos Álvarez
Because I'm stupid.
2017-06-15ir: Make the workaround for LLVM bug 9069 more reliable.Emilio Cobos Álvarez
Should fix https://github.com/zzeroo/libmodbus-rs/issues/4
2017-06-14Add typedef/namespace tests for module const enumTravis Finkenauer
2017-06-11Adds `--constified-enum-module` option per #699Travis Finkenauer
2017-06-10ir: Prevent integer overflow when using word-size bitfields.Emilio Cobos Álvarez
Fixes #739
2017-06-05ir: Fix a bunch of bitfield correctness issues.Emilio Cobos Álvarez
In particular, the "flush the allocation unit" logic is only valid for ms_structs (that is, MSVC). It's slightly annoying to have this different behavior, but it'd work just fine if we'd turn that on for MSVC. This patch doesn't do that, yet at least, and adds tests for all the weird bitfield alignments around. Fixes #726 (and another set of hidden issues by the old code).
2017-05-25Allow asserting expectations across different libclang versionsNick Fitzgerald
Rather than having a tests that we only run if libclang >= 3.9, this makes the test suite dynamically detect when we have different expectations for different libclang versions. It does this by adding `tests/expectations/tests/libclang-$VERSION` directories, and `testing_only_libclang_$VERSION` features that are consulted when the usual expectation file does not exist. Fixes #697
2017-05-24Always ignore style lints in test bindingsNick Fitzgerald
2017-05-24Improve test pragma parsingNick Fitzgerald
We should take any number of `// bindgen-$whatever` flags at the top of the file. Only considering the first three lines of the file was confusing when I tried adding new pragmas with an empty line between the new ones and old ones.
2017-05-24Only run call-conv-field.h test on linuxNick Fitzgerald
This is a temporary work around for issue #593 and this test failing on MacOS because we don't currently handle when bindgen's target OS is not the same as the emitted bindings' target OS.
2017-05-24Fix bitfield generation bug with const functionzzhu
Const function can't have variables or blocks.
2017-05-21Add a test for short enums.Emilio Cobos Álvarez
Closes #711.
2017-05-20codegen: Reuse the next_child_local_id hack for template instantiations.Emilio Cobos Álvarez
This should be good enough, following the pattern of anonymous items, and should prevent most of the current noise in stylo updates. Closes #620 Fixes #619
2017-05-19Add bitfield allocation unit constructorsNick Fitzgerald
This commit gives bindgen the ability to generate constructors for bitfield allocation units. This enables more ergonomic use of struct literals for bindings structs that contain bitfields. Additionally, when we are generating unstable Rust, these constructors are marked as const functions. This enables the creation of const binding structs that contain bitfields.
2017-05-18Move bitfields into the IRNick Fitzgerald
This commit moves bitfields and the computation of their allocation units into the IR. They were previously computed on-the-fly during code generation. In addition to breaking up and compartmentalizaing a portion of the gargantuan `CodeGeneration` implementation for `CompInfo`, this paves the way for adding const-fn bitfield unit constructors.
2017-05-17Use the default test flags in test-one.shNick Fitzgerald
2017-05-17Small improvements to test-one.shNick Fitzgerald
Allow running tests that don't have `bindgen-flags` pragmas. Less noisy output. Show diff if the generated bindings differ from the expected bindings.
2017-05-10Add other bitwise ops for bitflag enumsJon Gjengset
2017-05-10ir: Handle properly template alias instantiations in clang >3.9.Emilio Cobos Álvarez
This fixes tests/expectations/tests/type_alias_template_specialized.rs in those clang versions (without regressions, hopefully), and makes the behavior the proper one, without needing replacements.
2017-05-08codegen: Make phantom fields public.v0.25.0Emilio Cobos Álvarez
Otherwise you can't construct structs outside of the bindings file, which is breaking. Also, given the previous change was breaking and I didn't notice, I yanked 0.24.1.
2017-05-08ir: Don't assume template instantiation argument with vtable implies vtable.Emilio Cobos Álvarez
2017-05-05Emit `PhantomData<UnsafeCell<T>>` members for all generic parametersKowasaki
This makes generated generic structs lifetime invariant, since we cannot know the C++ type's true variance. Fixes #506
2017-05-03objc: Handle class and instance method with same nameMikko Lehtonen
Prefixes the clashing class method with class_ prefix
2017-05-03objc: Fix infinite recursionMikko Lehtonen
While parsing a Objective C property with function pointer type, bindgen hanged and died. This is still not generating valid code function signature for the property, but at least it is not dying. The actual fix was proposed by emilio.
2017-05-03objc: Handle template paramsMikko Lehtonen
The objetive-c template type params were handled as Typedefs so every interface generated its own, clashing in the namespace. This now maps them to id.
2017-05-01Auto merge of #681 - fitzgen:allow-multiple-headers, r=emiliobors-servo
Generate bindings to all headers passed to `Builder::header` Inspired by real misconfiguration from inside stylo. The previous behavior was that it would reconfigure the builder to generate bindings to the last header `Builder::header` was invoked with. This was not what people would expect: they expected it to generate bindings for all of the headers, and were accidentally misconfiguring their builders. This is a breaking change, but moves us inline with users' expectations. r? @emilio
2017-05-01Generate bindings to all headers passed to `Builder::header`Nick Fitzgerald
The previous behavior was that it would reconfigure the builder to generate bindings to the last header `Builder::header` was invoked with. This was not what people would expect: they expected it to generate bindings for all of the headers, and were accidentally misconfiguring their builders. This is a breaking change, but moves us inline with users' expectations.
2017-05-01ir: Support nested namespace specifiers.Emilio Cobos Álvarez
2017-05-01Trace opaque types' template parameters and inner typesNick Fitzgerald
The template parameter usage analysis needs to see the template parameters' definitions and have edges from any inner type to the parent in order to propagate data flow through dependencies properly. Fixes #674
2017-04-26Fix the test-one.sh script for OSXNick Fitzgerald
OSX has the BSD mktemp which is subtly different from GNU's in uninteresting ways.
2017-04-26Fix blacklisting and fix instantiations in the template analysisNick Fitzgerald
For correctness, I now realize that we need to consider the full transitive closure of whitelisted items, including blacklisted items that we would otherwise not consider as whitelisted. We need this so that the data flow propagates properly through dependencies that may or may not be blacklisted. This means that tracing infrastructure needs to trace items regardless if they are hidden or blacklisted. It is now the responsibility of consumers of a traversal to filter out such items if they are unwanted. I did this by turning the `ir::context::WhitelistedItems` type alias into a proper struct that performs the filtering. This approach avoids changing the many callers of whitelisted items traversal iteration. Additionally, and equally importantly, I realized that the case of template instantiations' template usages were subtly wrong. Before this commit, we only considered a template argument used if it itself was a template parameter. This breaks down in the face of template instantiations used as arguments to another template instantiation. If the inner instantiation used a template parameter, we would accidentally lose that usage. For example: ```c++ template <class T> struct Foo { // Direct usage of a template parameter T in an instantiation always worked. Bar<T> member; // While indirect usage of a template parameter nested within another // instantiation did NOT previously work. Bar< Qux<T> > another_member; }; ``` The solution is to take the union of each template arguments' template usages, not the template arguments themselves but only if they were themselves a template parameter. Obvious in retrospect!