C++: Move mayBeFromImplicitlyDeclaredFunction to Call

This commit is contained in:
Calum Grant
2024-10-18 15:56:08 +01:00
parent 419780591a
commit 0fcabc4e61
4 changed files with 9 additions and 11 deletions

View File

@@ -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()
}
}
/**
@@ -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. */

View File

@@ -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() }
}
/**

View File

@@ -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() + "'."

View File

@@ -1,5 +1,5 @@
import cpp
from Expr e
where e.mayBeFromImplicitlyDeclaredFunction()
select e
from Call c
where c.mayBeFromImplicitlyDeclaredFunction()
select c