File tree Expand file tree Collapse file tree 9 files changed +7137
-7107
lines changed
src/semmle/code/cpp/ir/implementation
valuenumbering/GlobalValueNumbering
csharp/ql/src/semmle/code/csharp/ir/implementation Expand file tree Collapse file tree 9 files changed +7137
-7107
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import Imports::IRType
99import Imports:: MemoryAccessKind
1010import Imports:: Opcode
1111private import Imports:: OperandTag
12+ import semmle.code.cpp.ir.implementation.internal.PrintSupport
1213
1314module InstructionSanity {
1415 /**
@@ -368,6 +369,12 @@ class Instruction extends Construction::TInstruction {
368369 )
369370 }
370371
372+ int getLineRank ( ) {
373+ this = rank [ result ] ( Instruction instr | instr .getAST ( ) .getFile ( ) = getAST ( ) .getFile ( ) and instr .getAST ( ) .getLocation ( ) .getStartLine ( ) = getAST ( ) .getLocation ( ) .getStartLine ( ) | instr
374+ order by instr .getBlock ( ) .getDisplayIndex ( ) , instr .getDisplayIndexInBlock ( )
375+ )
376+ }
377+
371378 /**
372379 * Gets a human-readable string that uniquely identifies this instruction
373380 * within the function. This string is used to refer to this instruction when
@@ -376,8 +383,7 @@ class Instruction extends Construction::TInstruction {
376383 * Example: `r1_1`
377384 */
378385 string getResultId ( ) {
379- result = getResultPrefix ( ) + getBlock ( ) .getDisplayIndex ( ) .toString ( ) + "_" +
380- getDisplayIndexInBlock ( ) .toString ( )
386+ result = getResultPrefix ( ) + getAST ( ) .getLocation ( ) .getStartLine ( ) + "_" + getLineRank ( )
381387 }
382388
383389 /**
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import Imports::IRType
99import Imports:: MemoryAccessKind
1010import Imports:: Opcode
1111private import Imports:: OperandTag
12+ import semmle.code.cpp.ir.implementation.internal.PrintSupport
1213
1314module InstructionSanity {
1415 /**
@@ -368,6 +369,12 @@ class Instruction extends Construction::TInstruction {
368369 )
369370 }
370371
372+ int getLineRank ( ) {
373+ this = rank [ result ] ( Instruction instr | instr .getAST ( ) .getFile ( ) = getAST ( ) .getFile ( ) and instr .getAST ( ) .getLocation ( ) .getStartLine ( ) = getAST ( ) .getLocation ( ) .getStartLine ( ) | instr
374+ order by instr .getBlock ( ) .getDisplayIndex ( ) , instr .getDisplayIndexInBlock ( )
375+ )
376+ }
377+
371378 /**
372379 * Gets a human-readable string that uniquely identifies this instruction
373380 * within the function. This string is used to refer to this instruction when
@@ -376,8 +383,7 @@ class Instruction extends Construction::TInstruction {
376383 * Example: `r1_1`
377384 */
378385 string getResultId ( ) {
379- result = getResultPrefix ( ) + getBlock ( ) .getDisplayIndex ( ) .toString ( ) + "_" +
380- getDisplayIndexInBlock ( ) .toString ( )
386+ result = getResultPrefix ( ) + getAST ( ) .getLocation ( ) .getStartLine ( ) + "_" + getLineRank ( )
381387 }
382388
383389 /**
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import Imports::IRType
99import Imports:: MemoryAccessKind
1010import Imports:: Opcode
1111private import Imports:: OperandTag
12+ import semmle.code.cpp.ir.implementation.internal.PrintSupport
1213
1314module InstructionSanity {
1415 /**
@@ -368,6 +369,12 @@ class Instruction extends Construction::TInstruction {
368369 )
369370 }
370371
372+ int getLineRank ( ) {
373+ this = rank [ result ] ( Instruction instr | instr .getAST ( ) .getFile ( ) = getAST ( ) .getFile ( ) and instr .getAST ( ) .getLocation ( ) .getStartLine ( ) = getAST ( ) .getLocation ( ) .getStartLine ( ) | instr
374+ order by instr .getBlock ( ) .getDisplayIndex ( ) , instr .getDisplayIndexInBlock ( )
375+ )
376+ }
377+
371378 /**
372379 * Gets a human-readable string that uniquely identifies this instruction
373380 * within the function. This string is used to refer to this instruction when
@@ -376,8 +383,7 @@ class Instruction extends Construction::TInstruction {
376383 * Example: `r1_1`
377384 */
378385 string getResultId ( ) {
379- result = getResultPrefix ( ) + getBlock ( ) .getDisplayIndex ( ) .toString ( ) + "_" +
380- getDisplayIndexInBlock ( ) .toString ( )
386+ result = getResultPrefix ( ) + getAST ( ) .getLocation ( ) .getStartLine ( ) + "_" + getLineRank ( )
381387 }
382388
383389 /**
Load Diff Large diffs are not rendered by default.
Load Diff Large diffs are not rendered by default.
Load Diff Large diffs are not rendered by default.
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import Imports::IRType
99import Imports:: MemoryAccessKind
1010import Imports:: Opcode
1111private import Imports:: OperandTag
12+ import semmle.code.cpp.ir.implementation.internal.PrintSupport
1213
1314module InstructionSanity {
1415 /**
@@ -368,6 +369,12 @@ class Instruction extends Construction::TInstruction {
368369 )
369370 }
370371
372+ int getLineRank ( ) {
373+ this = rank [ result ] ( Instruction instr | instr .getAST ( ) .getFile ( ) = getAST ( ) .getFile ( ) and instr .getAST ( ) .getLocation ( ) .getStartLine ( ) = getAST ( ) .getLocation ( ) .getStartLine ( ) | instr
374+ order by instr .getBlock ( ) .getDisplayIndex ( ) , instr .getDisplayIndexInBlock ( )
375+ )
376+ }
377+
371378 /**
372379 * Gets a human-readable string that uniquely identifies this instruction
373380 * within the function. This string is used to refer to this instruction when
@@ -376,8 +383,7 @@ class Instruction extends Construction::TInstruction {
376383 * Example: `r1_1`
377384 */
378385 string getResultId ( ) {
379- result = getResultPrefix ( ) + getBlock ( ) .getDisplayIndex ( ) .toString ( ) + "_" +
380- getDisplayIndexInBlock ( ) .toString ( )
386+ result = getResultPrefix ( ) + getAST ( ) .getLocation ( ) .getStartLine ( ) + "_" + getLineRank ( )
381387 }
382388
383389 /**
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import Imports::IRType
99import Imports:: MemoryAccessKind
1010import Imports:: Opcode
1111private import Imports:: OperandTag
12+ import semmle.code.cpp.ir.implementation.internal.PrintSupport
1213
1314module InstructionSanity {
1415 /**
@@ -368,6 +369,12 @@ class Instruction extends Construction::TInstruction {
368369 )
369370 }
370371
372+ int getLineRank ( ) {
373+ this = rank [ result ] ( Instruction instr | instr .getAST ( ) .getFile ( ) = getAST ( ) .getFile ( ) and instr .getAST ( ) .getLocation ( ) .getStartLine ( ) = getAST ( ) .getLocation ( ) .getStartLine ( ) | instr
374+ order by instr .getBlock ( ) .getDisplayIndex ( ) , instr .getDisplayIndexInBlock ( )
375+ )
376+ }
377+
371378 /**
372379 * Gets a human-readable string that uniquely identifies this instruction
373380 * within the function. This string is used to refer to this instruction when
@@ -376,8 +383,7 @@ class Instruction extends Construction::TInstruction {
376383 * Example: `r1_1`
377384 */
378385 string getResultId ( ) {
379- result = getResultPrefix ( ) + getBlock ( ) .getDisplayIndex ( ) .toString ( ) + "_" +
380- getDisplayIndexInBlock ( ) .toString ( )
386+ result = getResultPrefix ( ) + getAST ( ) .getLocation ( ) .getStartLine ( ) + "_" + getLineRank ( )
381387 }
382388
383389 /**
You can’t perform that action at this time.
0 commit comments