Files
codeql/cpp/ql/test/library-tests/regex/parse.ql
copilot-swe-agent[bot] cc12bba930 Add C++ ECMAScript regex parser and tree view (initial implementation)
Ports the Ruby regex library to C++/ECMAScript (`std::regex` default dialect):
- `cpp/ql/lib/semmle/code/cpp/regex/internal/ParseRegExp.qll`: ECMAScript-adapted parser over `StringLiteral`
- `cpp/ql/lib/semmle/code/cpp/regex/RegexTreeView.qll`: tree view implementing `RegexTreeViewSig`
- `cpp/ql/lib/qlpack.yml`: add `codeql/regex` dependency (already present)
- `cpp/ql/test/library-tests/regex/`: hermetic test corpus (test.cpp with std:: stubs), parse.ql, regexp.ql, RegExpConfig.qll
- `cpp/ql/lib/change-notes/released/12.1.0.md`: minorAnalysis change note

Note: .expected files are placeholders; run `codeql test run --accept` after database generation to populate them.
2026-07-21 09:01:50 +00:00

29 lines
756 B
Plaintext

/**
* @kind graph
*/
import cpp
import RegExpConfig
import semmle.code.cpp.regex.RegexTreeView as RE
query predicate nodes(RE::RegExpTerm n, string attr, string val) {
attr = "semmle.label" and
val = "[" + concat(n.getAPrimaryQlClass(), ", ") + "] " + n.toString()
or
attr = "semmle.order" and
val =
any(int i |
n =
rank[i](RE::RegExpTerm t, string fp, int sl, int sc, int el, int ec |
t.hasLocationInfo(fp, sl, sc, el, ec)
|
t order by fp, sl, sc, el, ec, t.toString()
)
).toString()
}
query predicate edges(RE::RegExpTerm pred, RE::RegExpTerm succ, string attr, string val) {
attr in ["semmle.label", "semmle.order"] and
val = any(int i | succ = pred.getChild(i)).toString()
}