Skip to content

Commit d816701

Browse files
committed
Revert "C++: Use StackVariable in Nullness.qll"
It looks like allowing statics in `Nullness.qll` is fine since it's a "may be null" analysis rather than a "must be null" analysis. This reverts commit f5b9837.
1 parent 0731309 commit d816701

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

cpp/ql/src/semmle/code/cpp/controlflow/Nullness.qll

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Zero extends NullValue {
1818
*/
1919
cached
2020
predicate nullCheckExpr(Expr checkExpr, Variable var) {
21-
exists(StackVariable v, AnalysedExpr expr |
21+
exists(LocalScopeVariable v, AnalysedExpr expr |
2222
var = v and
2323
checkExpr = expr
2424
|
@@ -67,7 +67,7 @@ predicate nullCheckExpr(Expr checkExpr, Variable var) {
6767
*/
6868
cached
6969
predicate validCheckExpr(Expr checkExpr, Variable var) {
70-
exists(AnalysedExpr expr, StackVariable v |
70+
exists(AnalysedExpr expr, LocalScopeVariable v |
7171
v = var and
7272
expr = checkExpr
7373
|
@@ -123,19 +123,19 @@ class AnalysedExpr extends Expr {
123123
/**
124124
* Holds if `v` is null when this expression evaluates to a true value.
125125
*/
126-
predicate isNullCheck(StackVariable v) { nullCheckExpr(this, v) }
126+
predicate isNullCheck(LocalScopeVariable v) { nullCheckExpr(this, v) }
127127

128128
/**
129129
* Holds if `v` is non-null when this expression evaluates to a true value.
130130
*/
131-
predicate isValidCheck(StackVariable v) { validCheckExpr(this, v) }
131+
predicate isValidCheck(LocalScopeVariable v) { validCheckExpr(this, v) }
132132

133133
/**
134134
* Gets a successor of `this` in the control flow graph, where that successor
135135
* is among the nodes to which control may flow when `this` tests `v` to be
136136
* _null_.
137137
*/
138-
ControlFlowNode getNullSuccessor(StackVariable v) {
138+
ControlFlowNode getNullSuccessor(LocalScopeVariable v) {
139139
this.isNullCheck(v) and result = this.getATrueSuccessor()
140140
or
141141
this.isValidCheck(v) and result = this.getAFalseSuccessor()
@@ -146,7 +146,7 @@ class AnalysedExpr extends Expr {
146146
* is among the nodes to which control may flow when `this` tests `v` to be
147147
* _not null_.
148148
*/
149-
ControlFlowNode getNonNullSuccessor(StackVariable v) {
149+
ControlFlowNode getNonNullSuccessor(LocalScopeVariable v) {
150150
this.isNullCheck(v) and result = this.getAFalseSuccessor()
151151
or
152152
this.isValidCheck(v) and result = this.getATrueSuccessor()
@@ -155,7 +155,7 @@ class AnalysedExpr extends Expr {
155155
/**
156156
* DEPRECATED: Use `getNonNullSuccessor` instead, which does the same.
157157
*/
158-
deprecated ControlFlowNode getValidSuccessor(StackVariable v) {
158+
deprecated ControlFlowNode getValidSuccessor(LocalScopeVariable v) {
159159
this.isValidCheck(v) and result = this.getATrueSuccessor()
160160
or
161161
this.isNullCheck(v) and result = this.getAFalseSuccessor()
@@ -164,15 +164,15 @@ class AnalysedExpr extends Expr {
164164
/**
165165
* Holds if this is a `VariableAccess` of `v` nested inside a condition.
166166
*/
167-
predicate isUse(StackVariable v) {
167+
predicate isUse(LocalScopeVariable v) {
168168
this.inCondition() and
169169
this = v.getAnAccess()
170170
}
171171

172172
/**
173173
* Holds if this is an `Assignment` to `v` nested inside a condition.
174174
*/
175-
predicate isDef(StackVariable v) {
175+
predicate isDef(LocalScopeVariable v) {
176176
this.inCondition() and
177177
this.(Assignment).getLValue() = v.getAnAccess()
178178
}
@@ -192,7 +192,7 @@ class AnalysedExpr extends Expr {
192192
*/
193193
cached
194194
predicate checkedNull(Variable var, ControlFlowNode node) {
195-
exists(StackVariable v | v = var |
195+
exists(LocalScopeVariable v | v = var |
196196
exists(AnalysedExpr e | e.getNullSuccessor(v) = node)
197197
or
198198
exists(ControlFlowNode pred |
@@ -208,7 +208,7 @@ predicate checkedNull(Variable var, ControlFlowNode node) {
208208
*/
209209
cached
210210
predicate checkedValid(Variable var, ControlFlowNode node) {
211-
exists(StackVariable v | v = var |
211+
exists(LocalScopeVariable v | v = var |
212212
exists(AnalysedExpr e | e.getNonNullSuccessor(v) = node)
213213
or
214214
exists(ControlFlowNode pred |
@@ -277,7 +277,7 @@ predicate mayReturnNull(Function f) {
277277
ret.getEnclosingFunction() = f
278278
)
279279
or
280-
exists(ReturnStmt ret, Expr returned, ControlFlowNode init, StackVariable v |
280+
exists(ReturnStmt ret, Expr returned, ControlFlowNode init, LocalScopeVariable v |
281281
ret.getExpr() = returned and
282282
nullInit(v, init) and
283283
definitionUsePair(v, init, returned) and

0 commit comments

Comments
 (0)