Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Several summaries lose flow through modifiable return references and assignment results.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds contained-value flow modeling for BDE nullable and variant wrappers.
Changes:
- Adds type-aware assignment and emplacement summaries.
- Models accessors, copying, moving, and reference writes.
- Adds data-flow tests and release documentation.
File summaries
| File | Description |
|---|---|
cpp/ql/lib/semmle/code/cpp/models/Models.qll |
Registers the new implementation. |
cpp/ql/lib/semmle/code/cpp/models/implementations/BdlbValues.qll |
Implements assignment and emplacement summaries. |
cpp/ql/lib/ext/bdlb.values.model.yml |
Declares accessor and copy/move models. |
cpp/ql/lib/change-notes/2026-09-14-bdlb-values.md |
Documents the analysis improvement. |
cpp/ql/test/library-tests/dataflow/bdlb-values/wrappers.h |
Defines reduced BDE test APIs. |
cpp/ql/test/library-tests/dataflow/bdlb-values/test.cpp |
Tests wrapper data flow. |
cpp/ql/test/library-tests/dataflow/bdlb-values/emplacement.cpp |
Tests constructor-body analysis. |
cpp/ql/test/library-tests/dataflow/bdlb-values/flow.ql |
Configures the flow test. |
cpp/ql/test/library-tests/dataflow/bdlb-values/flow.expected |
Records expected results. |
cpp/ql/test/library-tests/dataflow/external-models/validatemodels.expected |
Updates model-validation expectations. |
Review details
Suppressed comments (4)
cpp/ql/lib/semmle/code/cpp/models/implementations/BdlbValues.qll:85
- Both emplacement APIs return a modifiable reference to the newly stored value, but this summary has no return-to-wrapper edge. Consequently, writes such as
n.makeValueInplace(0) = source()orv.createInPlace<int>(0) = source()are lost when the wrapper is read later. Add the same reverse paths used forvalue()/the().
output = ["Argument[-1].Element[" + stars + "]", "ReturnValue[*" + stars + "]"]
cpp/ql/lib/ext/bdlb.values.model.yml:14
- The move-assignment summary does not propagate the moved contents to the returned
NullableValue&, so chained reads from(dst = move(src))miss flow. Add a parallelReturnValue[*].Element[@]output for this signature.
- ["BloombergLP::bdlb", "NullableValue", False, "operator=", "(NullableValue &&)", "", "Argument[*0].Element[@]", "Argument[-1].Element[@]", "value", "manual"]
cpp/ql/lib/ext/bdlb.values.model.yml:19
- The copy-assignment model omits flow to the returned
VariantImp&. As a result, reading the contained value through(dst = src)loses the copied taint even though the returned reference aliasesdst. Add the corresponding return-value element summary.
- ["BloombergLP::bdlb", "VariantImp", False, "operator=", "(const VariantImp &)", "", "Argument[*0].Element[@]", "Argument[-1].Element[@]", "value", "manual"]
cpp/ql/lib/ext/bdlb.values.model.yml:21
- The move-assignment model similarly omits flow to the returned
VariantImp&, so chained reads from the assignment result are not modeled. Add a parallelReturnValue[*].Element[@]output for the move signature.
- ["BloombergLP::bdlb", "VariantImp", False, "operator=", "(VariantImp &&)", "", "Argument[*0].Element[@]", "Argument[-1].Element[@]", "value", "manual"]
- Files reviewed: 9/10 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Fix both P2 findings: propagate copy/move assignment contents to the returned wrapper reference, and preserve writes through makeValue and scalar emplacement results. Add seven regression cases with destination-read controls. Wrapper flow tests, model validation, and QL formatting pass.
Address the two P2 findings from the independent review of PR github#22581. Restrict scalar emplacement summaries to arithmetic or pointer inputs so user-defined conversions retain body analysis. Model copy/move assignment results as aliases of the receiver. Add positive and negative conversion regressions and write-through tests for both assignment forms and wrappers. Wrapper flow tests and model validation pass.
31508c5 to
ed31d67
Compare
ed31d67 to
07cf84e
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The summaries omit valid pointer conversions and several C++ scalar emplacement categories.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (1)
cpp/ql/lib/semmle/code/cpp/models/implementations/BdlbValues.qll:88
- The advertised scalar-emplacement model currently omits several C++ scalar categories. In particular, an exact
enumpayload is neitherArithmeticTypenorPointerType, soNullableValue<MyEnum>::makeValueInplace(sourceEnum())and the corresponding variant call get no summary even though no user-defined conversion is involved. Include enums (and the other scalar pointer/null categories) or narrow the documented scope.
(inputType instanceof ArithmeticType or inputType instanceof PointerType) and
storedType =
this.getType().getUnspecifiedType().(ReferenceType).getBaseType().getUnspecifiedType() and
(storedType instanceof ArithmeticType or storedType instanceof PointerType) and
- Files reviewed: 11/12 changed files
- Comments generated: 1
- Review effort level: Balanced
Track contained values through NullableValue and VariantImp accessors, copy/move operations, assignment, and scalar emplacement. Preserve assignment-result aliasing, returned-reference writes, and exact-type pointer payloads. Leave user-defined conversions and emplacement constructors available for body analysis. Add regressions for scalar, pointer and aggregate payloads; copy/move result reads and writes; arithmetic conversions; and constructors and conversions that use or ignore their inputs. Wrapper flow tests and external model validation pass.
07cf84e to
a2ae81f
Compare
Adds contained-value flow models for BDE
bdlb::NullableValueand thebdlb::Variantfamily.Covers accessors (
value,the,valueOr,addressOr,valueOrNull),makeValue/assign, same-specialization copy and move operations, allocator-extended constructors, and single-argument arithmetic, enum, and pointer emplacement.Simple reads use YAML summaries; type-dependent flow and write-back through returned references/pointers use QL summaries. Inherited optional operators are handled separately in #22582.
Class-typed and multi-argument emplacement, engagement state, and C++03 move emulation are outside this change.