mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C++: Add CFG test for constexpr_if
This commit is contained in:
47
cpp/ql/test/library-tests/constexpr_if/cfg.expected
Normal file
47
cpp/ql/test/library-tests/constexpr_if/cfg.expected
Normal file
@@ -0,0 +1,47 @@
|
||||
| __va_list_tag::operator= | false | 64 | 64 | operator= |
|
||||
| __va_list_tag::operator= | false | 70 | 70 | operator= |
|
||||
| test | false | 121 | 121 | test |
|
||||
| test | false | 127 | 127 | declaration |
|
||||
| test | false | 133 | 133 | 1 |
|
||||
| test | false | 139 | 139 | x |
|
||||
| test | false | 145 | 145 | 1 |
|
||||
| test | false | 147 | 147 | ... = ... |
|
||||
| test | false | 150 | 150 | ExprStmt |
|
||||
| test | false | 153 | 153 | { ... } |
|
||||
| test | false | 156 | 156 | x |
|
||||
| test | false | 162 | 162 | 2 |
|
||||
| test | false | 164 | 164 | ... = ... |
|
||||
| test | false | 167 | 167 | ExprStmt |
|
||||
| test | false | 170 | 170 | { ... } |
|
||||
| test | false | 173 | 173 | if constexpr (...) ... |
|
||||
| test | false | 179 | 179 | 0 |
|
||||
| test | false | 181 | 181 | x |
|
||||
| test | false | 187 | 187 | 3 |
|
||||
| test | false | 189 | 189 | ... = ... |
|
||||
| test | false | 192 | 192 | ExprStmt |
|
||||
| test | false | 195 | 195 | { ... } |
|
||||
| test | false | 198 | 198 | if constexpr (...) ... |
|
||||
| test | false | 201 | 201 | return ... |
|
||||
| test | false | 204 | 204 | { ... } |
|
||||
| test | true | 127 | 173 | |
|
||||
| test | true | 133 | 153 | T |
|
||||
| test | true | 139 | 147 | |
|
||||
| test | true | 145 | 139 | |
|
||||
| test | true | 147 | 198 | |
|
||||
| test | true | 150 | 145 | |
|
||||
| test | true | 153 | 150 | |
|
||||
| test | true | 156 | 164 | |
|
||||
| test | true | 162 | 156 | |
|
||||
| test | true | 164 | 198 | |
|
||||
| test | true | 167 | 162 | |
|
||||
| test | true | 170 | 167 | |
|
||||
| test | true | 173 | 133 | |
|
||||
| test | true | 179 | 201 | F |
|
||||
| test | true | 181 | 189 | |
|
||||
| test | true | 187 | 181 | |
|
||||
| test | true | 189 | 201 | |
|
||||
| test | true | 192 | 187 | |
|
||||
| test | true | 195 | 192 | |
|
||||
| test | true | 198 | 179 | |
|
||||
| test | true | 201 | 121 | |
|
||||
| test | true | 204 | 127 | |
|
||||
34
cpp/ql/test/library-tests/constexpr_if/cfg.ql
Normal file
34
cpp/ql/test/library-tests/constexpr_if/cfg.ql
Normal file
@@ -0,0 +1,34 @@
|
||||
// query-type: graph
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user