Commit Graph

11909 Commits

Author SHA1 Message Date
Dave Bartolomeo
66381e89ef C++: Add comment from PR feedback 2020-04-22 08:11:43 -04:00
Dave Bartolomeo
4b44afef90 C++: Accept syntax-zoo test output 2020-04-21 09:42:24 -04:00
Dave Bartolomeo
fee557001e C++: Update SignAnalysis test results 2020-04-21 09:34:44 -04:00
Dave Bartolomeo
1428811f75 C++: IR translation for binary conditional operator
IR generation was not handling the special two-operand flavor of the `?:` operator that GCC supports as an extension. The extractor doesn't quite give us enough information to do this correctly (see github/codeql-c-extractor-team#67), but we can get pretty close.

About half of the code could be shared between the two-operand and three-operand flavors. The main differences for the two-operand flavor are:
1. The "then" operand isn't a child of the `ConditionalExpr`. Instead, we just reuse the original value of the "condition" operand, skipping any implicit cast to `bool` (see comment for rationale).
2. For the three-operand flavor, we generate the condition as control flow rather than the computation of a `bool` value, to avoid creating unnecessarily complicated branching. For the two-operand version, we just compute the value, since we have to reuse that value in the "then" branch anyway.

I've added IR tests for these new cases. I've also updated the expectations for `SignAnalysis.ql` based on the fix. @rdmarsh2, can you please double-check that these diffs look correct? I believe they do, but you're the range/sign analysis expert.
2020-04-21 02:05:21 -04:00
Jonas Jensen
875daae84b Merge pull request #3151 from dbartol/dbartol/floats
C++: Better support for complex numbers in IR and AST
2020-04-20 16:27:20 +02:00
semmle-qlci
e965e5c73e Merge pull request #3094 from erik-krogh/Mispelled
Approved by esbena
2020-04-20 11:41:23 +01:00
Calum Grant
eb1474acee Merge pull request #3276 from hvitved/csharp/dataflow/array-tests
C#: Add data-flow test for collections
2020-04-20 11:36:17 +01:00
Erik Krogh Kristensen
c713ba7bfe fix typo 2020-04-20 10:51:42 +02:00
Tom Hvitved
e186c9ddd1 C#: Update data-flow collection test method names 2020-04-20 09:29:51 +02:00
Tom Hvitved
161093bd57 C#: Rename arrays data-flow test to collections 2020-04-20 09:20:42 +02:00
Erik Krogh Kristensen
2632699397 Merge branch 'master' of git.semmle.com:Semmle/ql into Mispelled 2020-04-18 17:58:57 +02:00
Dave Bartolomeo
8041b74f1c C++: Fix formatting 2020-04-18 09:56:38 -04:00
Dave Bartolomeo
de5abdb29a C++/C#: Add missing QLDoc 2020-04-18 09:55:35 -04:00
semmle-qlci
243dea706e Merge pull request #3269 from erik-krogh/Promisify
Approved by esbena
2020-04-18 13:02:42 +01:00
Robert Marsh
9008084b74 Merge pull request #3272 from dbartol/dbartol/DumpFixes
C++: A couple of fixes for IR dumps
2020-04-17 11:49:52 -07:00
Jonas Jensen
8ca6c57eef Merge pull request #3118 from MathiasVP/ir-flow-fields
C++: IR field flow
2020-04-17 15:49:19 +02:00
Erik Krogh Kristensen
cffa911661 retarget change note for 1.25 2020-04-17 14:22:57 +02:00
Erik Krogh Kristensen
a2ddf7bf8f retarget change-note for 1.25 2020-04-17 14:19:17 +02:00
Erik Krogh Kristensen
88f600fa34 more -> additional
Co-Authored-By: Esben Sparre Andreasen <esbena@github.com>
2020-04-17 14:14:08 +02:00
Mathias Vorreiter Pedersen
ba0429cf01 Merge branch 'master' into ir-flow-fields 2020-04-17 13:57:12 +02:00
Erik Krogh Kristensen
225dc4b017 change-note 2020-04-17 13:54:48 +02:00
Chris Gavin
e974006122 Merge pull request #3283 from jbj/mergeback-2020-04-17
Mergeback rc/1.24 -> master
2020-04-17 12:11:22 +01:00
Erik Krogh Kristensen
e72eed1db5 more -> additional
Co-Authored-By: Esben Sparre Andreasen <esbena@github.com>
2020-04-17 13:10:06 +02:00
Mathias Vorreiter Pedersen
8c03423f3e C++: Accept test output 2020-04-17 12:03:16 +02:00
Erik Krogh Kristensen
4a93b91d59 make maybePromisified private 2020-04-17 11:47:03 +02:00
Erik Krogh Kristensen
3b230648d2 change-note 2020-04-17 11:45:08 +02:00
Erik Krogh Kristensen
4f32157a78 rename func to callback
Co-Authored-By: Esben Sparre Andreasen <esbena@github.com>
2020-04-17 11:36:48 +02:00
Erik Krogh Kristensen
427c32f211 report a local variable as the misspelling if there any many occourances of the global 2020-04-17 11:25:23 +02:00
Tom Hvitved
c36142f129 C#: Add data-flow test for collections 2020-04-17 11:22:01 +02:00
Jonas Jensen
c970e8a52e Merge remote-tracking branch 'upstream/rc/1.24' into mergeback-2020-04-17 2020-04-17 10:42:27 +02:00
Erik Krogh Kristensen
eca98b42d2 basic support for util.promisify for NodeJSFileSystemAccess 2020-04-17 09:54:37 +02:00
Erik Krogh Kristensen
ea0f6a367d refactor into maybePromisified predicate 2020-04-17 09:50:08 +02:00
Dave Bartolomeo
c705797a2d C++: IR construction for _Imaginary types
Includes a fairly exhaustive test case for arithmetic operations involving `_Complex` and/or `_Imaginary` types. Thanks to these new tests, I discovered that the extractor treats certain arithmetic operations on `_Imaginary` types as separate expression kinds, so I added support for those kinds in IR construction.
2020-04-16 11:58:09 -04:00
Mathias Vorreiter Pedersen
62e2ffe623 C++: Make PartialDefinitionNode private and add/update comments based on review comments 2020-04-16 17:19:12 +02:00
Dave Bartolomeo
3dd3b5304e Merge remote-tracking branch 'upstream/master' into dbartol/floats 2020-04-16 08:44:41 -04:00
Taus
964a619450 Merge pull request #3211 from RasmusWL/python-unused-import-small-fix
Python: Fix FN in unused import
2020-04-16 14:22:50 +02:00
Taus
a92d926b56 Merge pull request #3218 from RasmusWL/python-add-missing-override
Python: Add missing override to ClassValue.hasAttribute
2020-04-16 14:06:23 +02:00
Tom Hvitved
922e52f061 Merge pull request #3257 from hvitved/csharp/dataflow/tests
C#: Update data flow tests
2020-04-16 11:47:45 +02:00
Dave Bartolomeo
2264ec714f C++: Better type preservation in getVariableType()
`getVariableType()` is used to compute the actual semantic type of a variable from its declared type. That's where we handle pointer and function decay for parameters, and it's also where we handle arrays of unknown bound initialized with an initializer of known bound.

Previously, even if neither of the above situations applied, the type that we returned was the `getUnspecifiedType()` of the variable. This meant that, for example, `const char* p` would be treated as `char *`. This is inconsistent with how we handle types elsewhere in IR construction, where we preserve typedefs and cv-qualifiers when creating the `CppType` of an `IRVariable`, `Instruction`, or `Operand`.

The only visible effect this fix has is to fix the inferred result type for `Phi` instructions for variables affect by this change in `getVariableType()` behavior. Previously, we would see the variable accessed as both `const char*` and as `char*`, so we'd fall back to the canonical pointer type, which is `decltype(nullptr)`. Now, we see the same type for all accesses to the variable, so we use that type as the type of the SSA memory location and as the result type of the `Phi` instruction.
2020-04-15 18:41:24 -04:00
Dave Bartolomeo
90dc14c56e C++/C#: Fix phantom Chi definitions in PrintSSA
When `PrintSSA.qll` is imported, IR dumps will be annotated with the alias analysis information used during SSA construction. When printing this information, we incorrectly treated instructions at offset -1, which should only be `Phi` instructions, as `Chi` instructions for the instruction at offset 0. This produced phantom annotations, but did not affect the correctness of the actual IR.
2020-04-15 18:24:11 -04:00
Mathias Vorreiter Pedersen
86ba03bea8 Merge pull request #3256 from Semmle/rdmarsh/cpp/add-qldoc-1
C++: Add QLdoc to some AST methods (Class.qll-Diagnostics.qll)
2020-04-15 21:46:36 +02:00
Erik Krogh Kristensen
e8dc77d508 add support for util.promisify with child_process calls 2020-04-15 19:16:30 +02:00
Rasmus Wriedt Larsen
5a51d2cc4c Merge pull request #3245 from BekaValentine/python-objectapi-to-valueapi-wrongnameforargumentinclassinstantiation
Python: ObjectAPI to ValueAPI: WrongNameForArgumentInClassInstantiation
2020-04-15 16:48:26 +02:00
Rasmus Wriedt Larsen
390959713a Merge pull request #3246 from BekaValentine/python-objectapi-to-valueapi-uselessclass
Python: ObjectAPI to ValueAPI: UselessClass
2020-04-15 16:45:02 +02:00
Jonas Jensen
aa8f30cd83 Merge pull request #3268 from MathiasVP/ql-doc-negativitiy
C++: Add QLDoc to public predicates in Negativity.qll
2020-04-15 15:12:07 +02:00
Mathias Vorreiter Pedersen
3d0ac53266 Apply suggestions from code review
Co-Authored-By: Jonas Jensen <jbj@github.com>
2020-04-15 14:01:49 +02:00
Jonas Jensen
6eba3380dd Merge pull request #3241 from geoffw0/alloc-size2
C++ Improvements to TaintedAllocationSize.ql
2020-04-15 12:58:19 +02:00
semmle-qlci
bfd80b42a7 Merge pull request #3260 from asger-semmle/js/location-tweaks
Approved by erik-krogh
2020-04-15 10:47:35 +01:00
Asger F
34d40b5035 Merge pull request #3237 from asger-semmle/js/sparse-capture
JS: Add CapturedVariableNode to avoid N^2 edges
2020-04-15 10:42:48 +01:00
Mathias Vorreiter Pedersen
f02feac33a C++: Add flow from #3220 2020-04-15 11:34:19 +02:00