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:
Jonas Jensen
2019-09-05 15:35:00 +02:00
parent 1784122929
commit 4ef5c9af62
1141 changed files with 21968 additions and 23174 deletions

View File

@@ -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(), ", ")

View File

@@ -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(), ", ")

View File

@@ -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(), ", ")

View File

@@ -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()

View File

@@ -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

View File

@@ -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

View 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 }
}

View File

@@ -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(), ", ")

View File

@@ -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)
)
}

View File

@@ -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

View File

@@ -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