Skip to content

Commit 5125835

Browse files
redsun82Copilot
andcommitted
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>
1 parent 72d9afe commit 5125835

File tree

9 files changed

+63
-0
lines changed

9 files changed

+63
-0
lines changed

cpp/justfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import '../lib.just'
2+
3+
[group('build')]
4+
build: (_build_dist "cpp")
5+
6+
[group('test')]
7+
language-tests *EXTRA_ARGS: (_language_tests EXTRA_ARGS source_dir() 'ql/test' '../../semmlecode-cpp-tests')
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import cpp
2+
3+
// Locations should either be :0:0:0:0 locations (UnknownLocation, or
4+
// a whole file), or all 4 fields should be positive.
5+
from Location l
6+
where
7+
[l.getStartLine(), l.getEndLine(), l.getStartColumn(), l.getEndColumn()] != 0 and
8+
[l.getStartLine(), l.getEndLine(), l.getStartColumn(), l.getEndColumn()] < 1
9+
select l
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import cpp
2+
3+
from Element e
4+
where e.toString().matches("%(null)%")
5+
select e
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: codeql/cpp-consistency-queries
2+
groups: [cpp, test, consistency-queries]
3+
dependencies:
4+
codeql/cpp-all: ${workspace}
5+
extractor: cpp
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import cpp
2+
3+
from Location l
4+
where
5+
not any(Element e).getLocation() = l and
6+
not any(LambdaCapture lc).getLocation() = l and
7+
not any(MacroAccess ma).getActualLocation() = l and
8+
not any(NamespaceDeclarationEntry nde).getBodyLocation() = l and
9+
not any(XmlLocatable xml).getLocation() = l
10+
select l
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import cpp
2+
3+
from VariableDeclarationEntry i
4+
where not exists(i.getType())
5+
select i
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import cpp
2+
3+
from Variable i
4+
where not exists(i.getType())
5+
select i

cpp/ql/justfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import "../../lib.just"
2+
3+
[no-cd]
4+
format *ARGS=".": (_format_ql ARGS)
5+
6+
consistency_queries := source_dir() / "consistency-queries"

cpp/ql/test/justfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import "../justfile"
2+
3+
base_flags := "--include-location-in-star"
4+
5+
all_checks := default_db_checks + """\
6+
--check-undefined-labels \
7+
--check-unused-labels \
8+
--consistency-queries=""" + consistency_queries
9+
10+
[no-cd]
11+
test *ARGS=".": (_codeql_test "cpp" base_flags all_checks ARGS)

0 commit comments

Comments
 (0)