Skip to content

cpp: model BDE character views and substring utilities - #22583

Open
kumarak wants to merge 1 commit into
github:mainfrom
trail-of-forks:bde-stringref-models
Open

kumarak wants to merge 1 commit into
github:mainfrom
trail-of-forks:bde-stringref-models

Conversation

@kumarak

@kumarak kumarak commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

This change models character flow through pointer-based bslstl::StringRefImp construction, data, begin, and indexed access, plus bdlb::StringRefUtil operations including trim/ltrim/rtrim, substr, and the strstr/strrstr caseless variants.

The models target the StringRefImp template behind the public StringRef typedef and keep referenced characters separate from search patterns, positions, and lengths, preventing metadata from becoming returned character data.

Tests cover copying, pointer-range and integral-length constructors, narrow/wide character access, all eight utilities, and negative pattern/metadata cases.

@kumarak
kumarak requested a review from a team as a code owner September 15, 2026 22:05
Copilot AI balanced review requested due to automatic review settings September 15, 2026 22:05

Copilot AI 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.

🟢 Approval recommended

The models are narrowly scoped, preserve character flow without propagating metadata, and are covered by focused tests.

Pull request overview

Adds C++ data-flow models for BDE character views and substring utilities.

Changes:

  • Models pointer-based StringRefImp construction and character access.
  • Models eight StringRefUtil operations while excluding metadata and patterns.
  • Adds narrow/wide positive and negative flow tests.
File summaries
File Description
cpp/ql/lib/semmle/code/cpp/models/Models.qll Registers the new implementation model.
cpp/ql/lib/semmle/code/cpp/models/implementations/BdlbStringRef.qll Models pointer-based view construction.
cpp/ql/lib/ext/bdlb.stringref.model.yml Defines access and utility summaries.
cpp/ql/test/library-tests/dataflow/bdlb-stringref/test.cpp Adds positive and negative flow cases.
cpp/ql/test/library-tests/dataflow/bdlb-stringref/flow.ql Configures the taint-flow test.
cpp/ql/test/library-tests/dataflow/bdlb-stringref/flow.expected Provides the test expectation artifact.
cpp/ql/lib/change-notes/2026-09-15-bdlb-stringref.md Documents the analysis improvement.
Review details
  • Files reviewed: 6/7 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants