From aaa8883ceb0d08b23e39ae78531dfabec6b12d0f Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 28 Nov 2023 11:21:18 -0800 Subject: [PATCH] Handle CXCursor_LinkageSpec in Clang 18+ --- bindgen/ir/item.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bindgen/ir/item.rs b/bindgen/ir/item.rs index 4f2d361e51..dd587b088b 100644 --- a/bindgen/ir/item.rs +++ b/bindgen/ir/item.rs @@ -1433,8 +1433,11 @@ impl Item { } match cursor.kind() { - // Guess how does clang treat extern "C" blocks? - CXCursor_UnexposedDecl => Err(ParseError::Recurse), + // On Clang 18+, extern "C" is reported accurately as a LinkageSpec. + // Older LLVM treat it as UnexposedDecl. + CXCursor_LinkageSpec | CXCursor_UnexposedDecl => { + Err(ParseError::Recurse) + } // We allowlist cursors here known to be unhandled, to prevent being // too noisy about this.