Conversation
Signed-off-by: Elazar Gershuni <elazarg@gmail.com>
📝 WalkthroughWalkthroughThe Changes
Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/ir/unmarshal.hpp`:
- Line 5: unmarshal.hpp currently exposes the C++23 header <expected> to public
APIs (via ebpf_verifier.hpp); remove the direct public dependency by introducing
a small compatibility alias (e.g., expected_compat.hpp) that conditionally uses
std::expected when __cplusplus >= 202302L and falls back to a header-only
tl::expected (or a project-local Expected<T,E>) for C++20, then replace `#include`
<expected> in unmarshal.hpp with `#include` "expected_compat.hpp" and update any
public function signatures that reference std::expected to use the compatibility
alias (e.g., Expected<T,E>) so C++20 consumers can include the installed
headers.
🪄 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: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 3fba3bbb-f72d-4130-abd2-35062a4492d4
📒 Files selected for processing (10)
src/ir/unmarshal.cppsrc/ir/unmarshal.hppsrc/main.cppsrc/test/ebpf_yaml.cppsrc/test/test_elf_loader.cppsrc/test/test_failure_slice.cppsrc/test/test_marshal.cppsrc/test/test_print.cppsrc/test/test_verify.hppsrc/test/test_verify_multithreading.cpp
| // SPDX-License-Identifier: MIT | ||
| #pragma once | ||
|
|
||
| #include <expected> |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== C++ standard configuration =="
rg -n --iglob 'CMakeLists.txt' --iglob '*.cmake' 'CMAKE_CXX_STANDARD|CXX_STANDARD|cxx_std_'
echo
echo "== expected feature usage / compatibility shims =="
rg -n 'std::expected|<expected>|tl::expected|expected.hpp|std::unexpected'Repository: vbpf/prevail
Length of output: 1136
🏁 Script executed:
cd examples/using_installed_package && cat -n CMakeLists.txtRepository: vbpf/prevail
Length of output: 727
🏁 Script executed:
grep -r "unmarshal\|ir" examples/using_installed_package/ --include="*.cpp" --include="*.hpp" --include="*.h"Repository: vbpf/prevail
Length of output: 173
🏁 Script executed:
cat -n examples/using_installed_package/main.cppRepository: vbpf/prevail
Length of output: 1221
🏁 Script executed:
cat -n src/prevail.hpp | head -50Repository: vbpf/prevail
Length of output: 103
🏁 Script executed:
grep -n "unmarshal" src/prevail.hppRepository: vbpf/prevail
Length of output: 104
🏁 Script executed:
find . -name "prevail.hpp" -type fRepository: vbpf/prevail
Length of output: 38
🏁 Script executed:
git ls-files | grep -E "\.hpp$" | head -20Repository: vbpf/prevail
Length of output: 535
🏁 Script executed:
git ls-files | grep -i "prevail" | grep -E "\.(hpp|h)$"Repository: vbpf/prevail
Length of output: 38
🏁 Script executed:
rg -n "unmarshal" --iglob "*.hpp" --iglob "*.h" src/Repository: vbpf/prevail
Length of output: 977
🏁 Script executed:
cat -n src/ebpf_verifier.hppRepository: vbpf/prevail
Length of output: 372
🏁 Script executed:
grep -rn "public\|install" CMakeLists.txt | head -30Repository: vbpf/prevail
Length of output: 577
🏁 Script executed:
cat -n CMakeLists.txt | sed -n '240,265p'Repository: vbpf/prevail
Length of output: 1084
🏁 Script executed:
cat -n src/ebpf_verifier.hppRepository: vbpf/prevail
Length of output: 372
C++23 features in public headers break C++20 consumer builds.
The project is configured for C++23 (CMakeLists.txt:33), but unmarshal.hpp exposes std::expected (C++23 only) in the public API via ebpf_verifier.hpp. This prevents C++20-configured consumers like examples/using_installed_package from using the installed library headers. Either restrict C++23 features to implementation-only files, provide a C++20-compatible compatibility layer, or document this as a breaking requirement for library consumers.
🧰 Tools
🪛 Clang (14.0.6)
[error] 5-5: 'expected' file not found
(clang-diagnostic-error)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/ir/unmarshal.hpp` at line 5, unmarshal.hpp currently exposes the C++23
header <expected> to public APIs (via ebpf_verifier.hpp); remove the direct
public dependency by introducing a small compatibility alias (e.g.,
expected_compat.hpp) that conditionally uses std::expected when __cplusplus >=
202302L and falls back to a header-only tl::expected (or a project-local
Expected<T,E>) for C++20, then replace `#include` <expected> in unmarshal.hpp with
`#include` "expected_compat.hpp" and update any public function signatures that
reference std::expected to use the compatibility alias (e.g., Expected<T,E>) so
C++20 consumers can include the installed headers.
There was a problem hiding this comment.
@Alan-Jowett do we need unmarshal.hpp as part of the API?
There was a problem hiding this comment.
Yes, we currently call prevail::unmarshal() directly in 4 places across verifier_service.cpp and Verifier.cpp, and ebpf_verifier.hpp includes unmarshal.hpp. However, in all cases we immediately pass the InstructionSeq to the next step (Program::from_sequence, print, or analyze) — we never use InstructionSeq on its own.
So if prevail provided higher-level APIs that accept RawProgram directly (e.g., Program::from_raw(RawProgram, notes, options) that internalizes the unmarshal step, and a disassemble-to-stream function), we could stop depending on unmarshal.hpp and InstructionSeq entirely. That would also resolve the C++23 public API concern since std::expected would stay internal.
Our project currently builds with C++20, so exposing std::expected in public headers would require us to bump our standard.
There was a problem hiding this comment.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
There was a problem hiding this comment.
Something like this?
https://github.com/vbpf/prevail/pull/1074/changes#diff-6714101bca0d9472baf09f9c8eaf5708d12f6fa8f5dc3160e52f319eb2e32310
/// Build a Program directly from a raw (ELF-bytecode) representation.
/// On failure returns std::nullopt and appends the error message to `notes`
/// (the same vector that collects unmarshal warnings).
static std::optional<Program> from_raw(const RawProgram& raw_prog, std::vector<std::vector<std::string>>& notes,
const ebpf_verifier_options_t& options);/// Write a textual disassembly of `raw_prog` to `out`. On failure writes the
/// error message to `out` and returns false.
bool disassemble(const RawProgram& raw_prog, const ebpf_verifier_options_t& options, std::ostream& out,
const std::optional<Label>& label_to_print = {}, bool print_line_info = false);Signed-off-by: Elazar Gershuni <elazarg@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/printing.cpp`:
- Around line 730-739: The error message in disassemble (function disassemble,
variable inst_seq) uses the preposition "at" which misleadingly implies a
location; update the error output to use "unmarshaling error: " (colon) and
include inst_seq.error() so the full error text is preserved—i.e., change the
out << "unmarshaling error at " << inst_seq.error(); to use a clearer separator
like ":" while keeping the rest of the logic intact.
🪄 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: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: fb4fdb84-0628-45ff-8a99-099c6e380036
📒 Files selected for processing (14)
CMakeLists.txtdocs/architecture.mdsrc/ebpf_verifier.hppsrc/ir/cfg_builder.cppsrc/ir/program.hppsrc/ir/syntax.hppsrc/main.cppsrc/printing.cppsrc/test/ebpf_yaml.cppsrc/test/run_yaml.cppsrc/test/test_failure_slice.cppsrc/test/test_marshal.cppsrc/test/test_verify.hppsrc/test/test_yaml.cpp
💤 Files with no reviewable changes (2)
- src/test/test_yaml.cpp
- src/ebpf_verifier.hpp
Part of #1027: replace
std::variant<InstructionSeq, std::string>withstd::expected<InstructionSeq, std::string>.