mirror of
https://github.com/github/codeql.git
synced 2026-05-14 19:29:28 +02:00
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:
7
cpp/justfile
Normal file
7
cpp/justfile
Normal 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')
|
||||
9
cpp/ql/consistency-queries/badLocations.ql
Normal file
9
cpp/ql/consistency-queries/badLocations.ql
Normal 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
|
||||
5
cpp/ql/consistency-queries/nullInToString.ql
Normal file
5
cpp/ql/consistency-queries/nullInToString.ql
Normal file
@@ -0,0 +1,5 @@
|
||||
import cpp
|
||||
|
||||
from Element e
|
||||
where e.toString().matches("%(null)%")
|
||||
select e
|
||||
5
cpp/ql/consistency-queries/qlpack.yml
Normal file
5
cpp/ql/consistency-queries/qlpack.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
name: codeql/cpp-consistency-queries
|
||||
groups: [cpp, test, consistency-queries]
|
||||
dependencies:
|
||||
codeql/cpp-all: ${workspace}
|
||||
extractor: cpp
|
||||
10
cpp/ql/consistency-queries/unusedLocations.ql
Normal file
10
cpp/ql/consistency-queries/unusedLocations.ql
Normal 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
|
||||
@@ -0,0 +1,5 @@
|
||||
import cpp
|
||||
|
||||
from VariableDeclarationEntry i
|
||||
where not exists(i.getType())
|
||||
select i
|
||||
5
cpp/ql/consistency-queries/variablesWithoutTypes.ql
Normal file
5
cpp/ql/consistency-queries/variablesWithoutTypes.ql
Normal file
@@ -0,0 +1,5 @@
|
||||
import cpp
|
||||
|
||||
from Variable i
|
||||
where not exists(i.getType())
|
||||
select i
|
||||
6
cpp/ql/justfile
Normal file
6
cpp/ql/justfile
Normal 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
11
cpp/ql/test/justfile
Normal 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)
|
||||
Reference in New Issue
Block a user