Skip to content

Commit 8aa1a7b

Browse files
authored
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).
1 parent 903e9f2 commit 8aa1a7b

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

cpp/ql/lib/semmle/code/cpp/regex/RegexTreeView.qll

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,11 @@ private module Impl implements RegexTreeViewSig {
967967
* A term that matches a specific position between characters in the string.
968968
* ECMAScript anchors: `^` and `$` only.
969969
* (Ruby-only `\A`, `\Z`, `\z` removed)
970+
*
971+
* In the default `std::regex` ECMAScript grammar, `^` and `$` anchor to the
972+
* start and end of the input string. Multiline mode (in which they would
973+
* also match at line boundaries) is a construction-site flag that this
974+
* parser cannot observe, and is therefore not modelled.
970975
*/
971976
class RegExpAnchor extends RegExpSpecialChar {
972977
RegExpAnchor() { this.getChar() = ["^", "$"] }
@@ -975,7 +980,8 @@ private module Impl implements RegexTreeViewSig {
975980
}
976981

977982
/**
978-
* A dollar assertion `$` matching the end of a line.
983+
* A dollar assertion `$` matching the end of the input string
984+
* (multiline mode is not modelled; see `RegExpAnchor`).
979985
*
980986
* Example:
981987
*
@@ -992,7 +998,8 @@ private module Impl implements RegexTreeViewSig {
992998
}
993999

9941000
/**
995-
* A caret assertion `^` matching the beginning of a line.
1001+
* A caret assertion `^` matching the start of the input string
1002+
* (multiline mode is not modelled; see `RegExpAnchor`).
9961003
*
9971004
* Example:
9981005
*

0 commit comments

Comments
 (0)