Commit Graph

2715 Commits

Author SHA1 Message Date
idrissrio
39136f3827 C/C++ overlay: Add basic Overlay.qll file 2025-11-27 09:22:29 +01:00
Mathias Vorreiter Pedersen
47ab307410 C++: Respond to review comments. 2025-11-25 12:06:58 +00:00
Mathias Vorreiter Pedersen
eb6b08591d Update cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-24 15:01:09 +00:00
Mathias Vorreiter Pedersen
2e53370716 Update cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-24 15:01:00 +00:00
Mathias Vorreiter Pedersen
ecb80cb4fc C++: Represent field content using a column that is shared by all template instantiations. 2025-11-24 12:29:49 +00:00
Mathias Vorreiter Pedersen
4c09e554fc Merge branch 'main' into union-content-field-content-common-base-class 2025-11-19 17:17:45 +00:00
Jeroen Ketema
fe3f90e041 C++: Make getExpandedArgument more robust
This make the predicate give back sensible results on (upgraded) databases
where we do not have expanded arguments, and avoid having to write case
distinctions in places where we would want to use `getExpandedArgument`.
2025-11-19 12:49:54 +01:00
Jeroen Ketema
e235e0473a C++: Fix getAnExpandedArgument
The fix was accidentially lost when rebasing the branch that introduced this
predicate.
2025-11-19 12:49:02 +01:00
Mathias Vorreiter Pedersen
9bfe847fda C++: Fix awful joins on bochs:
```
Evaluated relational algebra for predicate DataFlowPrivate::storeStepImpl/4#b2c79f9a@13be12rc with tuple counts:
           9   ~0%    {3} r1 = JOIN `FlowSummaryImpl::Private::Steps::summaryStoreStep/3#5c2d4899` WITH DataFlowUtil::TFlowSummaryNode#40da8361 ON FIRST 1 OUTPUT Lhs.2, Lhs.1, Rhs.1
           9   ~0%    {4}    | JOIN WITH DataFlowUtil::TFlowSummaryNode#40da8361 ON FIRST 1 OUTPUT Lhs.2, Lhs.1, Rhs.1, _
           9  ~12%    {4}    | REWRITE WITH Out.3 := true

     1853420   ~0%    {3} r2 = SCAN `DataFlowPrivate::nodeHasInstruction/3#f469bb06` OUTPUT In.1, In.0, In.2
      100282   ~0%    {3}    | JOIN WITH `Instruction::StoreInstruction.getDestinationAddressOperand/0#dispred#596a4aba` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2
      127910   ~0%    {6}    | JOIN WITH `DataFlowPrivate::numberOfLoadsFromOperand/4#7e555666_1023#join_rhs` ON FIRST 1 OUTPUT _, Lhs.1, Rhs.1, Rhs.3, Lhs.2, Rhs.2
      127910   ~0%    {4}    | REWRITE WITH Tmp.0 := 1, Out.0 := (Tmp.0 + In.4 + In.5) KEEPING 4
  4178182721   ~1%    {4}    | JOIN WITH `DataFlowUtil::FieldContent.getIndirectionIndex/0#dispred#cc69866f_10#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2, Lhs.3
  4290552803   ~0%    {5}    | JOIN WITH `DataFlowUtil::FieldContent.getAField/0#dispred#ba1c91e5` ON FIRST 1 OUTPUT Lhs.2, Lhs.1, Lhs.3, Lhs.0, Rhs.1
  3033745816   ~5%    {7}    | JOIN WITH DataFlowUtil::PostFieldUpdateNode#b86f3a84_1023#join_rhs ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2, Lhs.3, Lhs.4, Rhs.2, Rhs.3
  3033745816   ~3%    {9}    | JOIN WITH DataFlowUtil::TPostUpdateNodeImpl#f5e76b7a_21#join_rhs ON FIRST 1 OUTPUT Lhs.1, Lhs.2, Lhs.3, Lhs.4, Lhs.0, Lhs.5, Lhs.6, Rhs.1, _
                      {8}    | REWRITE WITH Tmp.8 := 1, TEST InOut.7 = Tmp.8 KEEPING 8
  1516872908   ~0%    {7}    | SCAN OUTPUT In.4, In.5, In.6, In.0, In.1, In.2, In.3
  2409090286   ~1%    {6}    | JOIN WITH DataFlowUtil::PostFieldUpdateNode#b86f3a84_0231#join_rhs ON FIRST 3 OUTPUT Rhs.3, Lhs.6, Lhs.3, Lhs.4, Lhs.5, Lhs.0
       66016  ~45%    {4}    | JOIN WITH `DataFlowUtil::FieldAddress.getField/0#dispred#bdd01c1a` ON FIRST 2 OUTPUT Lhs.2, Lhs.4, Lhs.5, Lhs.3

       66025  ~45%    {4} r3 = r1 UNION r2
                      return r3
```
2025-11-19 10:08:09 +00:00
Mathias Vorreiter Pedersen
a5601ce734 C++: Lift 'getTypeOperand' to the superclass. 2025-11-18 19:52:05 +00:00
Mathias Vorreiter Pedersen
7f0fcb0c46 C++: Create a common base class for 'NonUnionContent' and 'UnionContent' called 'FieldContent'. 2025-11-18 18:53:37 +00:00
Mathias Vorreiter Pedersen
7527d88762 C++: Get rid of abstract'ness from these public predicates. We are not supposed to have abstract public stuff. Oops ... 2025-11-18 18:52:20 +00:00
Mathias Vorreiter Pedersen
2af6db6320 C++: Rename 'FieldContent' to 'NonUnionContent'. 2025-11-18 18:51:33 +00:00
Mathias Vorreiter Pedersen
47ac4dd1dc C++: Add 'nomagic' to 'getParameter'. 2025-11-17 19:21:37 +00:00
Jeroen Ketema
1671805598 Merge pull request #20831 from jketema/expanded
C++: Extract the expanded compiler arguments
2025-11-17 13:58:24 +01:00
Jeroen Ketema
1df47cc747 C++: Fix QL-for-QL warning 2025-11-17 11:17:57 +01:00
Jeroen Ketema
ee97d6f461 C++: Expose the expanded compilation arguments 2025-11-17 11:17:53 +01:00
Simon Friis Vindum
792ac7a772 C++: Fix typo
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-14 12:59:41 +01:00
Simon Friis Vindum
5da73f3232 C++: Make sure that nrOfBoundsNEPhi is functional 2025-11-14 12:26:23 +01:00
Simon Friis Vindum
69e70d7cbc Reapply "Merge pull request #20645 from paldepind/cpp/range-analysis-measure"
This reverts commit e7c029ae7d.
2025-11-14 12:26:21 +01:00
Mathias Vorreiter Pedersen
7b052e2404 Merge branch 'main' into fix-cp-in-external-flow 2025-11-10 10:44:31 +00:00
Mathias Vorreiter Pedersen
29a294f8d0 C++: Bind the columns inside the predicate instead of relying on 'bindingset's. The repeated inlining caused by 'bindiingset's created some #shared predicates with repeated regex matching. 2025-11-10 10:21:12 +00:00
Mathias Vorreiter Pedersen
267a7f5229 Merge pull request #20779 from MathiasVP/fix-bad-magic
C++: Fix bad magic in `IRGuards`
2025-11-10 10:05:18 +00:00
Jeroen Ketema
eb3e86480f Merge pull request #20784 from jketema/qual-fail
C++: Fix named qualifier dataset check error with decltypes
2025-11-10 10:36:47 +01:00
Jeroen Ketema
f9554e1542 C++: Give proper getNames to more types and fix QLdoc 2025-11-10 10:11:01 +01:00
Mathias Vorreiter Pedersen
dfdc2a6a15 C++: Delete an incorrect comment. 2025-11-08 16:45:45 +00:00
Mathias Vorreiter Pedersen
3d6b3a31ac C++: Also join on the 'namespace'. 2025-11-08 16:45:39 +00:00
Mathias Vorreiter Pedersen
bfe2b7dc44 C++: Use the new predicate to remove a cartesian-like join. 2025-11-08 16:43:43 +00:00
Mathias Vorreiter Pedersen
a922d5099f C++: Factor out some conjuncts from 'interpretElement0' and into a new predicate. 2025-11-08 16:42:16 +00:00
Mathias Vorreiter Pedersen
74b774eec5 Merge pull request #20769 from MathiasVP/add-more-flow-models
C++: Add a few more models
2025-11-08 16:39:29 +00:00
Mathias Vorreiter Pedersen
6a2debba96 C++: Fix bad magic. 2025-11-07 17:38:18 +00:00
Mathias Vorreiter Pedersen
56b9566299 C++: Fix mistakes in models of internal strcat and strcpy functions. 2025-11-07 17:29:48 +00:00
Mathias Vorreiter Pedersen
f163d015d5 C++: Clean up comments. 2025-11-07 17:27:25 +00:00
Enrico Steffinlongo
e7c029ae7d Revert "Merge pull request #20645 from paldepind/cpp/range-analysis-measure"
This reverts commit a0a6f288b5, reversing
changes made to 32f21d6d49.
2025-11-07 16:49:47 +00:00
Mathias Vorreiter Pedersen
f0da0d98a2 C++: Add a few more models I noticed while here. 2025-11-06 17:00:19 +00:00
Simon Friis Vindum
d1ea1af945 C++: Make small trivial tweaks 2025-10-24 16:16:57 +02:00
Simon Friis Vindum
5709964fbf C++: Simplify boundFromGuard
The last disjunct in `boundFromGuard` is moved into `linearBoundFromGuard`. This avoids repeating the calculation for `boundValue`.

`getBounds` and `getExprTypeBounds` are turned into predicates with result. Their middle argument was the "output" which was confusing.
2025-10-24 16:12:05 +02:00
Simon Friis Vindum
383e6a44aa C++: Use or instead of if
The proposition in the true branch implied the condition, so `or` is more appropriate. Also eliminated an existentially quantified variable.
2025-10-24 16:08:35 +02:00
Simon Friis Vindum
17e0dec08a C++: Add toString for RelationStrictness
This helps for debugging.
2025-10-24 16:01:38 +02:00
Simon Friis Vindum
a0a6f288b5 Merge pull request #20645 from paldepind/cpp/range-analysis-measure
C++: Range analysis measure bounds
2025-10-24 15:30:07 +02:00
Anders Schack-Mulligen
f257c7a570 Guards: Align the SSA signature with the one from shared SSA. 2025-10-23 10:23:22 +02:00
Simon Friis Vindum
0badcfd663 C++: Address review comments 2025-10-21 09:47:58 +02:00
Simon Friis Vindum
979b05cc1a C++: Apply suggested fixes from review 2025-10-17 09:50:36 +02:00
Simon Friis Vindum
9502d83f2c C++: Add debug predicates 2025-10-16 15:05:48 +02:00
Simon Friis Vindum
c1f0f3da96 C++: Handle guard phi nodes differently 2025-10-16 15:05:46 +02:00
Simon Friis Vindum
8896a7210b C++: Add number of bounds test to simple range analysis 2025-10-16 15:05:44 +02:00
Simon Friis Vindum
7eacd87343 C++: Apply widening based on number of bounds measure 2025-10-16 15:05:42 +02:00
Simon Friis Vindum
8aaf9f696a C++: Factor out widening of bounds 2025-10-15 11:11:45 +02:00
Mathias Vorreiter Pedersen
bc0b87632d C++: Fix bad magic on Element.getFile when running on InconsistentCheckReturnNull.qll:
Evaluated non-recursive predicate Element::Element.getFile/0#dispred#536cb5f3#bb@f6f5329i in 182326ms (size: 50437).
Evaluated relational algebra for predicate Element::Element.getFile/0#dispred#536cb5f3#bb@f6f5329i with tuple counts:
           2029351   ~0%    {2} r1 = SCAN `Expr::Expr.getLocation/0#dispred#0a3d90c6` OUTPUT In.1, In.0
           2029351   ~0%    {2}    | JOIN WITH `Location::Location.getStartLine/0#d54f9e6c` ON FIRST 1 OUTPUT Rhs.1, Lhs.1
           1168789   ~0%    {2}    | JOIN WITH `InconsistentCheckReturnNull::assertInvocation/2#b2a4c9e3_10#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Lhs.1
        5533128288   ~0%    {3}    | JOIN WITH `Location::Location.getContainer/0#9edabfb6_10#join_rhs` ON FIRST 1 OUTPUT Lhs.1, Rhs.1, Lhs.0
             50413   ~0%    {2}    | JOIN WITH `Element::Element.getLocation/0#dispred#6c3f5b09#bf` ON FIRST 2 OUTPUT Lhs.0, Lhs.2

              3043   ~0%    {2} r2 = JOIN `project#InconsistentCheckReturnNull::relevantFunctionCall/2#d18cd566` WITH `Expr::Expr.getLocation/0#dispred#0a3d90c6` ON FIRST 1 OUTPUT Rhs.1, Lhs.0

              3043   ~0%    {2} r3 = JOIN r2 WITH locations_default ON FIRST 1 OUTPUT Rhs.4, Lhs.1
              1945   ~3%    {2}    | JOIN WITH `InconsistentCheckReturnNull::assertInvocation/2#b2a4c9e3_10#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Lhs.1
           9106248   ~2%    {3}    | JOIN WITH `Location::Location.getContainer/0#9edabfb6_10#join_rhs` ON FIRST 1 OUTPUT Lhs.1, Rhs.1, Lhs.0
                 0   ~0%    {2}    | JOIN WITH `Element::Element.getLocation/0#dispred#6c3f5b09#bf` ON FIRST 2 OUTPUT Lhs.0, Lhs.2

              3043   ~0%    {3} r4 = JOIN r2 WITH locations_default ON FIRST 1 OUTPUT _, Lhs.1, Rhs.4
              3043   ~0%    {2}    | REWRITE WITH Tmp.0 := 1, Out.0 := (In.2 + Tmp.0) KEEPING 2
              2013   ~0%    {2}    | JOIN WITH `InconsistentCheckReturnNull::assertInvocation/2#b2a4c9e3_10#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Lhs.1
           9621327   ~0%    {3}    | JOIN WITH `Location::Location.getContainer/0#9edabfb6_10#join_rhs` ON FIRST 1 OUTPUT Lhs.1, Rhs.1, Lhs.0
                24   ~3%    {2}    | JOIN WITH `Element::Element.getLocation/0#dispred#6c3f5b09#bf` ON FIRST 2 OUTPUT Lhs.0, Lhs.2

             50437   ~0%    {2} r5 = r1 UNION r3 UNION r4
                            return r5
2025-10-02 17:36:21 +01:00
Mathias Vorreiter Pedersen
b0e9238ddf Merge branch 'main' into use-shared-guards-library 2025-10-01 11:59:17 +01:00