Skip to content

Commit 483370d

Browse files
committed
Merge branch 'main' into unreachable
2 parents f084bb7 + 5a4cd1c commit 483370d

File tree

443 files changed

+7687
-2545
lines changed

Some content is hidden

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

443 files changed

+7687
-2545
lines changed

cpp/ql/lib/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.1
2+
3+
No user-facing changes.
4+
15
## 2.0.0
26

37
### Breaking Changes
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 2.0.1
2+
3+
No user-facing changes.

cpp/ql/lib/codeql-pack.release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
lastReleaseVersion: 2.0.0
2+
lastReleaseVersion: 2.0.1

cpp/ql/lib/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/cpp-all
2-
version: 2.0.1-dev
2+
version: 2.0.2-dev
33
groups: cpp
44
dbscheme: semmlecode.cpp.dbscheme
55
extractor: cpp

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,17 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
500500
* Gets the nearest enclosing AccessHolder.
501501
*/
502502
override AccessHolder getEnclosingAccessHolder() { result = this.getDeclaringType() }
503+
504+
/**
505+
* Holds if this function has extraction errors that create an `ErrorExpr`.
506+
*/
507+
predicate hasErrors() {
508+
exists(ErrorExpr e |
509+
e.getEnclosingFunction() = this and
510+
// Exclude the first allocator call argument because it is always extracted as `ErrorExpr`.
511+
not exists(NewOrNewArrayExpr new | e = new.getAllocatorCall().getArgument(0))
512+
)
513+
}
503514
}
504515

505516
pragma[noinline]

cpp/ql/src/Best Practices/Unused Entities/UnusedLocals.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ where
5757
not declarationHasSideEffects(v) and
5858
not exists(AsmStmt s | f = s.getEnclosingFunction()) and
5959
not v.getAnAttribute().getName() = "unused" and
60-
not any(ErrorExpr e).getEnclosingFunction() = f // unextracted expr may use `v`
60+
not f.hasErrors() // Unextracted expressions may use `v`
6161
select v, "Variable " + v.getName() + " is not used."

cpp/ql/src/CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
## 1.2.4
2+
3+
### Minor Analysis Improvements
4+
5+
* Fixed false positives in the `cpp/wrong-number-format-arguments` ("Too few arguments to formatting function") query when the formatting function has been declared implicitly.
6+
17
## 1.2.3
28

39
### Minor Analysis Improvements
410

5-
* Removed false positives caused by buffer accesses in unreachable code.
6-
* Removed false positives caused by inconsistent type checking.
11+
* Removed false positives caused by buffer accesses in unreachable code
12+
* Removed false positives caused by inconsistent type checking
713
* Add modeling of C functions that don't throw, thereby increasing the precision of the `cpp/incorrect-allocation-error-handling` ("Incorrect allocation-error handling") query. The query now produces additional true positives.
814

915
## 1.2.2

cpp/ql/src/Likely Bugs/Memory Management/ReturnStackAllocatedMemory.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ReturnStackAllocatedMemoryConfig extends MustFlowConfiguration {
2929
override predicate isSource(Instruction source) {
3030
exists(Function func |
3131
// Rule out FPs caused by extraction errors.
32-
not any(ErrorExpr e).getEnclosingFunction() = func and
32+
not func.hasErrors() and
3333
not intentionallyReturnsStackPointer(func) and
3434
func = source.getEnclosingFunction()
3535
|

cpp/ql/src/Likely Bugs/Memory Management/UninitializedLocal.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ predicate isSinkImpl(Instruction sink, VariableAccess va) {
6565
exists(LoadInstruction load |
6666
va = load.getUnconvertedResultExpression() and
6767
not va = commonException() and
68+
not va.getTarget().(LocalVariable).getFunction().hasErrors() and
6869
sink = load.getSourceValue()
6970
)
7071
}

cpp/ql/src/Likely Bugs/Memory Management/UsingExpiredStackAddress.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ predicate instructionHasVariable(VariableAddressInstruction vai, StackVariable v
2424
// Pointer-to-member types aren't properly handled in the dbscheme.
2525
not vai.getResultType() instanceof PointerToMemberType and
2626
// Rule out FPs caused by extraction errors.
27-
not any(ErrorExpr e).getEnclosingFunction() = f
27+
not f.hasErrors()
2828
}
2929

3030
/**

0 commit comments

Comments
 (0)