Skip to content
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

Add support for parse_translation_unit2 api. #70

Merged
merged 1 commit into from
May 5, 2023
Merged

Conversation

cfis
Copy link
Collaborator

@cfis cfis commented May 4, 2023

No description provided.

@ioquatix
Copy link
Owner

ioquatix commented May 4, 2023

Would it make sense to add a comment explaining why it exists, what problem it solves over the non-2 version?

@cfis
Copy link
Collaborator Author

cfis commented May 4, 2023

clang_parseTranslationUnit2 returns an error code indicating what went wrong. In addition, if you look at Clang's documentation, it focuses on clang_parseTranslationUnit2 - see https://clang.llvm.org/doxygen/group__CINDEX__TRANSLATION__UNIT.html#ga494de0e725c5ae40cbdea5fa6081027d.

The docs for clang_parseTranslationUnit are limited, only saying "Same as clang_parseTranslationUnit2, but returns the CXTranslationUnit instead of an error code. In case of an error this routine returns a NULL CXTranslationUnit, without further detailed error codes." See https://clang.llvm.org/doxygen/group__CINDEX__TRANSLATION__UNIT.html#ga2baf83f8c3299788234c8bce55e4472e

Thus my conclusion is use clang_parseTranslationUnit2 in favor of clang_parseTranslationUnit.

@ioquatix
Copy link
Owner

ioquatix commented May 4, 2023

Is there any point to continue providing the original API?

@cfis
Copy link
Collaborator Author

cfis commented May 4, 2023

No, but I didn't want to be removing existing methods. I'll leave the decision to you.

@cfis cfis force-pushed the main branch 2 times, most recently from a175a73 to 8466891 Compare May 5, 2023 06:12
@cfis
Copy link
Collaborator Author

cfis commented May 5, 2023

I updated the PR to have parse_translation_unit be a alias to parse_translation_unit2. I did leave in the FFI definition though.

@ioquatix
Copy link
Owner

ioquatix commented May 5, 2023

What do you think about dropping the alias and 2 suffix? I don’t think this will be a big compatibility issue.

@cfis
Copy link
Collaborator Author

cfis commented May 5, 2023

That's a good idea. Done.

@ioquatix ioquatix merged commit 6606686 into ioquatix:main May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants