File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed
cpp/ql/src/semmle/code/cpp/ir/implementation
unaliased_ssa/gvn/internal Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff 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+
99112private predicate variableAddressValueNumber (
100113 VariableAddressInstruction instr , IRFunction irFunc , Language:: AST ast
101114) {
@@ -208,7 +221,11 @@ private predicate loadTotalOverlapValueNumber(
208221private 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/**
Original file line number Diff line number Diff 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+
99112private predicate variableAddressValueNumber (
100113 VariableAddressInstruction instr , IRFunction irFunc , Language:: AST ast
101114) {
@@ -208,7 +221,11 @@ private predicate loadTotalOverlapValueNumber(
208221private 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/**
You can’t perform that action at this time.
0 commit comments