mirror of
https://github.com/github/codeql.git
synced 2025-12-20 10:46:30 +01:00
C++: Implement Expr::mayBeFromImplicitlyDeclaredFunction
This commit is contained in:
@@ -300,6 +300,11 @@ class FunctionCall extends Call, @funbindexpr {
|
||||
this.isVirtual() or
|
||||
this.getTarget().getAnAttribute().getName() = "weak"
|
||||
}
|
||||
|
||||
override predicate mayBeFromImplicitlyDeclaredFunction() {
|
||||
this.getType() instanceof IntType and
|
||||
this.getTarget().getADeclarationEntry().isImplicit()
|
||||
}
|
||||
}
|
||||
|
||||
/** A _user-defined_ unary `operator*` function. */
|
||||
|
||||
@@ -534,6 +534,9 @@ class Expr extends StmtParent, @expr {
|
||||
|
||||
/** Gets the function containing this control-flow node. */
|
||||
override Function getControlFlowScope() { result = this.getEnclosingFunction() }
|
||||
|
||||
/** Holds if this expression could be the return value of an implicitly declared function. */
|
||||
predicate mayBeFromImplicitlyDeclaredFunction() { none() }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -171,7 +171,7 @@ where
|
||||
not arg.isAffectedByMacro() and
|
||||
not arg.isFromUninstantiatedTemplate(_) and
|
||||
not actual.getUnspecifiedType() instanceof ErroneousType and
|
||||
not arg.(Call).getTarget().getADeclarationEntry().isImplicit()
|
||||
not arg.mayBeFromImplicitlyDeclaredFunction()
|
||||
select arg,
|
||||
"This format specifier for type '" + expected.getName() + "' does not match the argument type '" +
|
||||
actual.getUnspecifiedType().getName() + "'."
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
| file://:0:0:0:0 | <error expr> |
|
||||
@@ -0,0 +1,5 @@
|
||||
import cpp
|
||||
|
||||
from Expr e
|
||||
where e.getType() instanceof ErroneousType
|
||||
select e
|
||||
@@ -0,0 +1,2 @@
|
||||
| file://:0:0:0:0 | There was an error during this compilation |
|
||||
| implicit.cpp:5:5:5:5 | identifier 'g' is undefined |
|
||||
@@ -0,0 +1,4 @@
|
||||
import cpp
|
||||
|
||||
from Diagnostic d
|
||||
select d
|
||||
@@ -0,0 +1,4 @@
|
||||
void f() {
|
||||
f();
|
||||
g();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// semmle-extractor-options: --expect_errors
|
||||
|
||||
void f() {
|
||||
f();
|
||||
g();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
| implicit.c:3:5:3:5 | call to g |
|
||||
@@ -0,0 +1,5 @@
|
||||
import cpp
|
||||
|
||||
from Expr e
|
||||
where e.mayBeFromImplicitlyDeclaredFunction()
|
||||
select e
|
||||
Reference in New Issue
Block a user