Skip to content

clang-tidy: resolve performance-unnecessary-value-param - #796

Open
knoepfel wants to merge 3 commits into
Framework-R-D:mainfrom
knoepfel:performance-unnecessary-value-param
Open

clang-tidy: resolve performance-unnecessary-value-param#796
knoepfel wants to merge 3 commits into
Framework-R-D:mainfrom
knoepfel:performance-unnecessary-value-param

Conversation

@knoepfel

@knoepfel knoepfel commented Jul 31, 2026

Copy link
Copy Markdown
Member

Resolve performance-unnecessary-value-param clang-tidy warnings.

  • Code quality

    • Resolved performance-unnecessary-value-param clang-tidy warnings.
    • Replaced unnecessary by-value parameters with const& or std::string_view.
    • Added intentional-move suppressions and updated allowed clang-tidy types.
    • Moved owned objects where required to preserve transfer semantics.
  • API and framework

    • Updated graph, glue, registration, routing, storage, and plugin APIs.
    • Made applicable proxy creation and registration methods const.
    • Changed flush_gate::roll_up_child to accept counts by reference.
    • Updated Python wrappers to use const module and source pointers.
  • Correctness

    • Added assertions for committed flush counts before roll-up.
    • Updated data_cell_cursor to use non-owning pointers consistently.
    • Preserved validation, routing, registration, and error behavior.
  • Tests and documentation

    • Updated flush-gate tests for direct data_cell_counts values.
    • Recorded completion of the clang-tidy warning fix in docs/dev/clang-tidy-fixes-2026-04.md.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 64b3a81d-a440-4c09-95a7-f3d6a6aa0de7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR completes a clang-tidy cleanup across framework APIs, routing, plugin interfaces, model objects, and Python wrappers. It replaces unnecessary value parameters with references or std::string_view, adds intentional moves, and updates flush-gate tests.

Changes

Clang-tidy value-parameter cleanup

Layer / File(s) Summary
Registration APIs and string views
phlex/core/framework_graph.*, phlex/core/glue.*, phlex/core/graph_proxy.hpp, phlex/core/registration_api.*, phlex/module.hpp, phlex/source.hpp
Registration names now use std::string_view. Proxy creation is const-callable. Bound objects move into stored state.
Flush routing and count propagation
phlex/core/index_router.*, phlex/core/framework_graph.cpp, phlex/core/make_computational_edges.cpp, phlex/core/store_counters.*, phlex/model/flush_gate.*, test/flush_gate_test.cpp
Flush maps, port maps, counters, and committed counts now use const references. Parent rollup validates committed counts before dereferencing them.
Ownership and callable interfaces
phlex/detail/plugin_macros.hpp, phlex/app/load_module.cpp, phlex/driver.hpp, phlex/metaprogramming/delegate.hpp, phlex/model/*, plugins/layer_generator.*, .clang-tidy, docs/dev/clang-tidy-fixes-2026-04.md
Plugin and driver parameters use references. Delegate dispatch uses unified callable handling. Cursor storage uses non-owning pointers. Clang-tidy configuration and tracking documentation are updated.
Const Python wrappers
plugins/python/src/*
Module and source wrappers accept const references and preserve const Python object pointers. Converter registration moves the input selector.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: greenc-fnal

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.63% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the pull request's main change: resolving performance-unnecessary-value-param clang-tidy warnings.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@phlex/core/graph_proxy.hpp`:
- Around line 99-100: Make both the declaration and definition of
graph_proxy::output const, matching the other registration methods and allowing
calls through const graph_proxy<T> instances while preserving its existing
create_glue()-based behavior.

In `@phlex/detail/plugin_macros.hpp`:
- Around line 16-19: The plugin registration macros must preserve the exported
create_module/create_driver ABI by declaring proxy parameters by value, while
passing those parameters by const reference only when invoking the generated
implementation. Update PHLEX_DETAIL_REGISTER_PLUGIN and
PHLEX_DETAIL_REGISTER_DRIVER_PLUGIN accordingly, keeping the
PHLEX_DETAIL_CREATE_2ARGS implementation signature and loader-compatible
exported symbols consistent.

In `@plugins/python/src/modulewrap.cpp`:
- Around line 68-89: The wrappers wrap_module() and wrap_source() currently
expose const PyObject pointers at the Python C API boundary. Change both return
types and their local PyObject wrapper variables to mutable PyObject* while
keeping ph_module and ph_source members const, so callers such as
pymodule_register_providers(), PyObject_CallFunctionObjArgs(), and
PyObject_TypeCheck() receive the expected type.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7993b146-d93a-4ca9-b8b5-b2b1ce13eb4e

📥 Commits

Reviewing files that changed from the base of the PR and between 8f1dc63 and 090f738.

📒 Files selected for processing (33)
  • .clang-tidy
  • docs/dev/clang-tidy-fixes-2026-04.md
  • form/storage/storage_associative_write_container.cpp
  • phlex/app/load_module.cpp
  • phlex/core/framework_graph.cpp
  • phlex/core/framework_graph.hpp
  • phlex/core/glue.cpp
  • phlex/core/glue.hpp
  • phlex/core/graph_proxy.hpp
  • phlex/core/index_router.cpp
  • phlex/core/index_router.hpp
  • phlex/core/make_computational_edges.cpp
  • phlex/core/registration_api.cpp
  • phlex/core/registration_api.hpp
  • phlex/core/store_counters.cpp
  • phlex/core/store_counters.hpp
  • phlex/detail/plugin_macros.hpp
  • phlex/driver.hpp
  • phlex/metaprogramming/delegate.hpp
  • phlex/model/data_layer_hierarchy.cpp
  • phlex/model/data_layer_hierarchy.hpp
  • phlex/model/fixed_hierarchy.cpp
  • phlex/model/fixed_hierarchy.hpp
  • phlex/model/flush_gate.cpp
  • phlex/model/flush_gate.hpp
  • phlex/module.hpp
  • phlex/source.hpp
  • plugins/layer_generator.cpp
  • plugins/layer_generator.hpp
  • plugins/python/src/modulewrap.cpp
  • plugins/python/src/pymodule.cpp
  • plugins/python/src/wrap.hpp
  • test/flush_gate_test.cpp
📜 Review details
🧰 Additional context used
📓 Path-based instructions (5)
**/*.md

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.md: All Markdown files must follow markdownlint rule MD012: no multiple consecutive blank lines (never more than one blank line in a row)
All Markdown files must follow markdownlint rule MD022: headings must be surrounded by exactly one blank line before and after
All Markdown files must follow markdownlint rule MD031: fenced code blocks must be surrounded by exactly one blank line before and after
All Markdown files must follow markdownlint rule MD032: lists must be surrounded by exactly one blank line before and after (including after headings and code blocks)
All Markdown files must follow markdownlint rule MD034: no bare URLs (use markdown link syntax like [text](destination) instead of plain URLs)
All Markdown files must follow markdownlint rule MD036: use # headings for titles, not Bold:
All Markdown files must follow markdownlint rule MD040: always specify code block language (for example, use 'bash', 'python', '```text', etc.)

**/*.md: Do not use multiple consecutive blank lines in Markdown (MD012)
Surround Markdown headings with exactly one blank line (MD022)
Surround Markdown fenced code blocks with exactly one blank line (MD031)
Surround Markdown lists with exactly one blank line (MD032)
Do not use bare URLs in Markdown; use [text](url) syntax instead (MD034)
Use # headings in Markdown, not **Bold** for section titles (MD036)
Always specify language on fenced code blocks in Markdown (MD040)

Files:

  • docs/dev/clang-tidy-fixes-2026-04.md
**/*.{cpp,cc,cxx,h,hpp}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{cpp,cc,cxx,h,hpp}: Use clang-format tool for all C++ code formatting (VS Code auto-formats on save); configuration defined in .clang-format with 100-character line limit and 2-space indentation
Follow clang-tidy recommendations defined in .clang-tidy

Files:

  • phlex/core/store_counters.hpp
  • form/storage/storage_associative_write_container.cpp
  • phlex/core/store_counters.cpp
  • phlex/core/make_computational_edges.cpp
  • plugins/layer_generator.hpp
  • plugins/python/src/wrap.hpp
  • phlex/driver.hpp
  • plugins/layer_generator.cpp
  • phlex/core/glue.cpp
  • phlex/model/flush_gate.cpp
  • phlex/core/index_router.hpp
  • plugins/python/src/modulewrap.cpp
  • phlex/detail/plugin_macros.hpp
  • phlex/app/load_module.cpp
  • phlex/core/framework_graph.cpp
  • plugins/python/src/pymodule.cpp
  • phlex/model/fixed_hierarchy.cpp
  • test/flush_gate_test.cpp
  • phlex/model/fixed_hierarchy.hpp
  • phlex/core/registration_api.cpp
  • phlex/module.hpp
  • phlex/model/data_layer_hierarchy.hpp
  • phlex/model/data_layer_hierarchy.cpp
  • phlex/core/graph_proxy.hpp
  • phlex/metaprogramming/delegate.hpp
  • phlex/core/index_router.cpp
  • phlex/source.hpp
  • phlex/core/framework_graph.hpp
  • phlex/core/glue.hpp
  • phlex/model/flush_gate.hpp
  • phlex/core/registration_api.hpp
**/*.{hpp,cpp}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{hpp,cpp}: Use .hpp for header files, .cpp for implementation, and *_test.cpp for test files in C++
Enforce 100-character line limit and 2-space indentation in C++ code via .clang-format
Use QualifierAlignment: Right (east-const) style: int const x not const int x in C++
Use PointerAlignment: Left in C++ (pointer * attached to type, not variable name)
All C++ identifiers must use lower_case naming: namespaces, classes, structs, enums, functions, variables, parameters, members, and constants
Exception to C++ naming: template parameters use CamelCase
Exception to C++ naming: macros use UPPER_CASE
Private, protected, and constant members in C++ must have a trailing underscore (_), no trailing underscore on anything else
Use enum class preferred over plain enum in C++
Use std::shared_ptr for shared ownership, std::unique_ptr for exclusive ownership, raw pointers for non-owning references only in C++
Use functors with agent-noun pattern: ModelEvaluator evaluate_model(...) in C++
Apply .clang-tidy checks for bugprone, cert, clang-analyzer, concurrency, cppcoreguidelines, misc, modernize, performance, portability, and readability as defined in the .clang-tidy configuration file
Use phlex:: namespace for core code, phlex::experimental:: for experimental features in C++

Files:

  • phlex/core/store_counters.hpp
  • form/storage/storage_associative_write_container.cpp
  • phlex/core/store_counters.cpp
  • phlex/core/make_computational_edges.cpp
  • plugins/layer_generator.hpp
  • plugins/python/src/wrap.hpp
  • phlex/driver.hpp
  • plugins/layer_generator.cpp
  • phlex/core/glue.cpp
  • phlex/model/flush_gate.cpp
  • phlex/core/index_router.hpp
  • plugins/python/src/modulewrap.cpp
  • phlex/detail/plugin_macros.hpp
  • phlex/app/load_module.cpp
  • phlex/core/framework_graph.cpp
  • plugins/python/src/pymodule.cpp
  • phlex/model/fixed_hierarchy.cpp
  • test/flush_gate_test.cpp
  • phlex/model/fixed_hierarchy.hpp
  • phlex/core/registration_api.cpp
  • phlex/module.hpp
  • phlex/model/data_layer_hierarchy.hpp
  • phlex/model/data_layer_hierarchy.cpp
  • phlex/core/graph_proxy.hpp
  • phlex/metaprogramming/delegate.hpp
  • phlex/core/index_router.cpp
  • phlex/source.hpp
  • phlex/core/framework_graph.hpp
  • phlex/core/glue.hpp
  • phlex/model/flush_gate.hpp
  • phlex/core/registration_api.hpp
**/*.hpp

📄 CodeRabbit inference engine (AGENTS.md)

Avoid boolean parameters in C++ interfaces; prefer enumerations instead

Files:

  • phlex/core/store_counters.hpp
  • plugins/layer_generator.hpp
  • plugins/python/src/wrap.hpp
  • phlex/driver.hpp
  • phlex/core/index_router.hpp
  • phlex/detail/plugin_macros.hpp
  • phlex/model/fixed_hierarchy.hpp
  • phlex/module.hpp
  • phlex/model/data_layer_hierarchy.hpp
  • phlex/core/graph_proxy.hpp
  • phlex/metaprogramming/delegate.hpp
  • phlex/source.hpp
  • phlex/core/framework_graph.hpp
  • phlex/core/glue.hpp
  • phlex/model/flush_gate.hpp
  • phlex/core/registration_api.hpp
plugins/python/**/*.cpp

📄 CodeRabbit inference engine (AGENTS.md)

plugins/python/**/*.cpp: Use std::runtime_error for C++ runtime failures; propagate Python exceptions via PyErr_SetString/PyErr_Format; return nullptr on error; call PyErr_Clear() when recovering in Python/C++ integration
Use manual Py_INCREF/Py_DECREF for reference counting and PyGILRAII RAII wrapper for GIL management in C++ code that interacts with Python
For GC-tracked Python types in C++: use Py_TPFLAGS_HAVE_GC, implement tp_traverse and tp_clear, call PyObject_GC_UnTrack before deallocation

Files:

  • plugins/python/src/modulewrap.cpp
  • plugins/python/src/pymodule.cpp
🪛 Cppcheck (2.21.0)
phlex/core/glue.cpp

[style] 9-9: The function 'verify_name' is never used.

(unusedFunction)

plugins/python/src/modulewrap.cpp

[style] 68-68: The function 'wrap_module' is never used.

(unusedFunction)


[style] 84-84: The function 'wrap_source' is never used.

(unusedFunction)

🔇 Additional comments (36)
plugins/python/src/modulewrap.cpp (2)

758-758: LGTM!


64-65: 🎯 Functional Correctness

Const-qualified proxy storage is already safe.

transform(...) and provide(...) are const-qualified, so the const pointers can dereference them without compile failures.

phlex/core/framework_graph.hpp (1)

31-31: LGTM!

Also applies to: 60-64, 81-84, 92-143, 192-194

phlex/core/glue.cpp (1)

6-24: LGTM!

phlex/core/glue.hpp (3)

18-18: LGTM!

Also applies to: 29-29


175-183: LGTM! add_source correctly materializes an owning std::string{name} before it goes into nodes_.sources or the error message, so no dangling-view risk here.


56-173: 🩺 Stability & Availability

No change needed for name lifetime.

registration_api, fold_api, provider_api, unfold_api, and output all convert std::string_view name into phlex::experimental::algorithm_name before storing it. algorithm_name owns its name components, so these views do not outlive the caller.

phlex/core/graph_proxy.hpp (1)

16-16: LGTM!

Also applies to: 51-98, 102-115, 138-205, 211-233

phlex/module.hpp (1)

24-29: LGTM!

phlex/source.hpp (1)

40-45: LGTM!

phlex/core/store_counters.cpp (1)

12-25: LGTM!

phlex/core/store_counters.hpp (1)

20-20: LGTM!

phlex/model/flush_gate.cpp (1)

43-49: LGTM!

phlex/core/registration_api.hpp (1)

19-19: LGTM!

Also applies to: 41-48, 62-62, 105-112, 122-129, 150-163, 189-189, 198-198, 266-266, 276-276, 332-332

phlex/core/registration_api.cpp (1)

7-11: LGTM!

Also applies to: 21-21

phlex/core/framework_graph.cpp (1)

46-46: LGTM!

Also applies to: 85-85, 216-222, 251-251

phlex/core/index_router.cpp (1)

92-93: LGTM!

Also applies to: 126-126, 150-153, 193-193, 324-324, 416-418

phlex/core/index_router.hpp (1)

57-57: LGTM!

Also applies to: 72-73, 100-100

phlex/core/make_computational_edges.cpp (1)

42-42: LGTM!

Also applies to: 71-71, 205-208

phlex/model/flush_gate.hpp (1)

69-69: LGTM!

test/flush_gate_test.cpp (1)

28-28: LGTM!

Also applies to: 71-73, 228-234

form/storage/storage_associative_write_container.cpp (1)

5-6: LGTM!

Also applies to: 31-31

phlex/app/load_module.cpp (1)

53-53: LGTM!

phlex/detail/plugin_macros.hpp (1)

44-47: LGTM!

Also applies to: 67-72

phlex/metaprogramming/delegate.hpp (1)

8-29: LGTM!

Also applies to: 40-51

phlex/model/data_layer_hierarchy.cpp (1)

78-78: LGTM!

phlex/model/data_layer_hierarchy.hpp (1)

41-41: LGTM!

docs/dev/clang-tidy-fixes-2026-04.md (1)

153-154: LGTM!

phlex/driver.hpp (1)

139-139: LGTM!

plugins/layer_generator.cpp (1)

39-39: LGTM!

plugins/layer_generator.hpp (1)

66-66: LGTM!

phlex/model/fixed_hierarchy.cpp (3)

20-22: LGTM!


74-84: LGTM!


115-117: LGTM!

phlex/model/fixed_hierarchy.hpp (1)

38-41: LGTM!

.clang-tidy (1)

101-101: LGTM!

Comment thread phlex/core/graph_proxy.hpp Outdated
Comment thread phlex/detail/plugin_macros.hpp
Comment thread plugins/python/src/modulewrap.cpp Outdated
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.29630% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
phlex/model/fixed_hierarchy.cpp 25.00% 3 Missing ⚠️
@@            Coverage Diff             @@
##             main     #796      +/-   ##
==========================================
- Coverage   83.84%   83.83%   -0.01%     
==========================================
  Files         172      172              
  Lines        7230     7226       -4     
  Branches      850      850              
==========================================
- Hits         6062     6058       -4     
  Misses        885      885              
  Partials      283      283              
Flag Coverage Δ
scripts 80.09% <ø> (ø)
unittests 85.70% <96.29%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...rm/storage/storage_associative_write_container.cpp 100.00% <100.00%> (ø)
phlex/app/load_module.cpp 86.27% <100.00%> (ø)
phlex/core/framework_graph.cpp 96.63% <100.00%> (-0.03%) ⬇️
phlex/core/framework_graph.hpp 100.00% <100.00%> (ø)
phlex/core/glue.cpp 100.00% <ø> (ø)
phlex/core/glue.hpp 98.43% <100.00%> (ø)
phlex/core/graph_proxy.hpp 90.90% <100.00%> (-0.76%) ⬇️
phlex/core/index_router.cpp 92.77% <100.00%> (+0.04%) ⬆️
phlex/core/index_router.hpp 100.00% <ø> (ø)
phlex/core/make_computational_edges.cpp 100.00% <100.00%> (ø)
... and 18 more

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8f1dc63...1d1eb6c. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant