From 2f01e133b9064cf35c6d0a2664996a017be4f4f3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Jul 2026 12:27:34 +0000 Subject: [PATCH] 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). --- .../library-tests/regex/locations.expected | 8 +++++++ cpp/ql/test/library-tests/regex/options | 1 + .../test/library-tests/regex/parse.expected | 22 +++++++++++++++++++ .../test/library-tests/regex/regexp.expected | 12 ++++++++++ cpp/ql/test/library-tests/regex/test.cpp | 8 +++++++ 5 files changed, 51 insertions(+) create mode 100644 cpp/ql/test/library-tests/regex/options diff --git a/cpp/ql/test/library-tests/regex/locations.expected b/cpp/ql/test/library-tests/regex/locations.expected index a70822fa3a6..8b3a01df017 100644 --- a/cpp/ql/test/library-tests/regex/locations.expected +++ b/cpp/ql/test/library-tests/regex/locations.expected @@ -94,3 +94,11 @@ | test.cpp:196:22:196:25 | a\\.b | 21 | 0 | 4 | 22 | 25 | | test.cpp:196:23:196:24 | \\. | 21 | 1 | 3 | 23 | 24 | | test.cpp:196:25:196:25 | b | 21 | 3 | 4 | 25 | 25 | +| test.cpp:200:22:200:22 | a | 19 | 0 | 1 | 22 | 22 | +| test.cpp:200:22:200:23 | a+ | 19 | 0 | 2 | 22 | 23 | +| test.cpp:200:22:200:24 | a+b | 19 | 0 | 3 | 22 | 24 | +| test.cpp:200:24:200:24 | b | 19 | 2 | 3 | 24 | 24 | +| test.cpp:203:28:203:28 | a | 23 | 0 | 1 | 28 | 28 | +| test.cpp:203:28:203:29 | a+ | 23 | 0 | 2 | 28 | 29 | +| test.cpp:203:28:203:30 | a+b | 23 | 0 | 3 | 28 | 30 | +| test.cpp:203:30:203:30 | b | 23 | 2 | 3 | 30 | 30 | diff --git a/cpp/ql/test/library-tests/regex/options b/cpp/ql/test/library-tests/regex/options new file mode 100644 index 00000000000..2ebedec9a4c --- /dev/null +++ b/cpp/ql/test/library-tests/regex/options @@ -0,0 +1 @@ +semmle-extractor-options: -std=c++17 diff --git a/cpp/ql/test/library-tests/regex/parse.expected b/cpp/ql/test/library-tests/regex/parse.expected index b1ee43d1748..f7361ec71c4 100644 --- a/cpp/ql/test/library-tests/regex/parse.expected +++ b/cpp/ql/test/library-tests/regex/parse.expected @@ -861,3 +861,25 @@ test.cpp: # 196| [RegExpConstant, RegExpEscape] \. # 196| [RegExpConstant, RegExpNormalChar] b + +# 200| [RegExpConstant, RegExpNormalChar] a + +# 200| [RegExpPlus] a+ +#-----| 0 -> [RegExpConstant, RegExpNormalChar] a + +# 200| [RegExpSequence] a+b +#-----| 0 -> [RegExpPlus] a+ +#-----| 1 -> [RegExpConstant, RegExpNormalChar] b + +# 200| [RegExpConstant, RegExpNormalChar] b + +# 203| [RegExpConstant, RegExpNormalChar] a + +# 203| [RegExpPlus] a+ +#-----| 0 -> [RegExpConstant, RegExpNormalChar] a + +# 203| [RegExpSequence] a+b +#-----| 0 -> [RegExpPlus] a+ +#-----| 1 -> [RegExpConstant, RegExpNormalChar] b + +# 203| [RegExpConstant, RegExpNormalChar] b diff --git a/cpp/ql/test/library-tests/regex/regexp.expected b/cpp/ql/test/library-tests/regex/regexp.expected index cdb750c90fb..cb83e11287f 100644 --- a/cpp/ql/test/library-tests/regex/regexp.expected +++ b/cpp/ql/test/library-tests/regex/regexp.expected @@ -323,6 +323,14 @@ term | test.cpp:196:22:196:25 | a\\.b | RegExpSequence | | test.cpp:196:23:196:24 | \\. | RegExpConstant,RegExpEscape | | test.cpp:196:25:196:25 | b | RegExpConstant,RegExpNormalChar | +| test.cpp:200:22:200:22 | a | RegExpConstant,RegExpNormalChar | +| test.cpp:200:22:200:23 | a+ | RegExpPlus | +| test.cpp:200:22:200:24 | a+b | RegExpSequence | +| test.cpp:200:24:200:24 | b | RegExpConstant,RegExpNormalChar | +| test.cpp:203:28:203:28 | a | RegExpConstant,RegExpNormalChar | +| test.cpp:203:28:203:29 | a+ | RegExpPlus | +| test.cpp:203:28:203:30 | a+b | RegExpSequence | +| test.cpp:203:30:203:30 | b | RegExpConstant,RegExpNormalChar | regExpNormalCharValue | test.cpp:33:21:33:23 | abc | abc | | test.cpp:36:22:36:22 | a | a | @@ -461,3 +469,7 @@ regExpNormalCharValue | test.cpp:196:22:196:22 | a | a | | test.cpp:196:23:196:24 | \\. | . | | test.cpp:196:25:196:25 | b | b | +| test.cpp:200:22:200:22 | a | a | +| test.cpp:200:24:200:24 | b | b | +| test.cpp:203:28:203:28 | a | a | +| test.cpp:203:30:203:30 | b | b | diff --git a/cpp/ql/test/library-tests/regex/test.cpp b/cpp/ql/test/library-tests/regex/test.cpp index 37cb61d4a63..93aace2760c 100644 --- a/cpp/ql/test/library-tests/regex/test.cpp +++ b/cpp/ql/test/library-tests/regex/test.cpp @@ -194,4 +194,12 @@ void test_locations() { // Escape with dot — "a\\.b" value is a\.b; offset 1 correct std::regex r_esc2("a\\.b"); + + // u8 encoding prefix — content offset 3 (u8" = 3 chars). Requires C++17+. +#if __cplusplus >= 201703L + std::regex r_u8(u8"a+b"); + + // u8R raw — content offset 5 (u8R"( = 5 chars). + std::regex r_u8_raw(u8R"(a+b)"); +#endif }