mirror of
https://github.com/github/codeql.git
synced 2026-01-27 05:13:00 +01:00
This PR separates the core cpp packs into `codeql/cpp-queries` and `codeql/cpp-all`. There are very few lines of code changed. Almost all changes are moving files around.
36 lines
1.2 KiB
Plaintext
36 lines
1.2 KiB
Plaintext
import semmle.code.cpp.Function
|
|
import semmle.code.cpp.models.interfaces.Alias
|
|
import semmle.code.cpp.models.interfaces.DataFlow
|
|
import semmle.code.cpp.models.interfaces.SideEffect
|
|
|
|
/**
|
|
* The standard function templates `std::move` and `std::forward`.
|
|
*/
|
|
private class IdentityFunction extends DataFlowFunction, SideEffectFunction, AliasFunction,
|
|
FunctionTemplateInstantiation {
|
|
IdentityFunction() { this.hasQualifiedName("std", ["move", "forward"]) }
|
|
|
|
override predicate hasOnlySpecificReadSideEffects() { any() }
|
|
|
|
override predicate hasOnlySpecificWriteSideEffects() { any() }
|
|
|
|
override predicate parameterNeverEscapes(int index) { none() }
|
|
|
|
override predicate parameterEscapesOnlyViaReturn(int index) {
|
|
// These functions simply return the argument value.
|
|
index = 0
|
|
}
|
|
|
|
override predicate parameterIsAlwaysReturned(int index) {
|
|
// These functions simply return the argument value.
|
|
index = 0
|
|
}
|
|
|
|
override predicate hasDataFlow(FunctionInput input, FunctionOutput output) {
|
|
// These functions simply return the argument value.
|
|
input.isParameter(0) and output.isReturnValue()
|
|
or
|
|
input.isParameterDeref(0) and output.isReturnValueDeref()
|
|
}
|
|
}
|