Skip to content

Commit 278db14

Browse files
redsun82Copilot
andcommitted
C++: move consistency queries into the open-source repo
These queries live next to the C++ QL tests they check, so that `codeql test run --consistency-queries` can find them without an internal checkout. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 1d7c02c commit 278db14

6 files changed

Lines changed: 39 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)