https://github.com/timescale/pg_ladybug
Static C code checker for postgres API
https://github.com/timescale/pg_ladybug
clang-tidy postgresql
Last synced: 3 months ago
JSON representation
Static C code checker for postgres API
- Host: GitHub
- URL: https://github.com/timescale/pg_ladybug
- Owner: timescale
- License: postgresql
- Created: 2025-03-24T10:09:22.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-04-21T06:15:41.000Z (9 months ago)
- Last Synced: 2025-10-05T12:59:29.858Z (3 months ago)
- Topics: clang-tidy, postgresql
- Language: C++
- Homepage:
- Size: 15.6 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## pg_ladybug
Static C code checker for postgres API
pg_ladybug checks C code using the postgres API for problematic patterns. It is implemented as a clang-tidy plugin.
pg_ladybug checks for the following patterns:
- passing large int into Bitmapset
- missing assignment for return value of Bitmapset functions
## Installation
```
apt-get install llvm-19 llvm-19-dev clang-19 libclang-19-dev clang-tidy-19
git clone https://github.com/timescale/pg_ladybug
cd pg_ladybug
cmake -S . -B build
make -C build
sudo make -C build install
```
## Requirements
- clang
- clang-tidy
- llvm
### Usage
Verify checks are present:
```
clang-tidy --load=/usr/local/lib/libPostgresCheck.so --checks='-*,postgres-*' --list-checks
Enabled checks:
postgres-bitmapset
```
```
% clang-tidy --load /usr/local/lib/libPostgresCheck.so --checks='-*,postgres-*' file.c
2 warnings and 2 errors generated.
Error while processing file.c.
file.c:224:30: error: potential wrong function argument. bms_add_member called with datatype Oid [postgres-bitmapset-member]
224 | uncompressed_attrs_found = bms_add_member(uncompressed_attrs_found, ladybug_test);
| ^
file.c:227:30: error: potential wrong function argument. bms_add_member called with datatype Oid [postgres-bitmapset-member]
227 | uncompressed_attrs_found = bms_add_member(uncompressed_attrs_found, ladybug_test);
| ^
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
```