Skip to content

Commit 59a77d7

Browse files
committed
C++: Use Function::hasErrors in queries
1 parent 4b5aa14 commit 59a77d7

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

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()
6161
select v, "Variable " + v.getName() + " is not used."

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/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
/**

cpp/ql/src/jsf/4.13 Functions/AV Rule 114.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ predicate functionsMissingReturnStmt(Function f, ControlFlowNode blame) {
4949
predicate functionImperfectlyExtracted(Function f) {
5050
exists(CompilerError e | f.getBlock().getLocation().subsumes(e.getLocation()))
5151
or
52-
exists(ErrorExpr ee | ee.getEnclosingFunction() = f)
52+
f.hasErrors()
5353
or
5454
count(f.getType()) > 1
5555
or

0 commit comments

Comments
 (0)