Skip to content

Commit 34bb7ac

Browse files
authored
Commit 10: Strip process-narrative comments from shipped source
Remove "commit N does X" and "currently wrong / pre-fix" narrative from test.cpp and locations.ql; where appropriate, replace with concise process-free descriptions of the code (e.g. "Raw string literal; content offset 3"). Line count and column positions of every regex literal are preserved (empty lines take the place of removed comment lines), so no .expected file changes. Remaining "Note:" comments in the .qll files describe code semantics (excluded forms / handling), not the build process, and are kept. Bundle: github/codeql-action codeql-bundle-v2.26.1 (CodeQL CLI 2.26.1).
1 parent e4305fb commit 34bb7ac

2 files changed

Lines changed: 21 additions & 24 deletions

File tree

cpp/ql/test/library-tests/regex/locations.ql

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
* start column, the term's value offsets, and the computed start/end columns.
44
* Used to verify that `hasLocationInfo` produces correct columns for plain,
55
* raw, and encoding-prefixed C++ string literals.
6-
*
7-
* Commit 8 captures pre-fix (wrong) columns for raw/prefixed literals.
8-
* Commit 9 fixes them; plain "..." rows must remain unchanged.
96
*/
107

118
import cpp

cpp/ql/test/library-tests/regex/test.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void test() {
3535
// Repetition
3636
std::regex r_rep1("a*b+c?d");
3737
std::regex r_rep2("a{4,8}");
38-
// Removed: a{,8} — Ruby-only "{,n}" no-lower-bound quantifier (not in ECMAScript)
38+
3939
std::regex r_rep4("a{3,}");
4040
std::regex r_rep5("a{7}");
4141

@@ -45,7 +45,7 @@ void test() {
4545
// Character classes
4646
std::regex r_cc1("[abc]");
4747
std::regex r_cc2("[a-fA-F0-9_]");
48-
// Removed: \\A[+-]?\\d+ — \\A is a Ruby-only anchor; replaced with ^ for ECMAScript
48+
4949
std::regex r_cc3("^[+-]?\\d+");
5050
std::regex r_cc4("[\\w]+");
5151
std::regex r_cc5("\\[\\][123]");
@@ -59,7 +59,7 @@ void test() {
5959
std::regex r_nested("[[a-f]A-F]");
6060

6161
// POSIX bracket extensions (std::regex ECMAScript mode supports these inside [...])
62-
// Note: commit 7 fixes tokenization for these cases; commit 6 captures pre-fix behavior.
62+
6363

6464
// Single POSIX classes (single outer bracket around a single POSIX expression)
6565
std::regex r_posix_alpha("[[:alpha:]]"); // naïve parser closes at inner ] of [:alpha:]
@@ -91,14 +91,14 @@ void test() {
9191
std::regex r_meta2("\\w+\\W");
9292
std::regex r_meta3("\\s\\S");
9393
std::regex r_meta4("\\d\\D");
94-
// Removed: \\h\\H — Ruby-only hex-digit escape classes (not in ECMAScript)
94+
9595
std::regex r_meta6("\\n\\r\\t");
9696

9797
// NUL escape \0 (ECMAScript: valid when not followed by another digit)
9898
std::regex r_nul("a\\0b");
9999

100-
// Anchors (ECMAScript: \b, \B only; \A, \G removed)
101-
// Removed: \\Gabc — Ruby-only \G anchor (not in ECMAScript)
100+
// Anchors (ECMAScript: \b, \B only)
101+
102102
std::regex r_anc2("\\b!a\\B");
103103

104104
// Groups
@@ -109,7 +109,7 @@ void test() {
109109

110110
// Named groups
111111
std::regex r_ng1("(?<id>\\w+)");
112-
// Removed: (?'foo'fo+) — Ruby single-quote named-group form (not in ECMAScript)
112+
113113

114114
// Backreferences
115115
std::regex r_bref1("(a+)b+\\1");
@@ -157,42 +157,42 @@ void test() {
157157
// Integration case
158158
std::regex r_posix15("^([[:alpha:]]+[[:digit:]]*[[:space:]]?)+([[:punct:]]|[[:xdigit:]])+$");
159159

160-
// Dropped: /#{A}bc/ — Ruby string interpolation, no C++ string-literal form.
160+
161161

162162
// unicode: \uHHHH 4-digit hex form (valid ECMAScript \u escape in std::regex)
163163
std::regex r_uni("\\u9879");
164164
}
165165

166-
// Location tests (commit 8: pre-fix columns; commit 9: fixes raw/prefixed offsets).
167-
// Each literal is wrapped in an appropriate std::regex use so the literal is in the DB.
168-
// For each form, we test a simple "a+b" regex so the term locations are predictable.
166+
// Per-form location tests for C++ string-literal spellings. Each literal is
167+
// wrapped in an appropriate std::regex use so it is extracted, and each uses
168+
// a simple "a+b" body so term columns are predictable.
169169
void test_locations() {
170-
// Plain "..." — content offset 1 (CORRECT in current code)
170+
// Plain "..." — content offset 1.
171171
std::regex r_plain("a+b");
172172

173-
// Raw R"(...)" — content offset 3 (R"( = 3 chars); currently wrong (uses 1)
173+
// Raw R"(...)" — content offset 3 (`R"(` = 3 chars).
174174
std::regex r_raw(R"(a+b)");
175175

176-
// Raw with regex metacharacters — R"(\s+$)" offset 3; currently wrong
176+
// Raw with regex metacharacters — content offset 3.
177177
std::regex r_raw2(R"(\s+$)");
178178

179-
// Complex raw — R"(\(([,\w]+)+\)$)" offset 3; currently wrong
179+
// Complex raw — content offset 3.
180180
std::regex r_raw3(R"(\(([,\w]+)+\)$)");
181181

182-
// Custom-delimiter raw R"x(a+b)x" offset 4 (R"x( = 4); currently wrong
182+
// Custom-delimiter raw R"x(...)x" — content offset 4 (`R"x(` = 4 chars).
183183
std::regex r_raw4(R"x(a+b)x");
184184

185-
// Wide-char prefix L"..." — content offset 2 (L" = 2); currently wrong
185+
// Wide-char prefix L"..." — content offset 2 (`L"` = 2 chars).
186186
std::wregex r_wide(L"a+b");
187187

188-
// Wide raw LR"(...)" — content offset 4 (LR"( = 4); currently wrong
188+
// Wide raw LR"(...)" — content offset 4 (`LR"(` = 4 chars).
189189
std::wregex r_wide_raw(LR"(a+b)");
190190

191-
// Escape-containing plain — "\\s+" value is \s+ (2 chars); offset 1 correct
192-
// (within-content mapping is approximate for escaped strings, documented)
191+
// Escape-containing plain — value is \s+ (2 chars); offset 1.
192+
// (Within-content column mapping is approximate for escaped strings.)
193193
std::regex r_esc1("\\s+");
194194

195-
// Escape with dot — "a\\.b" value is a\.b; offset 1 correct
195+
// Escape with dot — value is a\.b; offset 1.
196196
std::regex r_esc2("a\\.b");
197197

198198
// u8 encoding prefix — content offset 3 (u8" = 3 chars). Requires C++17+.

0 commit comments

Comments
 (0)