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

Skip to content

Commit 3ccbeb0

Browse files
committed
CPP: Fix issue.
1 parent 630233f commit 3ccbeb0

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,20 @@ predicate emptyBlockContainsNonchild(Block b) {
7878
)
7979
}
8080

81+
predicate lineComment(Block b) {
82+
exists(File f, int line |
83+
f = b.getFile() and
84+
line = b.getLocation().getStartLine() and
85+
line = b.getLocation().getEndLine() and
86+
exists(Comment c |
87+
c.getFile() = f and
88+
c.getLocation().getStartLine() = line
89+
)
90+
)
91+
}
92+
8193
from ControlStructure s, Block eb
8294
where emptyBlock(s, eb)
8395
and not emptyBlockContainsNonchild(eb)
96+
and not lineComment(eb)
8497
select eb, "Empty block without comment"
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
| empty_block.cpp:7:10:7:11 | { ... } | Empty block without comment |
22
| empty_block.cpp:10:10:11:3 | { ... } | Empty block without comment |
33
| empty_block.cpp:18:10:19:3 | { ... } | Empty block without comment |
4-
| empty_block.cpp:53:10:53:11 | { ... } | Empty block without comment |
5-
| empty_block.cpp:56:10:56:11 | { ... } | Empty block without comment |

0 commit comments

Comments
 (0)