mirror of
https://github.com/github/codeql.git
synced 2026-04-27 09:45:15 +02:00
CPP: QLDoc comments.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user