@@ -19,7 +19,11 @@ import cpp
1919
2020predicate functionsMissingReturnStmt ( Function f , ControlFlowNode blame ) {
2121 f .fromSource ( ) and
22- not f .getType ( ) .getUnderlyingType ( ) .getUnspecifiedType ( ) instanceof VoidType and
22+ exists ( Type returnType |
23+ returnType = f .getType ( ) .getUnderlyingType ( ) .getUnspecifiedType ( ) and
24+ not returnType instanceof VoidType and
25+ not returnType instanceof TemplateParameter
26+ ) and
2327 exists ( ReturnStmt s | f .getAPredecessor ( ) = s | blame = s .getAPredecessor ( ) ) }
2428
2529/* If a function has a value-carrying return statement, but the extractor hit a snag
@@ -32,13 +36,11 @@ predicate functionImperfectlyExtracted(Function f) {
3236 exists ( ErrorExpr ee | ee .getEnclosingFunction ( ) = f )
3337}
3438
35- from Stmt stmt , string msg
39+ from Stmt stmt , string msg , Function f , ControlFlowNode blame
3640where
37- exists ( Function f , ControlFlowNode blame |
38- functionsMissingReturnStmt ( f , blame ) and
39- reachable ( blame ) and
40- not functionImperfectlyExtracted ( f ) and
41- ( blame = stmt or blame .( Expr ) .getEnclosingStmt ( ) = stmt ) and
42- msg = "Function " + f .getName ( ) + " should return a value of type " + f .getType ( ) .getName ( ) + " but does not return a value here"
43- )
41+ functionsMissingReturnStmt ( f , blame ) and
42+ reachable ( blame ) and
43+ not functionImperfectlyExtracted ( f ) and
44+ ( blame = stmt or blame .( Expr ) .getEnclosingStmt ( ) = stmt ) and
45+ msg = "Function " + f .getName ( ) + " should return a value of type " + f .getType ( ) .getName ( ) + " but does not return a value here"
4446select stmt , msg
0 commit comments