mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
CPP: Fix the issue.
This commit is contained in:
@@ -19,7 +19,11 @@ import cpp
|
||||
|
||||
predicate functionsMissingReturnStmt(Function f, ControlFlowNode blame) {
|
||||
f.fromSource() and
|
||||
not f.getType().getUnderlyingType().getUnspecifiedType() instanceof VoidType and
|
||||
exists(Type returnType |
|
||||
returnType = f.getType().getUnderlyingType().getUnspecifiedType() and
|
||||
not returnType instanceof VoidType and
|
||||
not returnType instanceof TemplateParameter
|
||||
) and
|
||||
exists(ReturnStmt s | f.getAPredecessor() = s | blame = s.getAPredecessor())}
|
||||
|
||||
/* If a function has a value-carrying return statement, but the extractor hit a snag
|
||||
@@ -32,13 +36,11 @@ predicate functionImperfectlyExtracted(Function f) {
|
||||
exists(ErrorExpr ee | ee.getEnclosingFunction() = f)
|
||||
}
|
||||
|
||||
from Stmt stmt, string msg
|
||||
from Stmt stmt, string msg, Function f, ControlFlowNode blame
|
||||
where
|
||||
exists(Function f, ControlFlowNode blame |
|
||||
functionsMissingReturnStmt(f, blame) and
|
||||
reachable(blame) and
|
||||
not functionImperfectlyExtracted(f) and
|
||||
(blame = stmt or blame.(Expr).getEnclosingStmt() = stmt) and
|
||||
msg = "Function " + f.getName() + " should return a value of type " + f.getType().getName() + " but does not return a value here"
|
||||
)
|
||||
functionsMissingReturnStmt(f, blame) and
|
||||
reachable(blame) and
|
||||
not functionImperfectlyExtracted(f) and
|
||||
(blame = stmt or blame.(Expr).getEnclosingStmt() = stmt) and
|
||||
msg = "Function " + f.getName() + " should return a value of type " + f.getType().getName() + " but does not return a value here"
|
||||
select stmt, msg
|
||||
|
||||
Reference in New Issue
Block a user