Skip to content

Conversation

@PengZheng
Copy link
Contributor

@PengZheng PengZheng commented Nov 3, 2025

Description

This pull request focuses on improving code clarity and consistency. The changes include:

  • Adding memory ownership annotations to improve code documentation and enable better static analysis.
  • Standardizing function declarations by explicitly including void in parameter lists for consistency.
  • Introducing the CELIX_HAS_ATTRIBUTE macro to check for attribute support.
  • Improved Formatting and Grammar: Fixed typos, improved clarity in comments, and ensured consistency in phrasing following CLion's suggestions.

Usage

Enable the following clang-tidy checks to see its effects:

  • clang-analyzer-unix.DynamicMemoryModeling
  • clang-analyzer-unix.Malloc
  • clang-analyzer-unix.MallocSizeof
  • clang-analyzer-unix.MismatchedDeallocator

Both vscode and Clion IDE have good integrations with clang-tidy.

Limitations

The first issue leads to lots of false-positives, which can fortunately be suppressed using NOLINT macros. I will try to fix both issues in the Clang upstream.

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.47%. Comparing base (6418698) to head (245a3a2).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #806      +/-   ##
==========================================
- Coverage   91.52%   91.47%   -0.06%     
==========================================
  Files         236      236              
  Lines       29561    28818     -743     
==========================================
- Hits        27057    26361     -696     
+ Misses       2504     2457      -47     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@PengZheng PengZheng changed the title Add memory annotations and standardize function declarations [WIP]Memory Ownership Annotations Nov 3, 2025
@PengZheng PengZheng requested a review from pnoltes November 3, 2025 06:25
Copy link
Contributor

@pnoltes pnoltes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice PR. I was not aware that this is possible and this looks like a good addition to make the code more readable and even more when using clang-tidy.

Should we also add clang-tidy to our CI?

For the usage of '(void)' for an explicit empty argument list, maybe this should also be added to our coding conventions documentation.

And ideally when to use 'CELIX_OWNERSHIP_RETURNS', '_TAKES' and ' _HOLDS' should also be documented.

@PengZheng
Copy link
Contributor Author

Should we also add clang-tidy to our CI?

Yes.

For the usage of '(void)' for an explicit empty argument list, maybe this should also be added to our coding conventions documentation.

And ideally when to use 'CELIX_OWNERSHIP_RETURNS', '_TAKES' and ' _HOLDS' should also be documented.

I am currently working on fixing the cleanup attributes modeling issue, and will follow the above suggestions once it's done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants