Clang C module importer bug?

Hi all,

I think there's a new-ish way to diagnose Clang importer questions such as yours, thanks to @NuriAmari’s work in PR #39923: Improve ClangImporter Diagnostics . From reading the PR, I assumed you should be able to pass -Xfrontend -enable-experimental-clang-importer-diagnostics to the compiler, but this doesn’t work for me with your sample project with Swift 5.7 (Xcode 14.0.1 or Xcode 14.1b3) because the compiler doesn’t recognize the flag:

error: unknown argument: '-enable-experimental-clang-importer-diagnostics'

Maybe this flag is not part of the Xcode toolchains (yet?)? I haven't tested with a current nightly toolchain. I think there's a new-ish way to diagnose Clang importer questions such as yours, thanks to @NuriAmari’s work in PR #39923: Improve ClangImporter Diagnostics . From reading the PR, I assumed you should be able to pass -Xfrontend -enable-experimental-clang-importer-diagnostics to the compiler, but this doesn’t work for me with your sample project with Swift 5.7 (Xcode 14.0.1 or Xcode 14.1b3) because the compiler doesn’t recognize the flag:

error: unknown argument: '-enable-experimental-clang-importer-diagnostics'

Maybe this flag is not part of the Xcode toolchains (yet?)? I haven't tested with a current nightly toolchain.

In terms of enabling the improved ClangImporter diagnostics, they are enabled by default now: [Pitch] Lazy ClangImporter Diagnostics Enabled by Default. Unfortunately, @mickeyl the case you are facing is not covered by the diagnostics.

On swift main at least, the macro is dropped here: https://github.com/apple/swift/blob/main/lib/ClangImporter/ImportMacro.cpp#L503. It seems I left myself a TODO to handle this case, but never got to it. Feel free to attach this post to the issue: [SR-15429] Add Missing Macro Diagnostics to ClangImporter · Issue #57735 · apple/swift · GitHub. At this moment, I don't really have any advice aside from using the __gmpz_clear name in the interim. I don't have time to investigate further at this moment, but I will try to either improve the diagnostic or see if we can import this macro, hopefully sometime in the next week or so.

2 Likes