Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 55465c3

Browse files
committed
CPP: Add some comments to the QL.
1 parent 3ccbeb0 commit 55465c3

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ class AffectedFile extends File {
2929
}
3030
}
3131

32+
/**
33+
* A block, or an element we might find textually within a block that is
34+
* not a child of it in the AST.
35+
*/
3236
class BlockOrNonChild extends Element {
3337
BlockOrNonChild() {
3438
( this instanceof Block
@@ -68,6 +72,9 @@ class BlockOrNonChild extends Element {
6872
}
6973
}
7074

75+
/**
76+
* A block that contains a non-child element.
77+
*/
7178
predicate emptyBlockContainsNonchild(Block b) {
7279
emptyBlock(_, b) and
7380
exists(BlockOrNonChild c, AffectedFile file |
@@ -78,7 +85,12 @@ predicate emptyBlockContainsNonchild(Block b) {
7885
)
7986
}
8087

88+
/**
89+
* A block that is entirely on one line, which also contains a comment. Chances
90+
* are the comment is intended to refer to the block.
91+
*/
8192
predicate lineComment(Block b) {
93+
emptyBlock(_, b) and
8294
exists(File f, int line |
8395
f = b.getFile() and
8496
line = b.getLocation().getStartLine() and

0 commit comments

Comments
 (0)