Skip to content

Commit 93bd380

Browse files
committed
C#/C++: Sync identical files.
1 parent 6b324fb commit 93bd380

File tree

4 files changed

+48
-32
lines changed

4 files changed

+48
-32
lines changed

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/gvn/internal/ValueNumberingInternal.qll

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ private predicate filteredNumberableInstruction(Instruction instr) {
106106
or
107107
instr instanceof FieldAddressInstruction and
108108
count(instr.(FieldAddressInstruction).getField()) != 1
109+
or
110+
instr instanceof InheritanceConversionInstruction and
111+
(
112+
count(instr.(InheritanceConversionInstruction).getBaseClass()) != 1 or
113+
count(instr.(InheritanceConversionInstruction).getDerivedClass()) != 1
114+
)
109115
}
110116

111117
private predicate variableAddressValueNumber(
@@ -115,8 +121,7 @@ private predicate variableAddressValueNumber(
115121
// The underlying AST element is used as value-numbering key instead of the
116122
// `IRVariable` to work around a problem where a variable or expression with
117123
// multiple types gives rise to multiple `IRVariable`s.
118-
instr.getIRVariable().getAST() = ast and
119-
strictcount(instr.getIRVariable().getAST()) = 1
124+
unique( | | instr.getIRVariable().getAST()) = ast
120125
}
121126

122127
private predicate initializeParameterValueNumber(
@@ -133,8 +138,7 @@ private predicate constantValueNumber(
133138
ConstantInstruction instr, IRFunction irFunc, IRType type, string value
134139
) {
135140
instr.getEnclosingIRFunction() = irFunc and
136-
strictcount(instr.getResultIRType()) = 1 and
137-
instr.getResultIRType() = type and
141+
unique( | | instr.getResultIRType()) = type and
138142
instr.getValue() = value
139143
}
140144

@@ -152,7 +156,7 @@ private predicate fieldAddressValueNumber(
152156
) {
153157
instr.getEnclosingIRFunction() = irFunc and
154158
instr.getField() = field and
155-
strictcount(instr.getField()) = 1 and
159+
unique( | | instr.getField()) = field and
156160
tvalueNumber(instr.getObjectAddress()) = objectAddress
157161
}
158162

@@ -195,9 +199,9 @@ private predicate inheritanceConversionValueNumber(
195199
) {
196200
instr.getEnclosingIRFunction() = irFunc and
197201
instr.getOpcode() = opcode and
198-
instr.getBaseClass() = baseClass and
199-
instr.getDerivedClass() = derivedClass and
200-
tvalueNumber(instr.getUnary()) = operand
202+
tvalueNumber(instr.getUnary()) = operand and
203+
unique( | | instr.(InheritanceConversionInstruction).getBaseClass()) = baseClass and
204+
unique( | | instr.(InheritanceConversionInstruction).getDerivedClass()) = derivedClass
201205
}
202206

203207
private predicate loadTotalOverlapValueNumber(

cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/gvn/internal/ValueNumberingInternal.qll

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ private predicate filteredNumberableInstruction(Instruction instr) {
106106
or
107107
instr instanceof FieldAddressInstruction and
108108
count(instr.(FieldAddressInstruction).getField()) != 1
109+
or
110+
instr instanceof InheritanceConversionInstruction and
111+
(
112+
count(instr.(InheritanceConversionInstruction).getBaseClass()) != 1 or
113+
count(instr.(InheritanceConversionInstruction).getDerivedClass()) != 1
114+
)
109115
}
110116

111117
private predicate variableAddressValueNumber(
@@ -115,8 +121,7 @@ private predicate variableAddressValueNumber(
115121
// The underlying AST element is used as value-numbering key instead of the
116122
// `IRVariable` to work around a problem where a variable or expression with
117123
// multiple types gives rise to multiple `IRVariable`s.
118-
instr.getIRVariable().getAST() = ast and
119-
strictcount(instr.getIRVariable().getAST()) = 1
124+
unique( | | instr.getIRVariable().getAST()) = ast
120125
}
121126

122127
private predicate initializeParameterValueNumber(
@@ -133,8 +138,7 @@ private predicate constantValueNumber(
133138
ConstantInstruction instr, IRFunction irFunc, IRType type, string value
134139
) {
135140
instr.getEnclosingIRFunction() = irFunc and
136-
strictcount(instr.getResultIRType()) = 1 and
137-
instr.getResultIRType() = type and
141+
unique( | | instr.getResultIRType()) = type and
138142
instr.getValue() = value
139143
}
140144

@@ -152,7 +156,7 @@ private predicate fieldAddressValueNumber(
152156
) {
153157
instr.getEnclosingIRFunction() = irFunc and
154158
instr.getField() = field and
155-
strictcount(instr.getField()) = 1 and
159+
unique( | | instr.getField()) = field and
156160
tvalueNumber(instr.getObjectAddress()) = objectAddress
157161
}
158162

@@ -195,9 +199,9 @@ private predicate inheritanceConversionValueNumber(
195199
) {
196200
instr.getEnclosingIRFunction() = irFunc and
197201
instr.getOpcode() = opcode and
198-
instr.getBaseClass() = baseClass and
199-
instr.getDerivedClass() = derivedClass and
200-
tvalueNumber(instr.getUnary()) = operand
202+
tvalueNumber(instr.getUnary()) = operand and
203+
unique( | | instr.(InheritanceConversionInstruction).getBaseClass()) = baseClass and
204+
unique( | | instr.(InheritanceConversionInstruction).getDerivedClass()) = derivedClass
201205
}
202206

203207
private predicate loadTotalOverlapValueNumber(

csharp/ql/src/experimental/ir/implementation/raw/gvn/internal/ValueNumberingInternal.qll

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ private predicate filteredNumberableInstruction(Instruction instr) {
106106
or
107107
instr instanceof FieldAddressInstruction and
108108
count(instr.(FieldAddressInstruction).getField()) != 1
109+
or
110+
instr instanceof InheritanceConversionInstruction and
111+
(
112+
count(instr.(InheritanceConversionInstruction).getBaseClass()) != 1 or
113+
count(instr.(InheritanceConversionInstruction).getDerivedClass()) != 1
114+
)
109115
}
110116

111117
private predicate variableAddressValueNumber(
@@ -115,8 +121,7 @@ private predicate variableAddressValueNumber(
115121
// The underlying AST element is used as value-numbering key instead of the
116122
// `IRVariable` to work around a problem where a variable or expression with
117123
// multiple types gives rise to multiple `IRVariable`s.
118-
instr.getIRVariable().getAST() = ast and
119-
strictcount(instr.getIRVariable().getAST()) = 1
124+
unique( | | instr.getIRVariable().getAST()) = ast
120125
}
121126

122127
private predicate initializeParameterValueNumber(
@@ -133,8 +138,7 @@ private predicate constantValueNumber(
133138
ConstantInstruction instr, IRFunction irFunc, IRType type, string value
134139
) {
135140
instr.getEnclosingIRFunction() = irFunc and
136-
strictcount(instr.getResultIRType()) = 1 and
137-
instr.getResultIRType() = type and
141+
unique( | | instr.getResultIRType()) = type and
138142
instr.getValue() = value
139143
}
140144

@@ -152,7 +156,7 @@ private predicate fieldAddressValueNumber(
152156
) {
153157
instr.getEnclosingIRFunction() = irFunc and
154158
instr.getField() = field and
155-
strictcount(instr.getField()) = 1 and
159+
unique( | | instr.getField()) = field and
156160
tvalueNumber(instr.getObjectAddress()) = objectAddress
157161
}
158162

@@ -195,9 +199,9 @@ private predicate inheritanceConversionValueNumber(
195199
) {
196200
instr.getEnclosingIRFunction() = irFunc and
197201
instr.getOpcode() = opcode and
198-
instr.getBaseClass() = baseClass and
199-
instr.getDerivedClass() = derivedClass and
200-
tvalueNumber(instr.getUnary()) = operand
202+
tvalueNumber(instr.getUnary()) = operand and
203+
unique( | | instr.(InheritanceConversionInstruction).getBaseClass()) = baseClass and
204+
unique( | | instr.(InheritanceConversionInstruction).getDerivedClass()) = derivedClass
201205
}
202206

203207
private predicate loadTotalOverlapValueNumber(

csharp/ql/src/experimental/ir/implementation/unaliased_ssa/gvn/internal/ValueNumberingInternal.qll

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ private predicate filteredNumberableInstruction(Instruction instr) {
106106
or
107107
instr instanceof FieldAddressInstruction and
108108
count(instr.(FieldAddressInstruction).getField()) != 1
109+
or
110+
instr instanceof InheritanceConversionInstruction and
111+
(
112+
count(instr.(InheritanceConversionInstruction).getBaseClass()) != 1 or
113+
count(instr.(InheritanceConversionInstruction).getDerivedClass()) != 1
114+
)
109115
}
110116

111117
private predicate variableAddressValueNumber(
@@ -115,8 +121,7 @@ private predicate variableAddressValueNumber(
115121
// The underlying AST element is used as value-numbering key instead of the
116122
// `IRVariable` to work around a problem where a variable or expression with
117123
// multiple types gives rise to multiple `IRVariable`s.
118-
instr.getIRVariable().getAST() = ast and
119-
strictcount(instr.getIRVariable().getAST()) = 1
124+
unique( | | instr.getIRVariable().getAST()) = ast
120125
}
121126

122127
private predicate initializeParameterValueNumber(
@@ -133,8 +138,7 @@ private predicate constantValueNumber(
133138
ConstantInstruction instr, IRFunction irFunc, IRType type, string value
134139
) {
135140
instr.getEnclosingIRFunction() = irFunc and
136-
strictcount(instr.getResultIRType()) = 1 and
137-
instr.getResultIRType() = type and
141+
unique( | | instr.getResultIRType()) = type and
138142
instr.getValue() = value
139143
}
140144

@@ -152,7 +156,7 @@ private predicate fieldAddressValueNumber(
152156
) {
153157
instr.getEnclosingIRFunction() = irFunc and
154158
instr.getField() = field and
155-
strictcount(instr.getField()) = 1 and
159+
unique( | | instr.getField()) = field and
156160
tvalueNumber(instr.getObjectAddress()) = objectAddress
157161
}
158162

@@ -195,9 +199,9 @@ private predicate inheritanceConversionValueNumber(
195199
) {
196200
instr.getEnclosingIRFunction() = irFunc and
197201
instr.getOpcode() = opcode and
198-
instr.getBaseClass() = baseClass and
199-
instr.getDerivedClass() = derivedClass and
200-
tvalueNumber(instr.getUnary()) = operand
202+
tvalueNumber(instr.getUnary()) = operand and
203+
unique( | | instr.(InheritanceConversionInstruction).getBaseClass()) = baseClass and
204+
unique( | | instr.(InheritanceConversionInstruction).getDerivedClass()) = derivedClass
201205
}
202206

203207
private predicate loadTotalOverlapValueNumber(

0 commit comments

Comments
 (0)