Skip to content

Commit c3ea0ce

Browse files
committed
Merge branch 'main' into logfix
2 parents 6aa8dae + b08e410 commit c3ea0ce

File tree

143 files changed

+12115
-2021
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+12115
-2021
lines changed

cpp/downgrades/dbe9c8eb5fc6f54b7ae08c7317d0795b24961564/old.dbscheme

Lines changed: 2213 additions & 0 deletions
Large diffs are not rendered by default.

cpp/downgrades/dbe9c8eb5fc6f54b7ae08c7317d0795b24961564/semmlecode.cpp.dbscheme

Lines changed: 2212 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
description: Make __is_trivial a builtin operation
2+
compatibility: full

cpp/ql/lib/semmle/code/cpp/controlflow/Dereferenced.qll

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,18 @@ predicate callDereferences(FunctionCall fc, int i) {
2626
}
2727

2828
/**
29-
* Holds if evaluation of `op` dereferences `e`.
29+
* Holds if evaluation of `op` dereferences `e` directly.
30+
*
31+
* This predicate does not recurse through function calls or arithmetic operations. To find
32+
* such cases, use `dereferencedByOperation`.
3033
*/
31-
predicate dereferencedByOperation(Expr op, Expr e) {
34+
predicate directDereferencedByOperation(Expr op, Expr e) {
3235
exists(PointerDereferenceExpr deref |
3336
deref.getAChild() = e and
3437
deref = op and
3538
not deref.getParent*() instanceof SizeofOperator
3639
)
3740
or
38-
exists(CrementOperation crement | dereferencedByOperation(e, op) and crement.getOperand() = e)
39-
or
4041
exists(ArrayExpr ae |
4142
(
4243
not ae.getParent() instanceof AddressOfExpr and
@@ -50,6 +51,24 @@ predicate dereferencedByOperation(Expr op, Expr e) {
5051
)
5152
)
5253
or
54+
// ptr->Field
55+
e = op.(FieldAccess).getQualifier() and isClassPointerType(e.getType())
56+
or
57+
// ptr->method()
58+
e = op.(Call).getQualifier() and isClassPointerType(e.getType())
59+
}
60+
61+
/**
62+
* Holds if evaluation of `op` dereferences `e`.
63+
*
64+
* This includes the set of operations identified via `directDereferencedByOperation`, as well
65+
* as calls to function that are known to dereference an argument.
66+
*/
67+
predicate dereferencedByOperation(Expr op, Expr e) {
68+
directDereferencedByOperation(op, e)
69+
or
70+
exists(CrementOperation crement | dereferencedByOperation(e, op) and crement.getOperand() = e)
71+
or
5372
exists(AddressOfExpr addof, ArrayExpr ae |
5473
dereferencedByOperation(addof, op) and
5574
addof.getOperand() = ae and
@@ -74,12 +93,6 @@ predicate dereferencedByOperation(Expr op, Expr e) {
7493
e = fc.getArgument(i) and
7594
op = fc
7695
)
77-
or
78-
// ptr->Field
79-
e = op.(FieldAccess).getQualifier() and isClassPointerType(e.getType())
80-
or
81-
// ptr->method()
82-
e = op.(Call).getQualifier() and isClassPointerType(e.getType())
8396
}
8497

8598
private predicate isClassPointerType(Type t) {

cpp/ql/lib/semmle/code/cpp/exprs/BuiltInOperations.qll

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,3 +1547,21 @@ class BuiltInBitCast extends BuiltInOperation, @builtinbitcast {
15471547

15481548
override string getAPrimaryQlClass() { result = "BuiltInBitCast" }
15491549
}
1550+
1551+
/**
1552+
* A C++ `__is_trivial` built-in operation (used by some implementations of the
1553+
* `<type_traits>` header).
1554+
*
1555+
* Returns `true` if a type is a trivial type.
1556+
* ```
1557+
* template<typename _Tp>
1558+
* struct is_trivial
1559+
* : public integral_constant<bool, __is_trivial(_Tp)>
1560+
* {};
1561+
* ```
1562+
*/
1563+
class BuiltInIsTrivial extends BuiltInOperation, @istrivialexpr {
1564+
override string toString() { result = "__is_trivial" }
1565+
1566+
override string getAPrimaryQlClass() { result = "BuiltInIsTrivial" }
1567+
}

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaInternals.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ predicate fromPhiNode(SsaPhiNode nodeFrom, Node nodeTo) {
766766
or
767767
exists(PhiNode phiTo |
768768
phi != phiTo and
769-
lastRefRedefExt(phi, _, _, phiTo) and
769+
lastRefRedefExt(phi, bb1, i1, phiTo) and
770770
nodeTo.(SsaPhiNode).getPhiNode() = phiTo
771771
)
772772
)

cpp/ql/lib/semmlecode.cpp.dbscheme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,6 +1755,7 @@ case @expr.kind of
17551755
| @istriviallydestructibleexpr
17561756
| @istriviallyassignableexpr
17571757
| @isnothrowassignableexpr
1758+
| @istrivialexpr
17581759
| @isstandardlayoutexpr
17591760
| @istriviallycopyableexpr
17601761
| @isliteraltypeexpr

0 commit comments

Comments
 (0)