New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve tracing so it doesn't ignore opaque stuff when it shouldn't #387
Conversation
r? @fitzgen Needs a test, but should be straight forward. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM, but I have a couple comments below.
"{" => None, | ||
s => Some(s.to_owned()), | ||
let mut module_name = None; | ||
if let Some(tokens) = self.translation_unit.tokens(&cursor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be absolutely lovely if this tokens processing wasn't inline, and instead was a separate helper function.
fn is_inline_namespace(unit: &clang::TranslationUnit, cursor: &clang::Cursor) -> bool {
...
}
namespace foo { | ||
inline namespace bar { | ||
using Ty = int; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the C++ semantics for when there are conflicts between the inline namespace and its parent namespace? If it is permitted at all, and not a compilation error, then we should test that we Do The Right Thing in this scenario.
namespace foo {
inline namespace bar {
using Ty = int;
}
using Ty = char;
}
http://stackoverflow.com/questions/24220127/redefinition-member-of-the-namespace-into-the-nested-inline-namespace#24220504 seems relevant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, what about multiple nested inline namespaces? Seems like another good thing to test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, that's a good question. Multiple nested inline namespaces work fine with this patch.
Overriding an item defined in an inline namespace is legal, though referencing it is a compile error.
If we want to support this edge case (which I think is kinda pointless tbh), we should keep all the namespaces in Rust I think. That will make bindgen harder to use with the STL though, given you no longer have std::string, but std::__gnu_xxx::string, etc.
This deserves a bit more discussion so I'll move this to another PR.
This makes sense because there's no special meaning for some of them to be opaque.
53843f4
to
2ad1b52
Compare
Dropped the inline namespace commit, and added a test. @bors-servo r=fitzgen |
📌 Commit 66447ff has been approved by |
Improve tracing so it doesn't ignore opaque stuff when it shouldn't Concretely, trace through functions, pointers, arrays, references, resolved type references, and template references, which are the types for which either: * There's no special meaning to be opaque, or * They're just placeholders that point to other types.
☀️ Test successful - status-travis |
Concretely, trace through functions, pointers, arrays, references, resolved type references, and template references, which are the types for which either: