Skip to content

Commit 2f01e13

Browse files
authored
Commit 8: Complete location-test coverage for u8 and u8R forms
Add u8"..." and u8R"(...)" cases to test_locations in test.cpp, guarded by #if __cplusplus >= 201703L. Add an options file forcing -std=c++17 so the u8 char8_t-era rows are actually extracted. Plain "..." rows are unchanged. New u8/u8R rows in locations.expected show correct columns computed by regexpContentOffset: offset 3 for `u8"` and offset 5 for `u8R"(`. No change to regexpContentOffset was needed. Bundle: github/codeql-action codeql-bundle-v2.26.1 (CodeQL CLI 2.26.1).
1 parent 633ba01 commit 2f01e13

5 files changed

Lines changed: 51 additions & 0 deletions

File tree

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,11 @@
9494
| test.cpp:196:22:196:25 | a\\.b | 21 | 0 | 4 | 22 | 25 |
9595
| test.cpp:196:23:196:24 | \\. | 21 | 1 | 3 | 23 | 24 |
9696
| test.cpp:196:25:196:25 | b | 21 | 3 | 4 | 25 | 25 |
97+
| test.cpp:200:22:200:22 | a | 19 | 0 | 1 | 22 | 22 |
98+
| test.cpp:200:22:200:23 | a+ | 19 | 0 | 2 | 22 | 23 |
99+
| test.cpp:200:22:200:24 | a+b | 19 | 0 | 3 | 22 | 24 |
100+
| test.cpp:200:24:200:24 | b | 19 | 2 | 3 | 24 | 24 |
101+
| test.cpp:203:28:203:28 | a | 23 | 0 | 1 | 28 | 28 |
102+
| test.cpp:203:28:203:29 | a+ | 23 | 0 | 2 | 28 | 29 |
103+
| test.cpp:203:28:203:30 | a+b | 23 | 0 | 3 | 28 | 30 |
104+
| test.cpp:203:30:203:30 | b | 23 | 2 | 3 | 30 | 30 |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
semmle-extractor-options: -std=c++17

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,3 +861,25 @@ test.cpp:
861861
# 196| [RegExpConstant, RegExpEscape] \.
862862

863863
# 196| [RegExpConstant, RegExpNormalChar] b
864+
865+
# 200| [RegExpConstant, RegExpNormalChar] a
866+
867+
# 200| [RegExpPlus] a+
868+
#-----| 0 -> [RegExpConstant, RegExpNormalChar] a
869+
870+
# 200| [RegExpSequence] a+b
871+
#-----| 0 -> [RegExpPlus] a+
872+
#-----| 1 -> [RegExpConstant, RegExpNormalChar] b
873+
874+
# 200| [RegExpConstant, RegExpNormalChar] b
875+
876+
# 203| [RegExpConstant, RegExpNormalChar] a
877+
878+
# 203| [RegExpPlus] a+
879+
#-----| 0 -> [RegExpConstant, RegExpNormalChar] a
880+
881+
# 203| [RegExpSequence] a+b
882+
#-----| 0 -> [RegExpPlus] a+
883+
#-----| 1 -> [RegExpConstant, RegExpNormalChar] b
884+
885+
# 203| [RegExpConstant, RegExpNormalChar] b

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,14 @@ term
323323
| test.cpp:196:22:196:25 | a\\.b | RegExpSequence |
324324
| test.cpp:196:23:196:24 | \\. | RegExpConstant,RegExpEscape |
325325
| test.cpp:196:25:196:25 | b | RegExpConstant,RegExpNormalChar |
326+
| test.cpp:200:22:200:22 | a | RegExpConstant,RegExpNormalChar |
327+
| test.cpp:200:22:200:23 | a+ | RegExpPlus |
328+
| test.cpp:200:22:200:24 | a+b | RegExpSequence |
329+
| test.cpp:200:24:200:24 | b | RegExpConstant,RegExpNormalChar |
330+
| test.cpp:203:28:203:28 | a | RegExpConstant,RegExpNormalChar |
331+
| test.cpp:203:28:203:29 | a+ | RegExpPlus |
332+
| test.cpp:203:28:203:30 | a+b | RegExpSequence |
333+
| test.cpp:203:30:203:30 | b | RegExpConstant,RegExpNormalChar |
326334
regExpNormalCharValue
327335
| test.cpp:33:21:33:23 | abc | abc |
328336
| test.cpp:36:22:36:22 | a | a |
@@ -461,3 +469,7 @@ regExpNormalCharValue
461469
| test.cpp:196:22:196:22 | a | a |
462470
| test.cpp:196:23:196:24 | \\. | . |
463471
| test.cpp:196:25:196:25 | b | b |
472+
| test.cpp:200:22:200:22 | a | a |
473+
| test.cpp:200:24:200:24 | b | b |
474+
| test.cpp:203:28:203:28 | a | a |
475+
| test.cpp:203:30:203:30 | b | b |

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,12 @@ void test_locations() {
194194

195195
// Escape with dot — "a\\.b" value is a\.b; offset 1 correct
196196
std::regex r_esc2("a\\.b");
197+
198+
// u8 encoding prefix — content offset 3 (u8" = 3 chars). Requires C++17+.
199+
#if __cplusplus >= 201703L
200+
std::regex r_u8(u8"a+b");
201+
202+
// u8R raw — content offset 5 (u8R"( = 5 chars).
203+
std::regex r_u8_raw(u8R"(a+b)");
204+
#endif
197205
}

0 commit comments

Comments
 (0)