C++: Port to new just-based language test definition

Add justfiles for C++ following the pattern of other ported languages
(go, rust, swift). Move consistency queries from semmle-code's
semmlecode-cpp-consistency-queries/ to ql/cpp/ql/consistency-queries/.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Paolo Tranquilli
2026-04-02 12:24:24 +02:00
parent 72d9afeb34
commit 5125835faf
9 changed files with 63 additions and 0 deletions

7
cpp/justfile Normal file
View File

@@ -0,0 +1,7 @@
import '../lib.just'
[group('build')]
build: (_build_dist "cpp")
[group('test')]
language-tests *EXTRA_ARGS: (_language_tests EXTRA_ARGS source_dir() 'ql/test' '../../semmlecode-cpp-tests')

View File

@@ -0,0 +1,9 @@
import cpp
// Locations should either be :0:0:0:0 locations (UnknownLocation, or
// a whole file), or all 4 fields should be positive.
from Location l
where
[l.getStartLine(), l.getEndLine(), l.getStartColumn(), l.getEndColumn()] != 0 and
[l.getStartLine(), l.getEndLine(), l.getStartColumn(), l.getEndColumn()] < 1
select l

View File

@@ -0,0 +1,5 @@
import cpp
from Element e
where e.toString().matches("%(null)%")
select e

View File

@@ -0,0 +1,5 @@
name: codeql/cpp-consistency-queries
groups: [cpp, test, consistency-queries]
dependencies:
codeql/cpp-all: ${workspace}
extractor: cpp

View File

@@ -0,0 +1,10 @@
import cpp
from Location l
where
not any(Element e).getLocation() = l and
not any(LambdaCapture lc).getLocation() = l and
not any(MacroAccess ma).getActualLocation() = l and
not any(NamespaceDeclarationEntry nde).getBodyLocation() = l and
not any(XmlLocatable xml).getLocation() = l
select l

View File

@@ -0,0 +1,5 @@
import cpp
from VariableDeclarationEntry i
where not exists(i.getType())
select i

View File

@@ -0,0 +1,5 @@
import cpp
from Variable i
where not exists(i.getType())
select i

6
cpp/ql/justfile Normal file
View File

@@ -0,0 +1,6 @@
import "../../lib.just"
[no-cd]
format *ARGS=".": (_format_ql ARGS)
consistency_queries := source_dir() / "consistency-queries"

11
cpp/ql/test/justfile Normal file
View File

@@ -0,0 +1,11 @@
import "../justfile"
base_flags := "--include-location-in-star"
all_checks := default_db_checks + """\
--check-undefined-labels \
--check-unused-labels \
--consistency-queries=""" + consistency_queries
[no-cd]
test *ARGS=".": (_codeql_test "cpp" base_flags all_checks ARGS)