CPP: QLDoc comments.

This commit is contained in:
Geoffrey White
2019-01-10 17:38:42 +00:00
parent ba3bc1596b
commit 87569d14b9

View File

@@ -12,12 +12,16 @@ import cpp
// See also InitialisationNotRun.ql and GlobalUseBeforeInit.ql
// Holds if s defines variable v (conservative)
/**
* Holds if `s` defines variable `v` (conservative).
*/
predicate defines(ControlFlowNode s, Variable lv) {
exists(VariableAccess va | va = s and va.getTarget() = lv and va.isUsedAsLValue())
}
// Holds if s uses variable v (conservative)
/**
* Holds if `s` uses variable `v` (conservative).
*/
predicate uses(ControlFlowNode s, Variable lv) {
exists(VariableAccess va |
va = s and
@@ -27,8 +31,10 @@ predicate uses(ControlFlowNode s, Variable lv) {
)
}
// Holds if there is a path from the declaration of lv to n such that lv is
// definitely not defined before n
/**
* Holds if there is a path from the declaration of `lv` to `n` such that `lv` is
* definitely not defined before `n`.
*/
predicate noDefPath(LocalVariable lv, ControlFlowNode n) {
n.(DeclStmt).getADeclaration() = lv and not exists(lv.getInitializer())
or
@@ -37,8 +43,10 @@ predicate noDefPath(LocalVariable lv, ControlFlowNode n) {
predicate isAggregateType(Type t) { t instanceof Class or t instanceof ArrayType }
// Holds if va is a use of a local variable that has not been previously
// defined
/**
* Holds if `va` is a use of a local variable that has not been previously
* defined.
*/
predicate undefinedLocalUse(VariableAccess va) {
exists(LocalVariable lv |
// it is hard to tell when a struct or array has been initialized, so we
@@ -51,7 +59,9 @@ predicate undefinedLocalUse(VariableAccess va) {
)
}
// Holds if gv is a potentially uninitialized global variable
/**
* Holds if `gv` is a potentially uninitialized global variable.
*/
predicate uninitialisedGlobal(GlobalVariable gv) {
exists(VariableAccess va |
not isAggregateType(gv.getUnderlyingType()) and