mirror of
https://github.com/github/codeql.git
synced 2025-12-17 17:23:36 +01:00
A number of CPP library tests contain `// query-type: graph` annotations that make the test driver compare the output from the test query in a special mode. (This feature is not used by other languages). It's somewhat awkward in the implementation of `codeql test run` that this annotation is not an ordinary item of query metadata -- essentially it means that _every_ test query has to be opened and read an extra time to look for this annotation. I'd like to move towards using ordinary query metadata for this, since the QL compiler already parses it anyway. For the time being, give the annotation in both old and new syntaxes, until a CLI that recognizes both has been released.
43 lines
1.3 KiB
Plaintext
43 lines
1.3 KiB
Plaintext
/**
|
|
* query-type: graph
|
|
*
|
|
* @kind graph-equivalence-test
|
|
*/
|
|
|
|
import cpp
|
|
|
|
class DestructorCallEnhanced extends DestructorCall {
|
|
override string toString() {
|
|
if exists(this.getQualifier().(VariableAccess).getTarget().getName())
|
|
then
|
|
result =
|
|
"call to " + this.getQualifier().(VariableAccess).getTarget().getName() + "." +
|
|
this.getTarget().getName()
|
|
else result = super.toString()
|
|
}
|
|
}
|
|
|
|
string scope(ControlFlowNode x) {
|
|
if exists(x.getControlFlowScope().getQualifiedName())
|
|
then result = x.getControlFlowScope().getQualifiedName()
|
|
else result = "<no scope>"
|
|
}
|
|
|
|
predicate isNode(boolean isEdge, ControlFlowNode x, ControlFlowNode y, string label) {
|
|
isEdge = false and x = y and label = x.toString()
|
|
}
|
|
|
|
predicate isSuccessor(boolean isEdge, ControlFlowNode x, ControlFlowNode y, string label) {
|
|
exists(string truelabel, string falselabel |
|
|
isEdge = true and
|
|
x.getASuccessor() = y and
|
|
(if x.getATrueSuccessor() = y then truelabel = "T" else truelabel = "") and
|
|
(if x.getAFalseSuccessor() = y then falselabel = "F" else falselabel = "") and
|
|
label = truelabel + falselabel
|
|
)
|
|
}
|
|
|
|
from boolean isEdge, ControlFlowNode x, ControlFlowNode y, string label
|
|
where isNode(isEdge, x, y, label) or isSuccessor(isEdge, x, y, label)
|
|
select scope(x), isEdge, x, y, label
|