Skip to content

Commit 0fcabc4

Browse files
committed
C++: Move mayBeFromImplicitlyDeclaredFunction to Call
1 parent 4197805 commit 0fcabc4

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ class Call extends Expr, NameQualifiableElement, TCall {
149149
variableAddressEscapesTreeNonConst(va, this.getQualifier().getFullyConverted()) and
150150
i = -1
151151
}
152+
153+
/** Holds if this expression could be the return value of an implicitly declared function. */
154+
predicate mayBeFromImplicitlyDeclaredFunction() {
155+
this.getTarget().getADeclarationEntry().isImplicit()
156+
}
152157
}
153158

154159
/**
@@ -300,10 +305,6 @@ class FunctionCall extends Call, @funbindexpr {
300305
this.isVirtual() or
301306
this.getTarget().getAnAttribute().getName() = "weak"
302307
}
303-
304-
override predicate mayBeFromImplicitlyDeclaredFunction() {
305-
this.getTarget().getADeclarationEntry().isImplicit()
306-
}
307308
}
308309

309310
/** A _user-defined_ unary `operator*` function. */

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,6 @@ class Expr extends StmtParent, @expr {
534534

535535
/** Gets the function containing this control-flow node. */
536536
override Function getControlFlowScope() { result = this.getEnclosingFunction() }
537-
538-
/** Holds if this expression could be the return value of an implicitly declared function. */
539-
predicate mayBeFromImplicitlyDeclaredFunction() { none() }
540537
}
541538

542539
/**

cpp/ql/src/Likely Bugs/Format/WrongTypeFormatArguments.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ where
171171
not arg.isAffectedByMacro() and
172172
not arg.isFromUninstantiatedTemplate(_) and
173173
not actual.getUnspecifiedType() instanceof ErroneousType and
174-
not arg.mayBeFromImplicitlyDeclaredFunction()
174+
not arg.(Call).mayBeFromImplicitlyDeclaredFunction()
175175
select arg,
176176
"This format specifier for type '" + expected.getName() + "' does not match the argument type '" +
177177
actual.getUnspecifiedType().getName() + "'."
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import cpp
22

3-
from Expr e
4-
where e.mayBeFromImplicitlyDeclaredFunction()
5-
select e
3+
from Call c
4+
where c.mayBeFromImplicitlyDeclaredFunction()
5+
select c

0 commit comments

Comments
 (0)