mirror of
https://github.com/github/codeql.git
synced 2026-05-02 20:25:13 +02:00
C++: Autoformat everything
Some files that will change in #1736 have been spared. ./build -j4 target/jars/qlformat find ql/cpp/ql -name "*.ql" -print0 | xargs -0 target/jars/qlformat --input find ql/cpp/ql -name "*.qll" -print0 | xargs -0 target/jars/qlformat --input (cd ql && git checkout 'cpp/ql/src/semmle/code/cpp/ir/implementation/**/*SSA*.qll') buildutils-internal/scripts/pr-checks/sync-identical-files.py --latest
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
import cpp
|
||||
|
||||
from FormattingFunction f
|
||||
select
|
||||
f,
|
||||
concat(f.getFormatCharType().toString(), ", "),
|
||||
select f, concat(f.getFormatCharType().toString(), ", "),
|
||||
concat(f.getDefaultCharType().toString(), ", "),
|
||||
concat(f.getNonDefaultCharType().toString(), ", "),
|
||||
concat(f.getWideCharType().toString(), ", ")
|
||||
concat(f.getNonDefaultCharType().toString(), ", "), concat(f.getWideCharType().toString(), ", ")
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import cpp
|
||||
|
||||
from FormattingFunction f
|
||||
select
|
||||
f,
|
||||
concat(f.getDefaultCharType().toString(), ", "),
|
||||
concat(f.getNonDefaultCharType().toString(), ", "),
|
||||
concat(f.getWideCharType().toString(), ", ")
|
||||
select f, concat(f.getDefaultCharType().toString(), ", "),
|
||||
concat(f.getNonDefaultCharType().toString(), ", "), concat(f.getWideCharType().toString(), ", ")
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import cpp
|
||||
|
||||
from FormattingFunction f
|
||||
select
|
||||
f,
|
||||
concat(f.getDefaultCharType().toString(), ", "),
|
||||
concat(f.getNonDefaultCharType().toString(), ", "),
|
||||
concat(f.getWideCharType().toString(), ", ")
|
||||
select f, concat(f.getDefaultCharType().toString(), ", "),
|
||||
concat(f.getNonDefaultCharType().toString(), ", "), concat(f.getWideCharType().toString(), ", ")
|
||||
|
||||
@@ -5,10 +5,7 @@ import cpp
|
||||
// StackAddressEscapes.ql, so the purpose of this test is to make
|
||||
// sure that the types behave in the way that we expect.
|
||||
from ArrayExpr arrayExpr
|
||||
select
|
||||
arrayExpr,
|
||||
arrayExpr.getArrayBase().getUnspecifiedType().toString() +
|
||||
", " +
|
||||
arrayExpr.getArrayBase().getFullyConverted().getUnspecifiedType().toString() +
|
||||
", " +
|
||||
arrayExpr.getUnspecifiedType().toString()
|
||||
select arrayExpr,
|
||||
arrayExpr.getArrayBase().getUnspecifiedType().toString() + ", " +
|
||||
arrayExpr.getArrayBase().getFullyConverted().getUnspecifiedType().toString() + ", " +
|
||||
arrayExpr.getUnspecifiedType().toString()
|
||||
|
||||
@@ -2,8 +2,5 @@ import TestPackage
|
||||
|
||||
// this is a copy of the body of ExternalDependencies.ql
|
||||
from File file, int num, string encodedDependency
|
||||
where
|
||||
encodedDependencies(file, encodedDependency, num)
|
||||
select
|
||||
encodedDependency, num
|
||||
order by num desc
|
||||
where encodedDependencies(file, encodedDependency, num)
|
||||
select encodedDependency, num order by num desc
|
||||
|
||||
@@ -9,8 +9,7 @@ import TestPackage
|
||||
* recover that information once we are in the dashboard database, using the
|
||||
* ExternalEntity.getASourceLink() method.
|
||||
*/
|
||||
|
||||
from File file, int num, string encodedDependency
|
||||
where
|
||||
encodedDependencies(file, encodedDependency, num)
|
||||
select
|
||||
encodedDependency, file
|
||||
where encodedDependencies(file, encodedDependency, num)
|
||||
select encodedDependency, file
|
||||
|
||||
@@ -4,19 +4,11 @@ import Metrics.Dependencies.ExternalDependencies
|
||||
* Count directories as libraries for testing purposes.
|
||||
*/
|
||||
class TestPackage extends LibraryElement {
|
||||
TestPackage() {
|
||||
this instanceof Folder
|
||||
}
|
||||
TestPackage() { this instanceof Folder }
|
||||
|
||||
override string getName() {
|
||||
result = this.(Folder).getBaseName()
|
||||
}
|
||||
override string getName() { result = this.(Folder).getBaseName() }
|
||||
|
||||
override string getVersion() {
|
||||
result = "1.0"
|
||||
}
|
||||
override string getVersion() { result = "1.0" }
|
||||
|
||||
override File getAFile() {
|
||||
result.getParentContainer() = this
|
||||
}
|
||||
override File getAFile() { result.getParentContainer() = this }
|
||||
}
|
||||
|
||||
@@ -2,12 +2,9 @@ import cpp
|
||||
import LoopConditionsConst
|
||||
|
||||
from Loop l, Expr condition
|
||||
where
|
||||
l.getCondition() = condition
|
||||
select
|
||||
l, condition,
|
||||
concat(int val | loopEntryConst(condition, val) | val.toString(), ", "),
|
||||
concat(BasicBlock bb | bb.getASuccessor() = l.getStmt() | bb.toString(), ", "),
|
||||
concat(l.getStmt().toString(), ", "),
|
||||
concat(BasicBlock bb | bb.getASuccessor() = l.getFollowingStmt() | bb.toString(), ", "),
|
||||
concat(l.getFollowingStmt().toString(), ", ")
|
||||
where l.getCondition() = condition
|
||||
select l, condition, concat(int val | loopEntryConst(condition, val) | val.toString(), ", "),
|
||||
concat(BasicBlock bb | bb.getASuccessor() = l.getStmt() | bb.toString(), ", "),
|
||||
concat(l.getStmt().toString(), ", "),
|
||||
concat(BasicBlock bb | bb.getASuccessor() = l.getFollowingStmt() | bb.toString(), ", "),
|
||||
concat(l.getFollowingStmt().toString(), ", ")
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import cpp
|
||||
import semmle.code.cpp.controlflow.internal.ConstantExprs
|
||||
|
||||
predicate loopEntryConst(Expr condition, int val)
|
||||
{
|
||||
exists(LoopEntryConditionEvaluator x, ControlFlowNode loop |
|
||||
x.isLoopEntry(condition, loop) and
|
||||
val = x.getValue(condition)
|
||||
)
|
||||
predicate loopEntryConst(Expr condition, int val) {
|
||||
exists(LoopEntryConditionEvaluator x, ControlFlowNode loop |
|
||||
x.isLoopEntry(condition, loop) and
|
||||
val = x.getValue(condition)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4,18 +4,14 @@ import definitions
|
||||
* An element that is the source of a jump-to-definition link.
|
||||
*/
|
||||
class Link extends Top {
|
||||
Link() {
|
||||
exists(definitionOf(this, _))
|
||||
}
|
||||
Link() { exists(definitionOf(this, _)) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the length of the longest line in file `f`.
|
||||
*/
|
||||
pragma[nomagic]
|
||||
private int maxCols(File f) {
|
||||
result = max(Location l | l.getFile() = f | l.getEndColumn())
|
||||
}
|
||||
private int maxCols(File f) { result = max(Location l | l.getFile() = f | l.getEndColumn()) }
|
||||
|
||||
/**
|
||||
* Gets the location of an element that has a link-to-definition (in a similar manner to
|
||||
@@ -35,22 +31,18 @@ predicate linkLocationInfo(Link e, string filepath, int begin, int end) {
|
||||
* Gets a string describing a problem with a `Link`.
|
||||
*/
|
||||
string issues(Link e) {
|
||||
(
|
||||
strictcount(Top def |
|
||||
def = definitionOf(e, _)
|
||||
) > 1 and
|
||||
result = "has more than one definition"
|
||||
) or (
|
||||
exists(string filepath1, int begin1, int end1, Link e2, string filepath2, int begin2, int end2 |
|
||||
linkLocationInfo(e, filepath1, begin1, end1) and
|
||||
linkLocationInfo(e2, filepath2, begin2, end2) and
|
||||
filepath1 = filepath2 and
|
||||
not end1 < begin2 and
|
||||
not begin1 > end2 and
|
||||
e != e2
|
||||
) and
|
||||
result = "overlaps another link"
|
||||
)
|
||||
strictcount(Top def | def = definitionOf(e, _)) > 1 and
|
||||
result = "has more than one definition"
|
||||
or
|
||||
exists(string filepath1, int begin1, int end1, Link e2, string filepath2, int begin2, int end2 |
|
||||
linkLocationInfo(e, filepath1, begin1, end1) and
|
||||
linkLocationInfo(e2, filepath2, begin2, end2) and
|
||||
filepath1 = filepath2 and
|
||||
not end1 < begin2 and
|
||||
not begin1 > end2 and
|
||||
e != e2
|
||||
) and
|
||||
result = "overlaps another link"
|
||||
}
|
||||
|
||||
from Link e
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import cpp
|
||||
|
||||
string describe(File f) {
|
||||
(
|
||||
f instanceof CFile and
|
||||
result = "CFile"
|
||||
) or (
|
||||
f instanceof CppFile and
|
||||
result = "CppFile"
|
||||
) or (
|
||||
f instanceof HeaderFile and
|
||||
result = "HeaderFile"
|
||||
)
|
||||
f instanceof CFile and
|
||||
result = "CFile"
|
||||
or
|
||||
f instanceof CppFile and
|
||||
result = "CppFile"
|
||||
or
|
||||
f instanceof HeaderFile and
|
||||
result = "HeaderFile"
|
||||
}
|
||||
|
||||
from File f
|
||||
|
||||
Reference in New Issue
Block a user