Skip to content

Commit 740518d

Browse files
committed
C++: Use the loaded this instead of the this initialization
1 parent 1a2f722 commit 740518d

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2679,7 +2679,7 @@ class TranslatedDestructorFieldDestruction extends TranslatedNonConstantExpr, St
26792679
final override Instruction getInstructionRegisterOperand(InstructionTag tag, OperandTag operandTag) {
26802680
tag = OnlyInstructionTag() and
26812681
operandTag instanceof UnaryOperandTag and
2682-
result = getTranslatedFunction(getEnclosingFunction(expr)).getInitializeThisInstruction()
2682+
result = getTranslatedFunction(getEnclosingFunction(expr)).getLoadThisInstruction()
26832683
}
26842684

26852685
final override Field getInstructionField(InstructionTag tag) {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,11 @@ class TranslatedFunction extends TranslatedRootElement, TTranslatedFunction {
306306
final predicate hasReturnValue() { hasReturnValue(func) }
307307

308308
/**
309-
* Gets the single `InitializeThis` instruction for this function. Holds only
310-
* if the function is an instance member function, constructor, or destructor.
309+
* Gets the first load of `this` for this function. Holds only if the function
310+
* is an instance member function, constructor, or destructor.
311311
*/
312-
final Instruction getInitializeThisInstruction() {
313-
result = getTranslatedThisParameter(func).getInstruction(InitializerStoreTag())
312+
final Instruction getLoadThisInstruction() {
313+
result = getTranslatedThisParameter(func).getInstruction(InitializerIndirectAddressTag())
314314
}
315315

316316
/**
@@ -639,7 +639,7 @@ class TranslatedConstructorInitList extends TranslatedElement, InitializationCon
639639
}
640640

641641
override Instruction getTargetAddress() {
642-
result = getTranslatedFunction(func).getInitializeThisInstruction()
642+
result = getTranslatedFunction(func).getLoadThisInstruction()
643643
}
644644

645645
override Type getTargetType() { result = getTranslatedFunction(func).getThisType() }

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ abstract class TranslatedBaseStructorCall extends TranslatedStructorCallFromStru
950950
final override Instruction getInstructionRegisterOperand(InstructionTag tag, OperandTag operandTag) {
951951
tag = OnlyInstructionTag() and
952952
operandTag instanceof UnaryOperandTag and
953-
result = getTranslatedFunction(this.getFunction()).getInitializeThisInstruction()
953+
result = getTranslatedFunction(this.getFunction()).getLoadThisInstruction()
954954
}
955955

956956
final override predicate getInstructionInheritance(
@@ -1000,7 +1000,7 @@ class TranslatedConstructorDelegationInit extends TranslatedConstructorCallFromC
10001000
}
10011001

10021002
final override Instruction getReceiver() {
1003-
result = getTranslatedFunction(this.getFunction()).getInitializeThisInstruction()
1003+
result = getTranslatedFunction(this.getFunction()).getLoadThisInstruction()
10041004
}
10051005
}
10061006

0 commit comments

Comments
 (0)