Commit Graph

85 Commits

Author SHA1 Message Date
Ziemowit Laski
872054a89a [CPP-434] Narrow down query. 2019-10-08 14:12:35 -07:00
Ziemowit Laski
341dc12fc8 [CPP-434] Adjust expected output. 2019-10-08 14:12:35 -07:00
Ziemowit Laski
8c6caf2b4e [CPP-434] Rename everything to SignedOverflowCheck. Add .qlhelp. Deal with addition only, not subtraction. 2019-10-08 14:12:35 -07:00
Ziemowit Laski
c9a9aff221 [CPP-434] Expected result. 2019-10-08 14:12:35 -07:00
Ziemowit Laski
55c26a8880 [CPP-434] Initial version of query + test cases. 2019-10-08 14:12:34 -07:00
Geoffrey White
48a60651b6 CPP: Fix query. 2019-07-17 11:43:05 +01:00
Geoffrey White
aa368d8763 CPP: Add test cases. 2019-07-17 11:38:59 +01:00
Dave Bartolomeo
878cdf7cb6 C++: Fix false positive in PointlessComparison
We avoid putting a variable into SSA if its address is ever taken in a way that could allow mutation of the variable via indirection. We currently just look to see if the address is either "pointer to non-const" or "reference to non-const". However, if the address was cast to an integral type (e.g. `uintptr_t n = (uintptr_t)&x;`), we were treating it as unescaped. This change makes the conservative assumption that casting a pointer to an integer may result in the pointed-to value being modified later.

This fixes a customer-reported false positive (#2 from https://discuss.lgtm.com/t/2-false-positives-in-c-for-comparison-is-always-same/1943)
2019-04-11 01:56:22 -07:00
Jonas Jensen
ca71ac7c36 C++: Accept improved test output 2019-04-09 13:38:52 +02:00
Jonas Jensen
4b159fd2a5 C++: Fix the suppression for alerts about enums
The suppression mechanism broke when I changed `relOpWithSwap` to take
fully-converted expressions as parameters.
2019-04-03 10:45:39 +02:00
Jonas Jensen
04a48e9034 Merge remote-tracking branch 'upstream/master' into SimpleRangeAnalysis-use-after-cast 2019-04-01 09:10:57 +02:00
Jason Reed
23ee7ee928 C++: Teach range analysis to pay attention to NaNs. 2019-03-28 20:39:29 -04:00
Jonas Jensen
36ba56c690 C++: Tests for PointlessComparison shortcomings 2019-03-27 10:48:35 +01:00
Jonas Jensen
1ffeebcfea C++: Range analysis: support casts from/to typedef 2019-03-27 10:48:35 +01:00
Jonas Jensen
1c71c74ce5 C++: Tests showing problems with casts of typedefs 2019-03-27 10:48:35 +01:00
Jonas Jensen
50559d5e63 C++: Accept test output change
The new output looks correct, although I'm not sure if it's correct for
the right reasons.
2019-03-27 10:48:34 +01:00
Dave Bartolomeo
669ac2f4b4 C++: Fix FP in PointlessComparison due to preprocessor
Reported by an LGTM customer here: https://discuss.lgtm.com/t/2-false-positives-in-c-for-comparison-is-always-same/1943.

Even though the comparison is pointless in the preprocessor configuration in effect during extraction, it is not pointless in other preprocessor configurations. Similar to ExprHasNoEffect, we'll now exclude results in functions that contain preprocessor-excluded code. I factored the similar code already used in ExprHasNoEffect in a non-recursive version into Preprocessor.qll, leaving the recursive version in ExprHasNoEffect.ql. I believe the recursive version is too aggressive for PointerlessComparison, which does no interprocedural analysis.
2019-03-25 16:19:18 -07:00
Jonas Jensen
cc28d04ba7 Merge pull request #405 from geoffw0/selfcompare
CPP: Fix false positives in PointlessSelfComparison.ql
2018-11-20 09:25:10 +01:00
Geoffrey White
33130b9800 CPP: Apply recommended fix. 2018-11-19 14:39:28 +00:00
Geoffrey White
6a14748af8 CPP: Add recommended test. 2018-11-19 14:25:11 +00:00
Geoffrey White
2d665e51d0 CPP: Move the BitwiseSignCheck.ql test. 2018-11-12 16:07:03 +00:00
Jonas Jensen
4a02b3946d C++: Tests for two range analysis bugs 2018-11-06 11:57:41 +01:00
Geoffrey White
3cb4211c78 CPP: Exclude code in macro invocations. 2018-11-05 15:07:22 +00:00
Geoffrey White
b4adfec2ef CPP: Add test case. 2018-11-05 14:19:16 +00:00
Jonas Jensen
006594fefe C++: Round towards +/- Inf in range analysis
Original author: Kevin Backhouse
2018-10-26 11:53:51 +02:00
Jonas Jensen
354f8bd0ff C++: Test of range analysis 64-bit rounding issue 2018-10-25 16:18:22 +02:00
Jonas Jensen
a10c3bcffb C++: Suppress UnsignedGEZero in template inst.
It still runs on uninstantiated templates because its underlying
libraries do. It's not clear whether that leads to other false
positives, but that's independent of the change I'm making here.
2018-10-10 17:06:24 +02:00
Jonas Jensen
383dafac5c C++: Test for UnsignedGEZero with templates 2018-10-10 17:04:35 +02:00
Jonas Jensen
364c9a6961 C++: Suppress pointless compare in template inst.
It still runs on uninstantiated templates because its underlying
libraries do. It's not clear whether that leads to other false
positives, but that's independent of the change I'm making here.
2018-10-03 14:48:11 +02:00
Jonas Jensen
2eea359f79 C++: Test for PointlessComparison with templates 2018-10-03 14:47:00 +02:00
Jonas Jensen
4d2e4c53f1 C++: Suppress IntMultToLong alert on char 2018-09-24 14:37:09 +02:00
Jonas Jensen
2b5d150829 C++: Test for IntMultToLong on char-typed numbers 2018-09-24 14:36:36 +02:00
Nick Rolfe
f2d030a7e6 C++: shorten message in integer-multiplication-cast-to-long 2018-09-04 14:45:12 +01:00
Nick Rolfe
04e919df9d C++: clearer alert wording in integer-multiplication-cast-to-long 2018-09-03 16:56:56 +01:00
Pavel Avgustinov
b55526aa58 QL code and tests for C#/C++/JavaScript. 2018-08-02 17:53:23 +01:00