Skip to content

clang::Cursor::template_arg_value should behave defensively #134

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

Closed
fitzgen opened this issue Oct 25, 2016 · 3 comments
Closed

clang::Cursor::template_arg_value should behave defensively #134

fitzgen opened this issue Oct 25, 2016 · 3 comments

Comments

@fitzgen
Copy link
Member

fitzgen commented Oct 25, 2016

We should check that the cursor's referent is a template specialization and that i is not out of bounds. If either of those things don't hold, we should return None and avoid the FFI call. There is no way to check the return value for validity if we mess this up: the behavior is undefined! Otherwise, we should make the FFI call and return Some.

This would be a nice removal of a foot gun.

http://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga46e363545effaa0794a2ba4bcfae1fe3

It is undefined to call this function on a CXCursor that does not represent a FunctionDecl or whose I'th template argument is not an integral value.

I can mentor whoever would like to work on this bug.

@highfive
Copy link

Please make a comment here if you intend to work on this issue. Thank you!

@nikhilshagri
Copy link
Contributor

I'll take a shot at this one!

@fitzgen
Copy link
Member Author

fitzgen commented Oct 31, 2016

Great! Let me know if you run into any road blocks :)

bors-servo pushed a commit that referenced this issue Nov 6, 2016
Added checks for clang::Cursor::template_arg_value

Fixes #134.
r? @fitzgen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants