CPP: Tag LossyFunctionResultCast.ql. Will be run on LGTM.

This commit is contained in:
Geoffrey White
2018-11-08 17:28:50 +00:00
parent bd9a2d71ba
commit 0e092ae88d

View File

@@ -1,10 +1,12 @@
/**
* @name Lossy function result cast
* @description Finds function calls whose result type is a floating point type, and which are casted to an integral type.
* Includes only expressions with implicit cast and excludes function calls to ceil, floor and round. {This is a gcc check; doesn't seem wildly useful.}
* Includes only expressions with implicit cast and excludes function calls to ceil, floor and round.
* @kind problem
* @id cpp/lossy-function-result-cast
* @problem.severity warning
* @precision medium
* @tags correctness
*/
import cpp
@@ -15,4 +17,4 @@ where t1 = c.getTarget().getType().getUnderlyingType() and
not c.getTarget().getName() = "ceil" and
not c.getTarget().getName() = "floor" and
not c.getTarget().getName() = "round"
select c
select c, "Return value of type " + t1.toString() + " is implicitly converted to " + t2.toString() + " here."