Skip to content

Commit a842ed5

Browse files
committed
CPP: Integrate and produce full results.
1 parent e143870 commit a842ed5

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

cpp/ql/src/semmle/code/cpp/Variable.qll

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ class Variable extends Declaration, @variable {
117117
or
118118
exists (AssignExpr ae
119119
| ae.getLValue().(Access).getTarget() = this and result = ae.getRValue())
120+
or
121+
exists(AggregateLiteral l |
122+
this.getDeclaringType() = l.getType() and
123+
result = l.getChild(this.(Field).getInitializationOrder())
124+
)
120125
}
121126

122127
/**
@@ -163,14 +168,6 @@ class Variable extends Declaration, @variable {
163168
predicate isCompilerGenerated() { compgenerated(underlyingElement(this)) }
164169
}
165170

166-
class ExtendedField extends Field {
167-
override Expr getAnAssignedValue() {
168-
exists(AggregateLiteral l |
169-
this.getDeclaringType() = l.getType() and result = l.getChild(this.getInitializationOrder())
170-
)
171-
}
172-
}
173-
174171
/**
175172
* A particular declaration or definition of a C/C++ variable.
176173
*/

cpp/ql/test/library-tests/variables/getanassignedvalue/getanassignedvalue.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
| test.cpp:10:10:10:11 | 13 | test.cpp:6:7:6:11 | ref_v |
88
| test.cpp:11:6:11:10 | ... + ... | test.cpp:4:6:4:6 | v |
99
| test.cpp:19:32:19:35 | 0.0 | test.cpp:19:27:19:28 | _y |
10+
| test.cpp:19:42:19:43 | _x | test.cpp:24:8:24:8 | x |
11+
| test.cpp:19:49:19:50 | _y | test.cpp:24:11:24:11 | y |
12+
| test.cpp:19:54:19:60 | 0.0 | test.cpp:24:14:24:14 | z |
1013
| test.cpp:35:16:35:25 | {...} | test.cpp:35:11:35:12 | v1 |
1114
| test.cpp:35:17:35:17 | 1 | test.cpp:31:6:31:8 | num |
1215
| test.cpp:35:20:35:24 | One | test.cpp:32:14:32:16 | str |

0 commit comments

Comments
 (0)