Skip to content

Commit b4ff121

Browse files
author
Robert Marsh
committed
C++: sync identical files
1 parent 0f58887 commit b4ff121

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,19 @@ private predicate numberableInstruction(Instruction instr) {
9696
instr instanceof LoadTotalOverlapInstruction
9797
}
9898

99+
private predicate filteredNumberableInstruction(Instruction instr) {
100+
// count rather than strictcount to handle missing AST elements
101+
// separate instanceof and inline casts to avoid failed casts with a count of 0
102+
instr instanceof VariableAddressInstruction and
103+
count(instr.(VariableAddressInstruction).getIRVariable().getAST()) != 1
104+
or
105+
instr instanceof ConstantInstruction and
106+
count(instr.getResultIRType()) != 1
107+
or
108+
instr instanceof FieldAddressInstruction and
109+
count(instr.(FieldAddressInstruction).getField()) != 1
110+
}
111+
99112
private predicate variableAddressValueNumber(
100113
VariableAddressInstruction instr, IRFunction irFunc, Language::AST ast
101114
) {
@@ -208,7 +221,11 @@ private predicate loadTotalOverlapValueNumber(
208221
private predicate uniqueValueNumber(Instruction instr, IRFunction irFunc) {
209222
instr.getEnclosingIRFunction() = irFunc and
210223
not instr.getResultIRType() instanceof IRVoidType and
211-
not numberableInstruction(instr)
224+
(
225+
not numberableInstruction(instr)
226+
or
227+
filteredNumberableInstruction(instr)
228+
)
212229
}
213230

214231
/**

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,19 @@ private predicate numberableInstruction(Instruction instr) {
9696
instr instanceof LoadTotalOverlapInstruction
9797
}
9898

99+
private predicate filteredNumberableInstruction(Instruction instr) {
100+
// count rather than strictcount to handle missing AST elements
101+
// separate instanceof and inline casts to avoid failed casts with a count of 0
102+
instr instanceof VariableAddressInstruction and
103+
count(instr.(VariableAddressInstruction).getIRVariable().getAST()) != 1
104+
or
105+
instr instanceof ConstantInstruction and
106+
count(instr.getResultIRType()) != 1
107+
or
108+
instr instanceof FieldAddressInstruction and
109+
count(instr.(FieldAddressInstruction).getField()) != 1
110+
}
111+
99112
private predicate variableAddressValueNumber(
100113
VariableAddressInstruction instr, IRFunction irFunc, Language::AST ast
101114
) {
@@ -208,7 +221,11 @@ private predicate loadTotalOverlapValueNumber(
208221
private predicate uniqueValueNumber(Instruction instr, IRFunction irFunc) {
209222
instr.getEnclosingIRFunction() = irFunc and
210223
not instr.getResultIRType() instanceof IRVoidType and
211-
not numberableInstruction(instr)
224+
(
225+
not numberableInstruction(instr)
226+
or
227+
filteredNumberableInstruction(instr)
228+
)
212229
}
213230

214231
/**

0 commit comments

Comments
 (0)