Skip to content

Commit

Permalink
Recognize inline namespaces using clang's dedicated API for that
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay authored and emilio committed Nov 28, 2024
1 parent 9123846 commit 7fd78ad
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
22 changes: 9 additions & 13 deletions bindgen-tests/tests/expectations/tests/inline_namespace_macro.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions bindgen/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,11 @@ impl Cursor {
})
}
}

/// Is this cursor's referent a namespace that is inline?
pub(crate) fn is_inline_namespace(&self) -> bool {
unsafe { clang_Cursor_isInlineNamespace(self.x) != 0 }
}
}

/// A struct that owns the tokenizer result from a given cursor.
Expand Down
4 changes: 4 additions & 0 deletions bindgen/ir/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2328,6 +2328,10 @@ If you encounter an error missing from this list, please file an issue or a PR!"
}
}

if cursor.is_inline_namespace() {
kind = ModuleKind::Inline;
}

(module_name, kind)
}

Expand Down

0 comments on commit 7fd78ad

Please sign in to comment.