зеркало из https://github.com/github/codeql.git
C++: Don't report results in files with compilation errors.
This commit is contained in:
Родитель
c599b02e98
Коммит
2756c0e7af
|
@ -14,15 +14,28 @@
|
|||
import cpp
|
||||
|
||||
predicate immediatelyReachableFunction(Function f) {
|
||||
not f.isStatic() or
|
||||
exists(BlockExpr be | be.getFunction() = f) or
|
||||
f instanceof MemberFunction or
|
||||
f instanceof TemplateFunction or
|
||||
f.getFile() instanceof HeaderFile or
|
||||
f.getAnAttribute().hasName("constructor") or
|
||||
f.getAnAttribute().hasName("destructor") or
|
||||
f.getAnAttribute().hasName("used") or
|
||||
not f.isStatic()
|
||||
or
|
||||
exists(BlockExpr be | be.getFunction() = f)
|
||||
or
|
||||
f instanceof MemberFunction
|
||||
or
|
||||
f instanceof TemplateFunction
|
||||
or
|
||||
f.getFile() instanceof HeaderFile
|
||||
or
|
||||
f.getAnAttribute().hasName("constructor")
|
||||
or
|
||||
f.getAnAttribute().hasName("destructor")
|
||||
or
|
||||
f.getAnAttribute().hasName("used")
|
||||
or
|
||||
f.getAnAttribute().hasName("unused")
|
||||
or
|
||||
// a compiler error in the same file suggests we may be missing data
|
||||
exists(Diagnostic d | d.getFile() = f.getFile() and d.getSeverity() >= 3)
|
||||
or
|
||||
exists(ErrorExpr ee | ee.getFile() = f.getFile())
|
||||
}
|
||||
|
||||
predicate immediatelyReachableVariable(Variable v) {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
| extraction_error.c:4:13:4:43 | my_function2_called_after_error | Static function my_function2_called_after_error is unreachable | extraction_error.c:4:13:4:43 | my_function2_called_after_error | my_function2_called_after_error |
|
||||
| extraction_error.c:5:13:5:35 | my_function3_not_called | Static function my_function3_not_called is unreachable | extraction_error.c:5:13:5:35 | my_function3_not_called | my_function3_not_called |
|
||||
| unused_functions.c:16:13:16:27 | unused_function | Static function unused_function is unreachable | unused_functions.c:16:13:16:27 | unused_function | unused_function |
|
||||
| unused_functions.c:20:13:20:28 | unused_function2 | Static function unused_function2 is unreachable ($@ must be removed at the same time) | unused_functions.c:24:13:24:28 | unused_function3 | unused_function3 |
|
||||
| unused_functions.c:24:13:24:28 | unused_function3 | Static function unused_function3 is unreachable | unused_functions.c:24:13:24:28 | unused_function3 | unused_function3 |
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// semmle-extractor-options: --expect_errors
|
||||
|
||||
static void my_function1_called() {} // GOOD
|
||||
static void my_function2_called_after_error() {} // GOOD [FALSE POSITIVE]
|
||||
static void my_function3_not_called() {} // BAD
|
||||
static void my_function2_called_after_error() {} // GOOD
|
||||
static void my_function3_not_called() {} // BAD [NOT DETECTED]
|
||||
|
||||
int main(void) {
|
||||
my_function1_called();
|
||||
|
|
Загрузка…
Ссылка в новой задаче