From 8aa1a7b2054f424e892d42d40ba10fafe5452263 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Jul 2026 12:20:47 +0000 Subject: [PATCH] Commit 4: Correct anchor semantics/docs for default std::regex In default ECMAScript std::regex (no multiline flag; this parser cannot detect construction-site flags), ^ and $ anchor to string start/end, not line boundaries. Update RegExpCaret, RegExpDollar, and RegExpAnchor doc comments to describe string-start/string-end semantics and note that multiline is not modelled, mirroring PR #22200. Tokenization unchanged. .expected files unchanged. Bundle: github/codeql-action codeql-bundle-v2.26.1 (CodeQL CLI 2.26.1). --- cpp/ql/lib/semmle/code/cpp/regex/RegexTreeView.qll | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cpp/ql/lib/semmle/code/cpp/regex/RegexTreeView.qll b/cpp/ql/lib/semmle/code/cpp/regex/RegexTreeView.qll index 3dbf67b6050..477b953739f 100644 --- a/cpp/ql/lib/semmle/code/cpp/regex/RegexTreeView.qll +++ b/cpp/ql/lib/semmle/code/cpp/regex/RegexTreeView.qll @@ -967,6 +967,11 @@ private module Impl implements RegexTreeViewSig { * A term that matches a specific position between characters in the string. * ECMAScript anchors: `^` and `$` only. * (Ruby-only `\A`, `\Z`, `\z` removed) + * + * In the default `std::regex` ECMAScript grammar, `^` and `$` anchor to the + * start and end of the input string. Multiline mode (in which they would + * also match at line boundaries) is a construction-site flag that this + * parser cannot observe, and is therefore not modelled. */ class RegExpAnchor extends RegExpSpecialChar { RegExpAnchor() { this.getChar() = ["^", "$"] } @@ -975,7 +980,8 @@ private module Impl implements RegexTreeViewSig { } /** - * A dollar assertion `$` matching the end of a line. + * A dollar assertion `$` matching the end of the input string + * (multiline mode is not modelled; see `RegExpAnchor`). * * Example: * @@ -992,7 +998,8 @@ private module Impl implements RegexTreeViewSig { } /** - * A caret assertion `^` matching the beginning of a line. + * A caret assertion `^` matching the start of the input string + * (multiline mode is not modelled; see `RegExpAnchor`). * * Example: *