Glud
Overview
Glud is an abstraction on the libclang library that make matching fragments of the Clang AST simple and Pythonic, in the same way that libclangastmatchers does for the C++ Clang API.
Examples
On the code snippet
// input.cpp
namespace X {
class Y {};
}
class Y {};
You could match a class named X in the namespace Y with the matcher:
from glud import *
m = cxxRecordDecl(
hasName('Y'),
hasAncestor(namespaceDecl(hasName('X'))))
tu = parse('input.cpp')
matches = walk(m, tu.cursor)
Prerequisites
Install a recent version of Clang and the python libclang bindings. On Ubuntu Trusty, you can install pre-built binaries from the LLVM apt repositories:
wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add -
echo "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.8 main" | sudo tee -a /etc/apt/sources.list
sudo apt-get update -qq
sudo apt-get install -y python-clang-3.8 libclang1-3.8
To run glud, you’ll need to make sure that libclang.so is on your loader path.
export LD_LIBRARY_PATH=/usr/lib/llvm-3.8/lib
Installing
You can install the latest stable version from PyPI
$ pip install glud
Or, you can install the latest development version from GitHub
$ pip install git+git://github.com/AndrewWalker/glud.git
Acknowledgements
This project is in no way affiliated with the LLVM Team or the University of Illinois at Urbana-Champaign.
Contributing
If you experience problems with glud, log them on GitHub. If you want to contribute code, please fork the code and submit a pull request.
Metadata
Release files for glud 0.3.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| glud-0.3.3.tar.gz | 8.0 kB | Without provenance | Details for glud-0.3.3.tar.gz |
Release files / glud-0.3.3.tar.gz
| Download URL | glud-0.3.3.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7e6a7ab7a328d2c90c7b87ad5076b44df7affd38ca2a6667a5cf7f89b22c7915
|
|
BLAKE2b-256 checksum How to use checksums |
27903d98276c41c0f8101ecab2c514b8b2ff5234bb0e639bf2d0d8f13534fb01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for glud 0.3.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.