Fix handling of anonymous names in Clang 16.#2316
Closed
pcwalton wants to merge 1 commit intorust-lang:masterfrom
Closed
Fix handling of anonymous names in Clang 16.#2316pcwalton wants to merge 1 commit intorust-lang:masterfrom
pcwalton wants to merge 1 commit intorust-lang:masterfrom
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.
Contributor
Author
|
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. |
emilio
added a commit
to emilio/rust-bindgen
that referenced
this pull request
Oct 22, 2022
…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 <pcwalton@fb.com>
emilio
requested changes
Oct 22, 2022
Contributor
emilio
left a comment
There was a problem hiding this comment.
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!
| // 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(); |
Contributor
There was a problem hiding this comment.
This is the bit I had missed in #2312 (comment), thanks for catching it :)
emilio
added a commit
to emilio/rust-bindgen
that referenced
this pull request
Oct 22, 2022
…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 <pcwalton@fb.com>
dtolnay
pushed a commit
to fbsource/bindgen
that referenced
this pull request
Oct 25, 2022
…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 <pcwalton@fb.com>
qsdrqs
pushed a commit
to qsdrqs/rust-bindgen
that referenced
this pull request
Oct 26, 2022
…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 <pcwalton@fb.com>
mqudsi
added a commit
to mqudsi/ffmpeg-the-third
that referenced
this pull request
Feb 10, 2023
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
shssoichiro
pushed a commit
to shssoichiro/ffmpeg-the-third
that referenced
this pull request
Feb 10, 2023
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
SWW13
pushed a commit
to SWW13/rust-bindgen
that referenced
this pull request
Sep 18, 2023
…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 <pcwalton@fb.com>
13 tasks
aktaboot
added a commit
to aktaboot/nixpkgs
that referenced
this pull request
Apr 17, 2024
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
vldm
pushed a commit
to velas/rust-bindgen
that referenced
this pull request
Jan 26, 2026
…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 <pcwalton@fb.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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