Repository navigation
Track callable and pointer flow through nested standard containers - #301
Conversation
PR Reviewer Guide 🔍(Review updated until commit 54a9b06)Here are some key observations to aid the review process:
✅ Resolved findingscrates/trace-parse/src/container_elements.rs:2814-2818Allocator copy from typed temporary
crates/trace-parse/src/container_elements.rs:758-760Pair key empty brace
crates/trace-parse/src/container_elements.rs:852-868Mixed entry list dropped For an entry model ( crates/trace-parse/src/container_elements.rs:3060-3070Question: extra entry-list reading In the CHANGELOG.md:28Literal Escape The new changelog entry has a literal crates/trace-parse/src/container_elements.rs:735-748Question: copy detection canonicalization
tests/fixtures/cpp_nested_containers/store.cpp:8Broken Fixture Source Line 8 contains a literal escape sequence instead of line breaks: |
DeepSeek review: Approved (
|
ArcsinX
left a comment
There was a problem hiding this comment.
Found several concrete issues across container_elements.rs, lower.rs, and the new fixture (in addition to the already-flagged literal \n\n on tests/fixtures/cpp_nested_containers/store.cpp:8 and the canonicalization question on copies_container):
- Single-element braced inner lists bypass inner-container validation in
list_element_conversions, andordinary_constructor_acceptsmisses canonical-prelude constructors and parameter compatibility. inserted_valueshas three separate validation bypasses (braced_allocator_argumentsinsingle_entry_viable, untypedcompound_literal_expressionunwrapping, and falling through to the non-bracedunwrap_braced_valuepath whenpreserve_braceschecks reject an entry), andstore_valueswrites non-container fallthrough values directly into the nested element cell.key_braced_acceptsmisclassifies pointer-to-template keys likestd::pair<int, int>*and missesstd::__1::pair/::std::pair.Elements::for_receiverhandlessubscript_expressionviaaccess(...).nested(...)but routes modeledAccesscalls like.at(i)/.front()/.back()to an isolated return-temp cell.lower_statement_localmisses reference type aliases when deciding whether a range-for variable aliases the nested container.
d9da267 to
16e5d7a
Compare
16e5d7a to
0cde965
Compare
ArcsinX
left a comment
There was a problem hiding this comment.
Re-reviewed 0cde965: the previously flagged issues have been addressed (including the CHANGELOG.md literal \n, store.cpp, and the nine prior review threads, which I have resolved), though the reference-alias fix only updated lower.rs and still drops flow in Elements::for_var.
Found several remaining issues in the updated code (detailed in the inline comments):
inner_container_viablerejects braced copies of named inner containers ({{inner}},{1, {inner}}) becauselist_initializationrejectscopies_container.typed_inner_bracesignores template arguments, andcopy_container_elementscopies the first element level before checking specialization compatibility.Elements::for_vardoes not unwrapTypeDesc::Ptrfor reference-type aliases recorded innested_container_owners.Elements::for_receiver("call_expression") missesmethod_is_from_ignored_macroand blocks unevaluatedat/front/backchains viaeffects_allowed.store_valuesallocates an unused temp and emits a deadContainerElementconstraint whenevernested.is_some().inserted_valuesdrops typedstd::paircompound literals (std::pair<K, V>{k, ...}).canonical_specialization_at/canonical_desc_atlackcanonical_declarations(ctx)defaults, can shift positions on partial default binding, and useDebugformatting for scalar fallback.key_braced_acceptsmisclassifiesconst intandvoid (*const)()keys as aggregates,ordinary_constructor_acceptscanonical-prelude fallback accepts arbitraryargc > 3, andrange_is_from_ignored_macromisses ignored[brackets and ignored accessor method macros.
There was a problem hiding this comment.
Automated DeepSeek review found no blocking concerns in 0cde965.
0cde965 to
d6ace6d
Compare
There was a problem hiding this comment.
Automated DeepSeek review found no blocking concerns in d6ace6d.
ArcsinX
left a comment
There was a problem hiding this comment.
Re-reviewed d6ace6d8: all 11 previous comments have been addressed and resolved. Found two remaining edge cases in container_elements.rs.
d6ace6d to
ac9a52c
Compare
There was a problem hiding this comment.
Automated DeepSeek review found no blocking concerns in ac9a52c.
ArcsinX
left a comment
There was a problem hiding this comment.
Re-reviewed ac9a52c: both previously open comments (effects_allowed checking method_is_from_ignored_macro and keeping std::pair compound literals out of the list_overload outer-list unwrap while unwrapping them per clause) are addressed, and I have resolved those two threads.
Found two remaining edge cases in crates/trace-parse/src/container_elements.rs (inline comments below).
ac9a52c to
4ef7374
Compare
There was a problem hiding this comment.
Automated DeepSeek review found no blocking concerns in 4ef7374.
ArcsinX
left a comment
There was a problem hiding this comment.
Re-reviewed 4ef7374: both previously open threads (unwrap_or(value) / missing key_braced_accepts on line 829, and removing the entry.is_some() single push in inserted_values) are addressed, and I have resolved both threads.
Found five remaining issues in crates/trace-parse/src/container_elements.rs (detailed in the inline comments below).
4ef7374 to
dec75f6
Compare
There was a problem hiding this comment.
Automated DeepSeek review found no blocking concerns in dec75f6.
ArcsinX
left a comment
There was a problem hiding this comment.
Re-reviewed dec75f6: all 5 previously open threads (trace_ir::split_instance in key_braced_accepts, compound_pair_brace + {} handling in list_element_conversions / lower_list_initializer, lower_operation in store_nested_braced, independent map-clause extraction + single-pair count guard in inserted_values, and has_subscript_base in lower_subscript_call) have been addressed and resolved.
Found 4 remaining issues in container_elements.rs and lower.rs (inline comments attached).
dec75f6 to
c7ccd23
Compare
There was a problem hiding this comment.
Automated DeepSeek review found no blocking concerns in c7ccd23.
ArcsinX
left a comment
There was a problem hiding this comment.
Re-reviewed c7ccd23: all 5 previously open threads (first_is_entry for {1, {{alpha}, {}}} / 3-level single-pair inserts, all_clauses_inner for position inserts, split_top_level / has_top_level in type_spelling_for, and without_leading_cv in canonical_specialization / compound_pair_brace / initializer_list_literal) have been addressed and resolved.
Found one remaining edge-case bug in the new first_is_entry guard in crates/trace-parse/src/container_elements.rs (inline comment attached).
c7ccd23 to
37f4780
Compare
b7d4e1c to
dd4eb96
Compare
ArcsinX
left a comment
There was a problem hiding this comment.
Re-reviewed dd4eb961. All 7 CI checks (check, coverage, check-macos, check-windows, and the three release build jobs) passed on this commit.
Resolved the 8 addressed ArcsinX review threads (canonical_specialization_at / class_template_defaults canonical prelude lookup, type_spelling_node dispatch, key_braced_accepts unbraced pair rejection, std::initializer_list<T>{...} opt-in check, const Callback function-pointer alias qualifier placement, inserted_values unconditional return after failed single_entry_viable, and all_clauses_inner ignored-macro filtering).
Three issues remain on dd4eb961 (plus PRRT_kwDOT_8HwM68wOj7, which stays open until lower.rs:23110 is fixed); details are noted inline.
There was a problem hiding this comment.
Automated DeepSeek review found no blocking concerns in dd4eb96. 1 data file(s) were left out of the review for a person to check.
dd4eb96 to
b8ec12d
Compare
ArcsinX
left a comment
There was a problem hiding this comment.
Re-reviewed b8ec12da (with CI/check, CI/check-windows, CI/coverage, and CI/build (aarch64-unknown-linux-gnu) passing; remaining CI jobs still in progress).
Resolved the 4 addressed ArcsinX threads (lower.rs:23110 top-level */& check via has_top_level, split_top_level + split_function_pointer_star for function-pointer aliases with pointer parameters, and pair_clause_key_matches in clause_is_entry).
Found two issues in the new pair_clause_key_matches logic in crates/trace-parse/src/container_elements.rs (inline comments attached).
There was a problem hiding this comment.
Automated DeepSeek review found no blocking concerns in b8ec12d. 1 data file(s) were left out of the review for a person to check.
b8ec12d to
bf57e6a
Compare
There was a problem hiding this comment.
Automated DeepSeek review found no blocking concerns in bf57e6a.
ArcsinX
left a comment
There was a problem hiding this comment.
Re-reviewed bf57e6ae (with all 7 CI/* checks passing: check, check-macos, check-windows, coverage, and the 3 build jobs).
Resolved the 2 addressed ArcsinX threads (pair_clause_key_matches replaced by pair_key_may_convert, and key compatibility now checked consistently in list_element_conversions and inserted_values).
Found two remaining key-validation issues in crates/trace-parse/src/container_elements.rs that can drop valid inner container values and leak key callbacks into the map's mapped cell (inline comments attached).
bf57e6a to
47ae01f
Compare
There was a problem hiding this comment.
Automated DeepSeek review found no blocking concerns in 47ae01f.
devnullexile
left a comment
There was a problem hiding this comment.
All three earlier comments are resolved in 47ae01f:
canonical_alias_spelling_atnow strips leading cv-qualifiers before alias lookup.key_braced_acceptsnow accepts{}(and single-clause copy-list-init) forstd::pairkeys.inserted_valuesnow unwrapspair_bracefor direct typed-pair inserts on non-nested maps too.
Found one new edge-case bug in type_spelling_for when cv-qualifying an already cv-qualified function-pointer alias.
| if pointer.take_prefix(tail).is_empty() { | ||
| qualifiers = TypeQualifiers::default(); | ||
| format!("{pointee}*{}", pointer.spelling()) | ||
| } else if alias.contains('(') | ||
| && (!after.is_empty() || !qualifiers.spelling().is_empty()) | ||
| { | ||
| } else if has_top_level(alias, '(') && !qualifiers.spelling().is_empty() { | ||
| let cv = qualifiers.spelling(); | ||
| qualifiers = TypeQualifiers::default(); | ||
| format!("{pointee}*{cv}{tail}") |
There was a problem hiding this comment.
[P2] format!("{pointee}*{cv}{tail}") prepends cv directly onto the unstripped tail instead of using the merged pointer qualifiers and the remainder returned by pointer.take_prefix(tail). When qualifying an already cv-qualified function-pointer alias (e.g. using CCallback = void (*const)(); with const CCallback or volatile CCallback), tail starts with const)(), so this produces void (*constconst)() or void (*volatileconst)() (breaking canonical specialization equality with CCallback).
| if pointer.take_prefix(tail).is_empty() { | |
| qualifiers = TypeQualifiers::default(); | |
| format!("{pointee}*{}", pointer.spelling()) | |
| } else if alias.contains('(') | |
| && (!after.is_empty() || !qualifiers.spelling().is_empty()) | |
| { | |
| } else if has_top_level(alias, '(') && !qualifiers.spelling().is_empty() { | |
| let cv = qualifiers.spelling(); | |
| qualifiers = TypeQualifiers::default(); | |
| format!("{pointee}*{cv}{tail}") | |
| let remainder = pointer.take_prefix(tail); | |
| if remainder.is_empty() { | |
| qualifiers = TypeQualifiers::default(); | |
| format!("{pointee}*{}", pointer.spelling()) | |
| } else if has_top_level(alias, '(') && !qualifiers.spelling().is_empty() { | |
| qualifiers = TypeQualifiers::default(); | |
| format!("{pointee}*{} {remainder}", pointer.spelling()) |
devnullexile
left a comment
There was a problem hiding this comment.
LGTM — the remaining P2 on cv-qualified function-pointer aliases is non-blocking.
47ae01f to
81147f9
Compare
There was a problem hiding this comment.
Automated DeepSeek review found no blocking concerns in 81147f9.
devnullexile
left a comment
There was a problem hiding this comment.
The earlier findings on cv-qualified map key aliases, empty std::pair keys, and direct typed-pair inserts are addressed. This revision also fixes the duplicate and mixed cv qualifiers on single-level function-pointer aliases from my last review. I found one new regression in how the merge handles a pointer to a function pointer.
| { | ||
| } else if has_top_level(alias, '(') && !qualifiers.spelling().is_empty() { | ||
| qualifiers = TypeQualifiers::default(); | ||
| format!("{pointee}*{} {remainder}", pointer.spelling()) |
There was a problem hiding this comment.
[P2] Preserve cv qualifiers on the outer pointer
With using Slot = void (*const *)(int *); using ConstSlot = const Slot;, split_function_pointer_star picks the inner *. This merge absorbs the new const into the inner pointer’s existing const, so both aliases now have the same spelling. ConstSlot should spell void (*const *const)(int *).
That collision lets nested containers copy callback flow across distinct specializations. I reproduced a new indirect edge to alpha when a modeled Box<ConstSlot, Callback> was constructed from Box<Slot, Callback> by a converting constructor that leaves the destination callback null. Apply the alias qualifiers to the outer pointer in the declarator.
81147f9 to
c7acb88
Compare
There was a problem hiding this comment.
Automated DeepSeek review found no blocking concerns in c7acb88.
There was a problem hiding this comment.
This revision resolves my finding about applying cv qualifiers to the outer pointer in void (*const *)(int *). I also verified the earlier fixes for cv-qualified map key aliases, empty std::pair keys, direct typed-pair inserts, and duplicate or mixed cv qualifiers on single-level function-pointer aliases. Two new declarator regressions are detailed inline.
| } | ||
| '*' if angle == 0 && paren == 1 => { | ||
| let prefix = spelling[group_start..index].trim(); | ||
| if star.is_some() || prefix.is_empty() || prefix.ends_with("::") { |
There was a problem hiding this comment.
[P2] Skip multiplication inside array bounds when finding the pointer declarator
using Slots = void (*[2 * 3])(int *);
using ConstSlots = const Slots;
using Written = void (*const[2 * 3])(int *);Clang treats ConstSlots and Written as the same type. Once this scan has seen the pointer star, it also accepts the multiplication in [2 * 3], so alias expansion produces void(*[2*const 3])(int*). In the new Box test setup, using ConstSlots for the source and Written for the nested destination drops the stored callback's indirect edge on this commit. The edge was present on 81147f9. Track square-bracket nesting when selecting the declarator star.
[P2] Preserve type identity when cv is applied to a reference alias
using SlotRef = void (*const *&)(int *);
using ConstSlotRef = const SlotRef;C++ ignores the added const on a reference alias. After the switch to the last pointer star, this spells ConstSlotRef as void(*const*const&)(int*), qualifying the pointer that SlotRef refers to. In the new Box test setup, storing a callback in Box<ConstSlotRef, Callback> and copying it into the nested Box<SlotRef, Callback> resolves the callback on 81147f9 and drops the edge on this commit. Check for a reference declarator before applying the alias's cv qualifiers.
c7acb88 to
2465680
Compare
There was a problem hiding this comment.
Automated DeepSeek review found no blocking concerns in 2465680.
devnullexile
left a comment
There was a problem hiding this comment.
This revision resolves my finding about skipping multiplication inside array bounds (e.g., void (*[2 * 3])(int *)) in split_top_level and split_function_pointer_star, and the changes since c7acb88 introduce no new issues.
The second finding from my previous comment—preserving type identity when cv qualifiers are applied to a reference alias such as void (*const *&)(int *)—remains unresolved in 2465680.
Model inner containers with an element summary keyed by the outer owner and canonical inner specialization. Carry elements through copies, move casts, allocator-extended construction, chained accesses, and nested ranges. Bound alias spelling growth and reuse resolved access prefixes. Check map key compatibility during entry recognition and extraction. Accept viable conversions while keeping key-only callbacks out of the mapped cell. Preserve callback parameter type identity and honor macro provenance on explicit subscript operators. Regression tests cover callback flow, key isolation, and deep aliases. All 44 canonical HiView and Camera checks pass at one and eight jobs with identical analysis rows across job counts.
2465680 to
54a9b06
Compare
There was a problem hiding this comment.
Automated DeepSeek review found no blocking concerns in 54a9b06.
devnullexile
left a comment
There was a problem hiding this comment.
This revision resolves the remaining finding from my previous review on preserving type identity when cv qualifiers are applied to a reference alias (such as void (*const *&)(int *)), including both lvalue/rvalue and local reference aliases. All of my earlier comments are now resolved, and the changes since 2465680 introduce no new issues.
Model a container element that is itself a modeled container with a nested owner keyed by the parent owner and a canonical inner specialization identity. Named inner containers copy their element cell and matching descendant cells into the nested chain; omitted template defaults are filled before comparison, so aliases and explicit default allocators share both copy descent and nested cell keys. By-value range variables get their own seeded cells while explicit references bind the source. Nested owners report their root variable so header file-static initializers replay through merge, and nested pair members are seeded and copied through their modeled member cells. A container-typed call result uses its return temp rather than writing a container value into the inner element cell; call-return element summaries remain a follow-up.
Validate every bracket in a subscript chain against the configured access model. Gate braced inner lists on the inner initializer_list opt-in and standalone constructor and allocator checks, reuse inner constructor viability for outer list validation, keep an ordinary inner constructor viable, and preserve the allocator reading when the one-argument reading is not viable. Detect braced copies by canonical type before a list reading, route typed braced temporaries and named copies through the same copy-or-list path, and accept matching typed mapped temporaries in entry lists. Single-pair map readings preserve mapped braces and allocator clauses only when the key clause is compatible, including allowed implicit class-key conversions; entry-list readings require every clause to fit a full entry, a known pair key to have both clauses, and a non-braced mapped value to be the inner container. Key inference is limited to recognized map layouts. Insertion effects require an emitted, unfiltered call site, and ignored macros filter typed, named and field-nested braced sources before copying.
Honor ignored field macros beneath range and nested subscripts, keep unevaluated chained subscript sites distinct, and validate the fixture with an explicit initializer_list, allocator-qualified inner vectors, an allocator-capable initializer-list constructor, a count/value inner constructor, and a usable iterator. Exercise vector-of-vector, map-of-vector, vector-of-map, three-level, alias, explicit-allocator and mixed-allocator copies, shared header statics, named and braced pair inserts, typed mapped entries, class/callback/pair keys, custom entry models, model opt-outs, explicit and by-value ranges, pointer elements, and unrelated-container isolation in tests/fixtures/cpp_nested_containers.
Recapture the canonical container-cell probes: HiView 35 -> 39 and Camera 8 -> 10 for the new outer and nested cells, with every other global and probe unchanged. Map iteration, structured bindings, and chained find-second lookups remain documented follow-ups.
Verified with cargo test --workspace, cargo clippy --workspace --all-targets -- -D warnings, cargo fmt --check, clang syntax-only checks of the fixture, the canonical HiView and Camera debug checks (44/44), and identical --jobs 1 and --jobs 8 exports.