Skip to content

Commit 2590d8a

Browse files
committed
Merge branch 'main' into redsun82/go
2 parents cb85a75 + 7e83979 commit 2590d8a

File tree

75 files changed

+902
-1333
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+902
-1333
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: breaking
3+
---
4+
* Deleted the deprecated `GlobalValueNumberingImpl.qll` implementation.

cpp/ql/lib/semmle/code/cpp/controlflow/IRGuards.qll

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1156,5 +1156,14 @@ private predicate add_eq(
11561156
)
11571157
}
11581158

1159+
private class IntegerOrPointerConstantInstruction extends ConstantInstruction {
1160+
IntegerOrPointerConstantInstruction() {
1161+
this instanceof IntegerConstantInstruction or
1162+
this instanceof PointerConstantInstruction
1163+
}
1164+
}
1165+
11591166
/** The int value of integer constant expression. */
1160-
private int int_value(Instruction i) { result = i.(IntegerConstantInstruction).getValue().toInt() }
1167+
private int int_value(Instruction i) {
1168+
result = i.(IntegerOrPointerConstantInstruction).getValue().toInt()
1169+
}

cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ class Instruction extends Construction::TStageInstruction {
247247
* Gets the type of the result produced by this instruction. If the instruction does not produce
248248
* a result, its result type will be `IRVoidType`.
249249
*/
250-
cached
251-
final IRType getResultIRType() { result = this.getResultLanguageType().getIRType() }
250+
final IRType getResultIRType() { result = Construction::getInstructionResultIRType(this) }
252251

253252
/**
254253
* Gets the type of the result produced by this instruction. If the
@@ -995,9 +994,8 @@ class ConstantInstruction extends ConstantValueInstruction {
995994
*/
996995
class IntegerConstantInstruction extends ConstantInstruction {
997996
IntegerConstantInstruction() {
998-
exists(IRType resultType |
999-
resultType = this.getResultIRType() and
1000-
(resultType instanceof IRIntegerType or resultType instanceof IRBooleanType)
997+
exists(IRType resultType | resultType = this.getResultIRType() |
998+
resultType instanceof IRIntegerType or resultType instanceof IRBooleanType
1001999
)
10021000
}
10031001
}
@@ -1009,6 +1007,17 @@ class FloatConstantInstruction extends ConstantInstruction {
10091007
FloatConstantInstruction() { this.getResultIRType() instanceof IRFloatingPointType }
10101008
}
10111009

1010+
/**
1011+
* An instruction whose result is a constant value of a pointer type.
1012+
*/
1013+
class PointerConstantInstruction extends ConstantInstruction {
1014+
PointerConstantInstruction() {
1015+
exists(IRType resultType | resultType = this.getResultIRType() |
1016+
resultType instanceof IRAddressType or resultType instanceof IRFunctionAddressType
1017+
)
1018+
}
1019+
}
1020+
10121021
/**
10131022
* An instruction whose result is the address of a string literal.
10141023
*/

cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,11 @@ private module Cached {
429429
instr = unreachedInstruction(_) and result = Language::getVoidType()
430430
}
431431

432+
cached
433+
IRType getInstructionResultIRType(Instruction instr) {
434+
result = instr.getResultLanguageType().getIRType()
435+
}
436+
432437
/**
433438
* Holds if `opcode` is the opcode that specifies the operation performed by `instr`.
434439
*

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/Instruction.qll

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ class Instruction extends Construction::TStageInstruction {
247247
* Gets the type of the result produced by this instruction. If the instruction does not produce
248248
* a result, its result type will be `IRVoidType`.
249249
*/
250-
cached
251-
final IRType getResultIRType() { result = this.getResultLanguageType().getIRType() }
250+
final IRType getResultIRType() { result = Construction::getInstructionResultIRType(this) }
252251

253252
/**
254253
* Gets the type of the result produced by this instruction. If the
@@ -995,9 +994,8 @@ class ConstantInstruction extends ConstantValueInstruction {
995994
*/
996995
class IntegerConstantInstruction extends ConstantInstruction {
997996
IntegerConstantInstruction() {
998-
exists(IRType resultType |
999-
resultType = this.getResultIRType() and
1000-
(resultType instanceof IRIntegerType or resultType instanceof IRBooleanType)
997+
exists(IRType resultType | resultType = this.getResultIRType() |
998+
resultType instanceof IRIntegerType or resultType instanceof IRBooleanType
1001999
)
10021000
}
10031001
}
@@ -1009,6 +1007,17 @@ class FloatConstantInstruction extends ConstantInstruction {
10091007
FloatConstantInstruction() { this.getResultIRType() instanceof IRFloatingPointType }
10101008
}
10111009

1010+
/**
1011+
* An instruction whose result is a constant value of a pointer type.
1012+
*/
1013+
class PointerConstantInstruction extends ConstantInstruction {
1014+
PointerConstantInstruction() {
1015+
exists(IRType resultType | resultType = this.getResultIRType() |
1016+
resultType instanceof IRAddressType or resultType instanceof IRFunctionAddressType
1017+
)
1018+
}
1019+
}
1020+
10121021
/**
10131022
* An instruction whose result is the address of a string literal.
10141023
*/

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,10 @@ CppType getInstructionResultType(TStageInstruction instr) {
377377
result = getVoidType()
378378
}
379379

380+
IRType getInstructionResultIRType(Instruction instr) {
381+
result = instr.getResultLanguageType().getIRType()
382+
}
383+
380384
predicate getInstructionOpcode(Opcode opcode, TStageInstruction instr) {
381385
getInstructionTranslatedElement(instr).hasInstruction(opcode, getInstructionTag(instr), _)
382386
or

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,11 @@ class TranslatedResultCopy extends TranslatedExpr, TTranslatedResultCopy {
538538
final override predicate producesExprResult() { any() }
539539

540540
private TranslatedCoreExpr getOperand() { result.getExpr() = expr }
541+
542+
override predicate handlesDestructorsExplicitly() {
543+
// The destructor calls will already have been generated by the translation of `expr`.
544+
any()
545+
}
541546
}
542547

543548
class TranslatedCommaExpr extends TranslatedNonConstantExpr {

cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ class Instruction extends Construction::TStageInstruction {
247247
* Gets the type of the result produced by this instruction. If the instruction does not produce
248248
* a result, its result type will be `IRVoidType`.
249249
*/
250-
cached
251-
final IRType getResultIRType() { result = this.getResultLanguageType().getIRType() }
250+
final IRType getResultIRType() { result = Construction::getInstructionResultIRType(this) }
252251

253252
/**
254253
* Gets the type of the result produced by this instruction. If the
@@ -995,9 +994,8 @@ class ConstantInstruction extends ConstantValueInstruction {
995994
*/
996995
class IntegerConstantInstruction extends ConstantInstruction {
997996
IntegerConstantInstruction() {
998-
exists(IRType resultType |
999-
resultType = this.getResultIRType() and
1000-
(resultType instanceof IRIntegerType or resultType instanceof IRBooleanType)
997+
exists(IRType resultType | resultType = this.getResultIRType() |
998+
resultType instanceof IRIntegerType or resultType instanceof IRBooleanType
1001999
)
10021000
}
10031001
}
@@ -1009,6 +1007,17 @@ class FloatConstantInstruction extends ConstantInstruction {
10091007
FloatConstantInstruction() { this.getResultIRType() instanceof IRFloatingPointType }
10101008
}
10111009

1010+
/**
1011+
* An instruction whose result is a constant value of a pointer type.
1012+
*/
1013+
class PointerConstantInstruction extends ConstantInstruction {
1014+
PointerConstantInstruction() {
1015+
exists(IRType resultType | resultType = this.getResultIRType() |
1016+
resultType instanceof IRAddressType or resultType instanceof IRFunctionAddressType
1017+
)
1018+
}
1019+
}
1020+
10121021
/**
10131022
* An instruction whose result is the address of a string literal.
10141023
*/

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,11 @@ private module Cached {
429429
instr = unreachedInstruction(_) and result = Language::getVoidType()
430430
}
431431

432+
cached
433+
IRType getInstructionResultIRType(Instruction instr) {
434+
result = instr.getResultLanguageType().getIRType()
435+
}
436+
432437
/**
433438
* Holds if `opcode` is the opcode that specifies the operation performed by `instr`.
434439
*

0 commit comments

Comments
 (0)