-
Notifications
You must be signed in to change notification settings - Fork 719
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
Fix handling of anonymous names in Clang 16. #2316
Conversation
In trunk, Clang started emitting names like `"(unnamed enum at foo.cpp:4:2)"` for unnamed enums, structs, and unions, while previous versions emitted the empty string. This caused panics. This commit simply rewrites such names back to the empty string so that we stay compatible with both old and new versions of Clang. Closes rust-lang#2312.
With this PR, 3 tests still fail with Clang 16, but they look unrelated. In fact, for those 3 failing tests, Clang 16's output looks superior to the existing Clang. |
…y names. In Clang 16, anonymous items may return names like `(anonymous union at ..)` rather than empty names. The right way to detect them is using clang_Cursor_isAnonymous. Fixes rust-lang#2312 Closes rust-lang#2316 Co-Authored-by: Patrick Walton <[email protected]>
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! While this does fix the issue, I'd much rather check clang_Cursor_isAnonymous
than relying on the spelling.
I had a WIP in the issue, and you found the place that I had missed, so #2319 contains that and I confirmed I get the same results as with this fix.
If you're ok with that (and assuming that's green on CI), I'd rather use that approach, which seems slightly more robust.
Thanks!
@@ -1422,7 +1423,9 @@ impl CompInfo { | |||
|
|||
// A declaration of an union or a struct without name | |||
// could also be an unnamed field, unfortunately. | |||
if cur.spelling().is_empty() && | |||
let mut spelling = cur.spelling(); |
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.
This is the bit I had missed in #2312 (comment), thanks for catching it :)
…y names. In Clang 16, anonymous items may return names like `(anonymous union at ..)` rather than empty names. The right way to detect them is using clang_Cursor_isAnonymous. Fixes rust-lang#2312 Closes rust-lang#2316 Co-Authored-by: Patrick Walton <[email protected]>
…y names. In Clang 16, anonymous items may return names like `(anonymous union at ..)` rather than empty names. The right way to detect them is using clang_Cursor_isAnonymous. Fixes #2312 Closes #2316 Co-Authored-by: Patrick Walton <[email protected]>
…y names. In Clang 16, anonymous items may return names like `(anonymous union at ..)` rather than empty names. The right way to detect them is using clang_Cursor_isAnonymous. Fixes rust-lang#2312 Closes rust-lang#2316 Co-Authored-by: Patrick Walton <[email protected]>
…y names. In Clang 16, anonymous items may return names like `(anonymous union at ..)` rather than empty names. The right way to detect them is using clang_Cursor_isAnonymous. Fixes rust-lang#2312 Closes rust-lang#2316 Co-Authored-by: Patrick Walton <[email protected]>
This patch upgrades the `bindgen` dependency to version 0.64 which includes a fix for an upstream issue broken builds when building w/ clang 16 or newer [0]. The use of a wildcard `*` was removed in bindgen 0.62 [1], code has been updated to use the regex approach instead to continue working. [0]: rust-lang/rust-bindgen#2316 [1]: rust-lang/rust-bindgen#2373
This patch upgrades the `bindgen` dependency to version 0.64 which includes a fix for an upstream issue broken builds when building w/ clang 16 or newer [0]. The use of a wildcard `*` was removed in bindgen 0.62 [1], code has been updated to use the regex approach instead to continue working. [0]: rust-lang/rust-bindgen#2316 [1]: rust-lang/rust-bindgen#2373
…y names. In Clang 16, anonymous items may return names like `(anonymous union at ..)` rather than empty names. The right way to detect them is using clang_Cursor_isAnonymous. Fixes rust-lang#2312 Closes rust-lang#2316 Co-Authored-by: Patrick Walton <[email protected]>
The build was encountering an issue in rust-bindgen, that has been fixed[1], but nettle-sys depends on an old version of rust-bindgen, Updated nettle-sys, patched Cargo.lock [1]- rust-lang/rust-bindgen#2316 https://bugs.launchpad.net/ubuntu/+source/rust-bindgen/+bug/2030886
In trunk, Clang started emitting names like
"(unnamed enum at foo.cpp:4:2)"
for unnamed enums, structs, and unions, while previous versions emitted the empty string. This caused panics.This commit simply rewrites such names back to the empty string so that we stay compatible with both old and new versions of Clang.
Closes #2312.
r? @emilio