Skip to content

Commit 95a63a6

Browse files
committed
Merge branch 'main' into cwe497b
2 parents 92d748e + f53df25 commit 95a63a6

File tree

83 files changed

+3047
-2276
lines changed

Some content is hidden

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

83 files changed

+3047
-2276
lines changed

cpp/ql/lib/DefaultOptions.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ class Options extends string {
5454
*
5555
* By default, this holds for `exit`, `_exit`, `abort`, `__assert_fail`,
5656
* `longjmp`, `__builtin_unreachable` and any function with a
57-
* `noreturn` attribute.
57+
* `noreturn` attribute or specifier.
5858
*/
5959
predicate exits(Function f) {
6060
f.getAnAttribute().hasName("noreturn")
6161
or
62+
f.getASpecifier().hasName("noreturn")
63+
or
6264
f.hasGlobalOrStdName([
6365
"exit", "_exit", "abort", "__assert_fail", "longjmp", "__builtin_unreachable"
6466
])

cpp/ql/lib/Options.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CustomOptions extends Options {
3939
*
4040
* By default, this holds for `exit`, `_exit`, `abort`, `__assert_fail`,
4141
* `longjmp`, `error`, `__builtin_unreachable` and any function with a
42-
* `noreturn` attribute.
42+
* `noreturn` attribute or specifier.
4343
*/
4444
override predicate exits(Function f) { Options.super.exits(f) }
4545

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* `hasImplicitCopyConstructor` and `hasImplicitCopyAssignmentOperator` now correctly handle implicitly-deleted operators in templates.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* `DefaultOptions::exits` now holds for C11 functions with the `_Noreturn` or `noreturn` specifier.

cpp/ql/lib/semmle/code/cpp/Class.qll

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,16 @@ class Class extends UserType {
251251
not this.implicitCopyConstructorDeleted() and
252252
forall(CopyConstructor cc | cc = this.getAMemberFunction() |
253253
cc.isCompilerGenerated() and not cc.isDeleted()
254+
) and
255+
(
256+
not this instanceof ClassTemplateInstantiation
257+
or
258+
this.(ClassTemplateInstantiation).getTemplate().hasImplicitCopyConstructor()
259+
) and
260+
(
261+
not this instanceof PartialClassTemplateSpecialization
262+
or
263+
this.(PartialClassTemplateSpecialization).getPrimaryTemplate().hasImplicitCopyConstructor()
254264
)
255265
}
256266

@@ -266,6 +276,18 @@ class Class extends UserType {
266276
not this.implicitCopyAssignmentOperatorDeleted() and
267277
forall(CopyAssignmentOperator ca | ca = this.getAMemberFunction() |
268278
ca.isCompilerGenerated() and not ca.isDeleted()
279+
) and
280+
(
281+
not this instanceof ClassTemplateInstantiation
282+
or
283+
this.(ClassTemplateInstantiation).getTemplate().hasImplicitCopyAssignmentOperator()
284+
) and
285+
(
286+
not this instanceof PartialClassTemplateSpecialization
287+
or
288+
this.(PartialClassTemplateSpecialization)
289+
.getPrimaryTemplate()
290+
.hasImplicitCopyAssignmentOperator()
269291
)
270292
}
271293

cpp/ql/lib/semmle/code/cpp/Specifier.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class FunctionSpecifier extends Specifier {
3838

3939
/**
4040
* A C/C++ storage class specifier: `auto`, `register`, `static`, `extern`,
41-
* or `mutable".
41+
* or `mutable`.
4242
*/
4343
class StorageClassSpecifier extends Specifier {
4444
StorageClassSpecifier() { this.hasName(["auto", "register", "static", "extern", "mutable"]) }

cpp/ql/lib/semmle/code/cpp/controlflow/internal/CFG.qll

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -447,26 +447,6 @@ private predicate skipInitializer(Initializer init) {
447447
)
448448
}
449449

450-
/**
451-
* Holds if `e` is an expression in a static initializer that must be evaluated
452-
* at run time. This predicate computes "is non-const" instead of "is const" in
453-
* order to avoid recursion through forall.
454-
*/
455-
private predicate runtimeExprInStaticInitializer(Expr e) {
456-
inStaticInitializer(e) and
457-
if e instanceof AggregateLiteral
458-
then runtimeExprInStaticInitializer(e.getAChild())
459-
else not e.getFullyConverted().isConstant()
460-
}
461-
462-
/** Holds if `e` is part of the initializer of a local static variable. */
463-
private predicate inStaticInitializer(Expr e) {
464-
exists(LocalVariable local |
465-
local.isStatic() and
466-
e.getParent+() = local.getInitializer()
467-
)
468-
}
469-
470450
/**
471451
* Gets the `i`th child of `n` in control-flow order, where the `i`-indexes are
472452
* contiguous, and the first index is 0.

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -287,20 +287,6 @@ private module SsaDefReaches {
287287
)
288288
}
289289

290-
/**
291-
* Holds if the SSA definition of `v` at `def` reaches uncertain SSA definition
292-
* `redef` in the same basic block, without crossing another SSA definition of `v`.
293-
*/
294-
predicate ssaDefReachesUncertainDefWithinBlock(
295-
SourceVariable v, Definition def, UncertainWriteDefinition redef
296-
) {
297-
exists(BasicBlock bb, int rnk, int i |
298-
ssaDefReachesRank(bb, def, rnk, v) and
299-
rnk = ssaRefRank(bb, i, v, SsaDef()) - 1 and
300-
redef.definesAt(v, bb, i)
301-
)
302-
}
303-
304290
/**
305291
* Same as `ssaRefRank()`, but restricted to a particular SSA definition `def`.
306292
*/

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/reachability/DominanceInternal.qll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
private import ReachableBlock as Reachability
22

3-
private module ReachabilityGraph = Reachability::Graph;
4-
53
module Graph {
64
import Reachability::Graph
75

cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/reachability/DominanceInternal.qll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
private import ReachableBlock as Reachability
22

3-
private module ReachabilityGraph = Reachability::Graph;
4-
53
module Graph {
64
import Reachability::Graph
75

0 commit comments

Comments
 (0)