Skip to content

Commit

Permalink
C++: Move mayBeFromImplicitlyDeclaredFunction to Call
Browse files Browse the repository at this point in the history
  • Loading branch information
calumgrant committed Oct 18, 2024
1 parent 4197805 commit 0fcabc4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
9 changes: 5 additions & 4 deletions cpp/ql/lib/semmle/code/cpp/exprs/Call.qll
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ class Call extends Expr, NameQualifiableElement, TCall {
variableAddressEscapesTreeNonConst(va, this.getQualifier().getFullyConverted()) and
i = -1
}

/** Holds if this expression could be the return value of an implicitly declared function. */
predicate mayBeFromImplicitlyDeclaredFunction() {
this.getTarget().getADeclarationEntry().isImplicit()
}
}

/**
Expand Down Expand Up @@ -300,10 +305,6 @@ class FunctionCall extends Call, @funbindexpr {
this.isVirtual() or
this.getTarget().getAnAttribute().getName() = "weak"
}

override predicate mayBeFromImplicitlyDeclaredFunction() {
this.getTarget().getADeclarationEntry().isImplicit()
}
}

/** A _user-defined_ unary `operator*` function. */
Expand Down
3 changes: 0 additions & 3 deletions cpp/ql/lib/semmle/code/cpp/exprs/Expr.qll
Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,6 @@ class Expr extends StmtParent, @expr {

/** Gets the function containing this control-flow node. */
override Function getControlFlowScope() { result = this.getEnclosingFunction() }

/** Holds if this expression could be the return value of an implicitly declared function. */
predicate mayBeFromImplicitlyDeclaredFunction() { none() }
}

/**
Expand Down
2 changes: 1 addition & 1 deletion cpp/ql/src/Likely Bugs/Format/WrongTypeFormatArguments.ql
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ where
not arg.isAffectedByMacro() and
not arg.isFromUninstantiatedTemplate(_) and
not actual.getUnspecifiedType() instanceof ErroneousType and
not arg.mayBeFromImplicitlyDeclaredFunction()
not arg.(Call).mayBeFromImplicitlyDeclaredFunction()
select arg,
"This format specifier for type '" + expected.getName() + "' does not match the argument type '" +
actual.getUnspecifiedType().getName() + "'."
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cpp

from Expr e
where e.mayBeFromImplicitlyDeclaredFunction()
select e
from Call c
where c.mayBeFromImplicitlyDeclaredFunction()
select c

0 comments on commit 0fcabc4

Please sign in to comment.