Skip to content

Commit 9de1fb7

Browse files
authored
Merge pull request #4222 from jbj/BlockStmt
C++/Java/JS: Rename Block -> BlockStmt
2 parents 9879c6c + f92f84e commit 9de1fb7

File tree

75 files changed

+474
-437
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+474
-437
lines changed

change-notes/1.26/analysis-cpp.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The following changes in version 1.26 affect C/C++ analysis in all applications.
2020

2121
## Changes to libraries
2222

23+
* The QL class `Block`, denoting the `{ ... }` statement, is renamed to `BlockStmt`.
2324
* The models library now models many taint flows through `std::array`, `std::vector`, `std::deque`, `std::list` and `std::forward_list`.
2425
* The models library now models many more taint flows through `std::string`.
2526
* The `SimpleRangeAnalysis` library now supports multiplications of the form

change-notes/1.26/analysis-java.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Improvements to Java analysis
2+
3+
The following changes in version 1.26 affect Java analysis in all applications.
4+
5+
## General improvements
6+
7+
## New queries
8+
9+
| **Query** | **Tags** | **Purpose** |
10+
|-----------------------------|-----------|--------------------------------------------------------------------|
11+
12+
13+
## Changes to existing queries
14+
15+
| **Query** | **Expected impact** | **Change** |
16+
|------------------------------|------------------------|-----------------------------------|
17+
18+
19+
## Changes to libraries
20+
21+
* The QL class `Block`, denoting the `{ ... }` statement, is renamed to `BlockStmt`.

cpp/ql/examples/snippets/emptyblock.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99

1010
import cpp
1111

12-
from Block blk
12+
from BlockStmt blk
1313
where blk.getNumStmt() = 0
1414
select blk

cpp/ql/examples/snippets/emptythen.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
import cpp
1414

1515
from IfStmt i
16-
where i.getThen().(Block).getNumStmt() = 0
16+
where i.getThen().(BlockStmt).getNumStmt() = 0
1717
select i

cpp/ql/examples/snippets/singletonblock.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88

99
import cpp
1010

11-
from Block b
11+
from BlockStmt b
1212
where b.getNumStmt() = 1
1313
select b

cpp/ql/src/Best Practices/BlockWithTooManyStatements.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import cpp
1414

1515
class ComplexStmt extends Stmt {
1616
ComplexStmt() {
17-
exists(Block body |
17+
exists(BlockStmt body |
1818
body = this.(Loop).getStmt() or
1919
body = this.(SwitchStmt).getStmt()
2020
|
@@ -24,7 +24,7 @@ class ComplexStmt extends Stmt {
2424
}
2525
}
2626

27-
from Block b, int n, ComplexStmt complexStmt
27+
from BlockStmt b, int n, ComplexStmt complexStmt
2828
where
2929
n = strictcount(ComplexStmt s | s = b.getAStmt()) and
3030
n > 3 and

cpp/ql/src/Best Practices/Hiding/DeclarationHidesVariable.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ where
1717
shadowing(lv1, lv2) and
1818
not lv1.isCompilerGenerated() and
1919
not lv2.isCompilerGenerated() and
20-
not lv1.getParentScope().(Block).isInMacroExpansion() and
21-
not lv2.getParentScope().(Block).isInMacroExpansion()
20+
not lv1.getParentScope().(BlockStmt).isInMacroExpansion() and
21+
not lv2.getParentScope().(BlockStmt).isInMacroExpansion()
2222
select lv1, "Variable " + lv1.getName() + " hides another variable of the same name (on $@).", lv2,
2323
"line " + lv2.getLocation().getStartLine().toString()

cpp/ql/src/Best Practices/Likely Errors/EmptyBlock.ql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import cpp
1616

17-
predicate emptyBlock(ControlStructure s, Block b) {
17+
predicate emptyBlock(ControlStructure s, BlockStmt b) {
1818
b = s.getAChild() and
1919
not exists(b.getAChild()) and
2020
not b.isInMacroExpansion() and
@@ -23,7 +23,7 @@ predicate emptyBlock(ControlStructure s, Block b) {
2323

2424
class AffectedFile extends File {
2525
AffectedFile() {
26-
exists(Block b |
26+
exists(BlockStmt b |
2727
emptyBlock(_, b) and
2828
this = b.getFile()
2929
)
@@ -37,7 +37,7 @@ class AffectedFile extends File {
3737
class BlockOrNonChild extends Element {
3838
BlockOrNonChild() {
3939
(
40-
this instanceof Block
40+
this instanceof BlockStmt
4141
or
4242
this instanceof Comment
4343
or
@@ -78,7 +78,7 @@ class BlockOrNonChild extends Element {
7878
/**
7979
* A block that contains a non-child element.
8080
*/
81-
predicate emptyBlockContainsNonchild(Block b) {
81+
predicate emptyBlockContainsNonchild(BlockStmt b) {
8282
emptyBlock(_, b) and
8383
exists(BlockOrNonChild c, AffectedFile file |
8484
c.(BlockOrNonChild).getStartRankIn(file) = 1 + b.(BlockOrNonChild).getStartRankIn(file) and
@@ -91,7 +91,7 @@ predicate emptyBlockContainsNonchild(Block b) {
9191
* A block that is entirely on one line, which also contains a comment. Chances
9292
* are the comment is intended to refer to the block.
9393
*/
94-
predicate lineComment(Block b) {
94+
predicate lineComment(BlockStmt b) {
9595
emptyBlock(_, b) and
9696
exists(Location bLocation, File f, int line |
9797
bLocation = b.getLocation() and
@@ -106,7 +106,7 @@ predicate lineComment(Block b) {
106106
)
107107
}
108108

109-
from ControlStructure s, Block eb
109+
from ControlStructure s, BlockStmt eb
110110
where
111111
emptyBlock(s, eb) and
112112
not emptyBlockContainsNonchild(eb) and

cpp/ql/src/Critical/DeadCodeGoto.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
import cpp
1313
import semmle.code.cpp.commons.Exclusions
1414

15-
Stmt getNextRealStmt(Block b, int i) {
15+
Stmt getNextRealStmt(BlockStmt b, int i) {
1616
result = b.getStmt(i + 1) and
1717
not result instanceof EmptyStmt
1818
or
1919
b.getStmt(i + 1) instanceof EmptyStmt and
2020
result = getNextRealStmt(b, i + 1)
2121
}
2222

23-
from JumpStmt js, Block b, int i, Stmt s
23+
from JumpStmt js, BlockStmt b, int i, Stmt s
2424
where
2525
b.getStmt(i) = js and
2626
s = getNextRealStmt(b, i) and

cpp/ql/src/JPL_C/LOC-4/Rule 21/MacroInBlock.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import cpp
1313

1414
int lineInBlock(File f) {
15-
exists(Block block, Location blockLocation |
15+
exists(BlockStmt block, Location blockLocation |
1616
block.getFile() = f and blockLocation = block.getLocation()
1717
|
1818
result in [blockLocation.getStartLine() .. blockLocation.getEndLine()]

0 commit comments

Comments
 (0)