Files
codeql/cpp/ql
copilot-swe-agent[bot] e7ccb1f2ce Commit 8: Add location tests exposing term-location off-by-one (pre-fix)
Add location test cases to test.cpp covering various C++ string literal forms:
- r_plain:     "a+b"          — plain, offset 1 (already correct)
- r_raw:       R"(a+b)"       — raw, offset 3 (R"( = 3); currently uses 1 (WRONG)
- r_raw2:      R"(\s+$)"      — raw with metacharacters; currently wrong
- r_raw3:      R"(\(([,\w]+)+\)$)" — complex raw; currently wrong
- r_raw4:      R"x(a+b)x"    — custom-delimiter raw, offset 4; currently uses 1 (WRONG)
- r_wide:      L"a+b"         — L" prefix, offset 2; currently uses 1 (WRONG)
- r_wide_raw:  LR"(a+b)"      — combined LR"( prefix, offset 4; currently uses 1 (WRONG)
- r_esc1:      "\\s+"         — escape-containing plain; offset 1 (correct)
- r_esc2:      "a\\.b"        — escaped dot; offset 1 (correct)

Added std::wregex typedef to stubs (for L"..." and LR"(...)" wide-char literals).

New locations.ql query reports per-term: litStartCol, valueStart, valueEnd,
termStartCol, termEndCol — restricted to test_locations() function.

Generated locations.expected via codeql test run --learn (CodeQL 2.26.1).
All 3 tests pass. The expected output captures the CURRENT (pre-fix) columns:
raw/prefixed rows show termStartCol = litStartCol + 1 (wrong);
plain rows show litStartCol + 1 (correct).
Commit 9 changes the raw/prefixed rows to their correct values.
2026-07-21 10:27:55 +00:00
..