Skip to content

Commit 4e39cc1

Browse files
authored
Merge pull request #22300 from jketema/jketema/ecma-regex
C++: Add ECMAScript `std::regex` parser
2 parents 0580587 + 50ed141 commit 4e39cc1

14 files changed

Lines changed: 3441 additions & 0 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: feature
3+
---
4+
* Added a C++ regular-expression parser for the ECMAScript grammar used by `std::regex`.

‎cpp/ql/lib/qlpack.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencies:
1010
codeql/mad: ${workspace}
1111
codeql/quantum: ${workspace}
1212
codeql/rangeanalysis: ${workspace}
13+
codeql/regex: ${workspace}
1314
codeql/ssa: ${workspace}
1415
codeql/typeflow: ${workspace}
1516
codeql/tutorial: ${workspace}

‎cpp/ql/lib/semmle/code/cpp/exprs/Literal.qll‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,19 @@ class StringLiteral extends TextLiteral {
133133
override string getAPrimaryQlClass() { result = "StringLiteral" }
134134
}
135135

136+
/**
137+
* A C++ raw string literal. For example:
138+
* ```
139+
* const char *s1 = R"(abcdef)";
140+
* const wchar_t *s2 = LR"x(123456)x";
141+
* ```
142+
*/
143+
class RawStringLiteral extends StringLiteral {
144+
RawStringLiteral() { this.getValueText().regexpMatch("[^\"]*R\".*\\(.*") }
145+
146+
override string getAPrimaryQlClass() { result = "RawStringLiteral" }
147+
}
148+
136149
/**
137150
* An octal literal. For example:
138151
* ```

0 commit comments

Comments
 (0)