Skip to content

Commit 59dd892

Browse files
committed
C++: Address review, fix bug related to Conversions.
1 parent 1b88ca1 commit 59dd892

File tree

3 files changed

+56
-56
lines changed

3 files changed

+56
-56
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class PrintASTNode extends TPrintASTNode {
123123
* Adds edges to fully converted expressions, that are not part of the
124124
* regular parent/child relation traversal.
125125
*/
126-
PrintASTNode getChild(int childIndex) {
126+
final PrintASTNode getChild(int childIndex) {
127127
result = getChildInternal(childIndex)
128128
or
129129
// We first compute the first available child index that is not used by
@@ -133,7 +133,7 @@ class PrintASTNode extends TPrintASTNode {
133133
exists(int nonConvertedIndex, int nextAvailableIndex, Expr expr |
134134
nextAvailableIndex = max(int idx | exists(this.getChildInternal(idx))) + 1 and
135135
childIndex - nextAvailableIndex = nonConvertedIndex and
136-
expr = getChild(nonConvertedIndex).(ASTNode).getAST()
136+
expr = getChildInternal(nonConvertedIndex).(ASTNode).getAST()
137137
|
138138
expr.getFullyConverted() instanceof Conversion and
139139
result.(ASTNode).getAST() = expr.getFullyConverted() and
@@ -186,7 +186,7 @@ class PrintASTNode extends TPrintASTNode {
186186
* Gets the label for the edge from this node to the specified child,
187187
* including labels for edges to nodes that represent conversions.
188188
*/
189-
string getChildEdgeLabel(int childIndex) {
189+
final string getChildEdgeLabel(int childIndex) {
190190
exists(getChildInternal(childIndex)) and
191191
result = getChildEdgeLabelInternal(childIndex)
192192
or
@@ -286,7 +286,7 @@ class ConversionNode extends ExprNode {
286286

287287
ConversionNode() { conv = expr }
288288

289-
override ASTNode getChild(int childIndex) {
289+
override ASTNode getChildInternal(int childIndex) {
290290
childIndex = 0 and
291291
result.getAST() = conv.getExpr() and
292292
conv.getExpr() instanceof Conversion

cpp/ql/test/examples/expressions/PrintAST.expected

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,12 @@ Conversion3.cpp:
302302
# 2| Type = [IntType] int
303303
# 2| Value = [CStyleCast] 1
304304
# 2| ValueCategory = prvalue
305-
# 2| : [CStyleCast] (bool)...
305+
# 2| expr: [CStyleCast] (bool)...
306306
# 2| Conversion = [BoolConversion] conversion to bool
307307
# 2| Type = [BoolType] bool
308308
# 2| Value = [CStyleCast] 1
309309
# 2| ValueCategory = prvalue
310-
# 2| : [CStyleCast] (int)...
310+
# 2| expr: [CStyleCast] (int)...
311311
# 2| Conversion = [IntegralConversion] integral conversion
312312
# 2| Type = [IntType] int
313313
# 2| Value = [CStyleCast] 1
@@ -316,7 +316,7 @@ Conversion3.cpp:
316316
# 2| Type = [IntType] int
317317
# 2| Value = [ParenthesisExpr] 7
318318
# 2| ValueCategory = prvalue
319-
# 2| : [CStyleCast] (int)...
319+
# 2| expr: [CStyleCast] (int)...
320320
# 2| Conversion = [IntegralConversion] integral conversion
321321
# 2| Type = [IntType] int
322322
# 2| Value = [CStyleCast] 7
@@ -343,7 +343,7 @@ Conversion4.c:
343343
# 2| Type = [IntType] int
344344
# 2| Value = [ParenthesisExpr] 7
345345
# 2| ValueCategory = prvalue
346-
# 2| : [CStyleCast] (int)...
346+
# 2| expr: [CStyleCast] (int)...
347347
# 2| Conversion = [IntegralConversion] integral conversion
348348
# 2| Type = [IntType] int
349349
# 2| Value = [CStyleCast] 7
@@ -362,11 +362,11 @@ Conversion4.c:
362362
# 6| Conversion = [PointerConversion] pointer conversion
363363
# 6| Type = [CharPointerType] char *
364364
# 6| ValueCategory = prvalue
365-
# 6| : [CStyleCast] (void *)...
365+
# 6| expr: [CStyleCast] (void *)...
366366
# 6| Conversion = [PointerConversion] pointer conversion
367367
# 6| Type = [VoidPointerType] void *
368368
# 6| ValueCategory = prvalue
369-
# 6| : [CStyleCast] (int *)...
369+
# 6| expr: [CStyleCast] (int *)...
370370
# 6| Conversion = [PointerConversion] pointer conversion
371371
# 6| Type = [IntPointerType] int *
372372
# 6| ValueCategory = prvalue
@@ -565,15 +565,15 @@ DynamicCast.cpp:
565565
# 13| 0 converted: [ReferenceToExpr] (reference to)
566566
# 13| Type = [LValueReferenceType] const Derived &
567567
# 13| ValueCategory = prvalue
568-
# 13| : [CStyleCast] (const Derived)...
568+
# 13| expr: [CStyleCast] (const Derived)...
569569
# 13| Conversion = [GlvalueConversion] glvalue conversion
570570
# 13| Type = [SpecifiedType] const Derived
571571
# 13| ValueCategory = lvalue
572-
# 13| : [DynamicCast] dynamic_cast<Derived>...
572+
# 13| expr: [DynamicCast] dynamic_cast<Derived>...
573573
# 13| Conversion = [DynamicCast] dynamic_cast
574574
# 13| Type = [Class] Derived
575575
# 13| ValueCategory = lvalue
576-
# 13| : [ReferenceDereferenceExpr] (reference dereference)
576+
# 13| expr: [ReferenceDereferenceExpr] (reference dereference)
577577
# 13| Type = [Class] Base
578578
# 13| ValueCategory = lvalue
579579
# 13| 0 converted: [ReferenceDereferenceExpr] (reference dereference)

0 commit comments

Comments
 (0)