Skip to main content

Python bindings for the LLVM Demangle library, with vendored LLVM source.

Project description

LLVM-Demangle

Python bindings for the LLVM Demangle library, with vendored LLVM source.

Exposes Itanium, Microsoft, Rust, and D language demanglers, plus ItaniumPartialDemangler for querying individual symbol components. Ships all LLVM versions 11–21 in a single package with runtime version selection. No system LLVM installation required.

Install

pip install llvm-demangle-fxti

Quick start

import llvmdemangle

llvmdemangle.demangle("_Z3fooi")           # 'foo(int)'
llvmdemangle.demangle("?foo@@YAHH@Z")      # 'int __cdecl foo(int)'

Version selection

By default, the highest available LLVM version (21) is used. Use backend() to get a specific version:

import llvmdemangle

# Default (LLVM 21)
llvmdemangle.demangle("_Z3fooi")

# Use a specific LLVM version
v18 = llvmdemangle.backend(18)
v18.demangle("_Z3fooi")
v18.ItaniumPartialDemangler("_ZN3Foo3barEid")
v18.LLVM_VERSION  # 18

# See what's available
llvmdemangle.SUPPORTED_VERSIONS  # [11, 12, 13, ..., 21]

API reference

LLVM_VERSION

Integer constant indicating the LLVM version of the default backend (e.g. 21).

SUPPORTED_VERSIONS

List of all available LLVM backend versions (e.g. [11, 12, ..., 21]).

backend(llvm_version) -> module

Return the backend module for a specific LLVM version. The returned module has the same API as the top-level llvmdemangle module.

demangle(name) -> str

Auto-detect mangling scheme and demangle. Returns the original string if unrecognized.

llvmdemangle.demangle("_Z3fooi")       # 'foo(int)'
llvmdemangle.demangle("?foo@@YAHH@Z")  # 'int __cdecl foo(int)'
llvmdemangle.demangle("plain")         # 'plain'

itanium_demangle(name, *, parse_params=True) -> str | None

Demangle an Itanium C++ ABI symbol. Returns None on failure.

parse_params=False omits function parameters (LLVM >= 18; ignored on older versions).

llvmdemangle.itanium_demangle("_Z3fooi")                        # 'foo(int)'
llvmdemangle.itanium_demangle("_Z3fooi", parse_params=False)    # 'foo'  (LLVM 18+)

microsoft_demangle(name, *, flags=0) -> tuple[str, int] | None

Demangle a Microsoft Visual C++ symbol. Returns (demangled_name, n_read) or None.

llvmdemangle.microsoft_demangle("?foo@@YAHH@Z")
# ('int __cdecl foo(int)', 12)

llvmdemangle.microsoft_demangle("?foo@@YAHH@Z", flags=llvmdemangle.MSDF_NO_CALLING_CONVENTION)
# ('int foo(int)', 12)

Flag constants:

Constant Value Description
MSDF_NONE 0 No flags
MSDF_DUMP_BACKREFS 1 Dump back-references
MSDF_NO_ACCESS_SPECIFIER 2 Omit access specifiers
MSDF_NO_CALLING_CONVENTION 4 Omit calling convention
MSDF_NO_RETURN_TYPE 8 Omit return type
MSDF_NO_MEMBER_TYPE 16 Omit member type
MSDF_NO_VARIABLE_TYPE 32 Omit variable type (LLVM >= 14)

rust_demangle(name) -> str | None

Demangle a Rust v0 symbol. Returns None on failure. Requires LLVM >= 13.

llvmdemangle.rust_demangle("_RNvC8my_crate3foo")  # 'my_crate::foo'

dlang_demangle(name) -> str | None

Demangle a D language symbol. Returns None on failure. Requires LLVM >= 14.

llvmdemangle.dlang_demangle("_Dmain")  # 'D main'

non_microsoft_demangle(name, *, can_have_leading_dot=True, parse_params=True) -> str | None

Demangle a non-Microsoft symbol (Itanium, Rust, or D). Returns None on failure. Requires LLVM >= 14. parse_params requires LLVM >= 18.

get_arm64ec_insertion_point(name) -> int | None

Get the Arm64EC insertion point in a mangled name. Requires LLVM >= 19.

ItaniumPartialDemangler(name)

Parse Itanium C++ symbols into an AST and query individual components. Raises ValueError if the name cannot be parsed.

d = llvmdemangle.ItaniumPartialDemangler("_ZN3Foo3barIiEEvi")
d.full_name              # 'void Foo::bar<int>(int)'
d.function_base_name     # 'bar'
d.function_decl_context  # 'Foo'
d.function_name          # 'Foo::bar<int>'
d.function_parameters    # '(int)'
d.function_return_type   # 'void'
d.is_function            # True
d.is_data                # False
d.is_ctor_or_dtor        # False
d.is_special_name        # False
d.has_function_qualifiers  # False

String properties return None when the property doesn't apply (e.g. function_name on a data symbol).

Version availability

Feature Minimum LLVM
demangle, itanium_demangle, microsoft_demangle 11
ItaniumPartialDemangler 11
rust_demangle 13
dlang_demangle, non_microsoft_demangle 14
MSDF_NO_VARIABLE_TYPE 14
itanium_demangle(parse_params=) 18
non_microsoft_demangle(parse_params=) 18
get_arm64ec_insertion_point 19

Functions unavailable for the selected LLVM backend raise NotImplementedError.

Build from source

# 1. Vendor LLVM Demangle source (downloads from GitHub releases)
python vendor_llvm.py --llvm-version 18
python vendor_llvm.py --llvm-version 21

# 2. Build & install (compiles backends for all vendored versions)
pip install .

Supported LLVM versions: 11–21. Only vendored versions are compiled.

License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llvm_demangle_fxti-1.0.0.tar.gz (886.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

llvm_demangle_fxti-1.0.0-cp36-abi3-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.6+Windows x86-64

llvm_demangle_fxti-1.0.0-cp36-abi3-win32.whl (1.0 MB view details)

Uploaded CPython 3.6+Windows x86

llvm_demangle_fxti-1.0.0-cp36-abi3-musllinux_1_2_x86_64.whl (11.5 MB view details)

Uploaded CPython 3.6+musllinux: musl 1.2+ x86-64

llvm_demangle_fxti-1.0.0-cp36-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (10.8 MB view details)

Uploaded CPython 3.6+manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

llvm_demangle_fxti-1.0.0-cp36-abi3-macosx_11_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.6+macOS 11.0+ ARM64

llvm_demangle_fxti-1.0.0-cp36-abi3-macosx_10_13_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.6+macOS 10.13+ x86-64

File details

Details for the file llvm_demangle_fxti-1.0.0.tar.gz.

File metadata

  • Download URL: llvm_demangle_fxti-1.0.0.tar.gz
  • Upload date:
  • Size: 886.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for llvm_demangle_fxti-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3c87b267521988f185c86b4eb7fe218fe1a09ddda601e881822761a3443d29ae
MD5 37393354e5e24da6a18fc224e6e36d97
BLAKE2b-256 04819181de204a23a8e23b0a5f5b31ae11d5907fb075651ffcf75a4f6bc74f5b

See more details on using hashes here.

Provenance

The following attestation bundles were made for llvm_demangle_fxti-1.0.0.tar.gz:

Publisher: build.yml on FXTi/llvmdemangle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llvm_demangle_fxti-1.0.0-cp36-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for llvm_demangle_fxti-1.0.0-cp36-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 91de5620086570a338aeb696ef4f9cc43e50256b9512bbc158d5d00fcca734c0
MD5 1a42c1d246b672cc351f56977de566be
BLAKE2b-256 ad76da264e2940a05e39ad497a262325a77e6d033886cd3259ed0d3e6c68cfc6

See more details on using hashes here.

Provenance

The following attestation bundles were made for llvm_demangle_fxti-1.0.0-cp36-abi3-win_amd64.whl:

Publisher: build.yml on FXTi/llvmdemangle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llvm_demangle_fxti-1.0.0-cp36-abi3-win32.whl.

File metadata

File hashes

Hashes for llvm_demangle_fxti-1.0.0-cp36-abi3-win32.whl
Algorithm Hash digest
SHA256 9dde9976ce511343275385ec988a945e1d039d221b121a0b4f8faa023dcc3ebe
MD5 50fe028cc1cad5f247e70f4878e1f8df
BLAKE2b-256 8716e18a066f438ad5ca20b9a36b06504913d48384b720708947d660a1cc1c6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for llvm_demangle_fxti-1.0.0-cp36-abi3-win32.whl:

Publisher: build.yml on FXTi/llvmdemangle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llvm_demangle_fxti-1.0.0-cp36-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for llvm_demangle_fxti-1.0.0-cp36-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1130c0d79ee0335875b2409b991587257ada2202ffe37a8a65b606f8d0ae93ee
MD5 8bee515b04308608d498232a4270429a
BLAKE2b-256 ffc60bffe73d2a2419eff024bc4fb638cb4041878d77efa9a76541af8551e56b

See more details on using hashes here.

Provenance

The following attestation bundles were made for llvm_demangle_fxti-1.0.0-cp36-abi3-musllinux_1_2_x86_64.whl:

Publisher: build.yml on FXTi/llvmdemangle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llvm_demangle_fxti-1.0.0-cp36-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for llvm_demangle_fxti-1.0.0-cp36-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c5f7b682277439935524849fef16234ecb983c08ef47c930287650b64ec61b31
MD5 067a8627ba2ed65d99be4dba8f3a7520
BLAKE2b-256 533eb6108a8373f9fa3af04573b2af345cc4370c03039256e3c8f6894ae89448

See more details on using hashes here.

Provenance

The following attestation bundles were made for llvm_demangle_fxti-1.0.0-cp36-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build.yml on FXTi/llvmdemangle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llvm_demangle_fxti-1.0.0-cp36-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for llvm_demangle_fxti-1.0.0-cp36-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9e58f31894e2315a75fa5d6d3b4da1d3ee134ad7fcaef403b59f56f58f8556e2
MD5 5d4de14d2d3acff53c0fc5c19362a93d
BLAKE2b-256 2046158e4ea8616902374065eda9fad9833d89b73203e8475bea9e4c28b546f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for llvm_demangle_fxti-1.0.0-cp36-abi3-macosx_11_0_arm64.whl:

Publisher: build.yml on FXTi/llvmdemangle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llvm_demangle_fxti-1.0.0-cp36-abi3-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for llvm_demangle_fxti-1.0.0-cp36-abi3-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 9deba1a28dd28450498a4ca3b0e89a51a4ae0573792297a4cef95d0289527f14
MD5 4d8128d762d57cb9087a349d7d9d32c8
BLAKE2b-256 500efa4b92d7f20497a0b63072a8017fff9f5d1a5630f0347f679404ceccfa6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for llvm_demangle_fxti-1.0.0-cp36-abi3-macosx_10_13_x86_64.whl:

Publisher: build.yml on FXTi/llvmdemangle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page