Skip to content

Commit 0a4d813

Browse files
committed
C++: Consistently use getUnspecifiedType in structured binding IR translation
1 parent 4ffbc2d commit 0a4d813

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -895,15 +895,15 @@ class TranslatedStructuredBindingVariableAccess extends TranslatedNonConstantExp
895895
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
896896
tag = StructuredBindingAccessTag() and
897897
opcode instanceof Opcode::VariableAddress and
898-
resultType = getTypeForGLValue(this.getReferenceType())
898+
resultType = getTypeForGLValue(this.getLValueReferenceType())
899899
or
900900
tag = LoadTag() and
901901
opcode instanceof Opcode::Load and
902-
resultType = getTypeForPRValue(this.getReferenceType())
902+
resultType = getTypeForPRValue(this.getLValueReferenceType())
903903
}
904904

905-
private Type getReferenceType() {
906-
result.(LValueReferenceType).getBaseType() = expr.getUnderlyingType()
905+
private LValueReferenceType getLValueReferenceType() {
906+
result.getBaseType() = expr.getUnspecifiedType()
907907
}
908908

909909
override Instruction getInstructionRegisterOperand(InstructionTag tag, OperandTag operandTag) {

cpp/ql/lib/semmle/code/cpp/ir/internal/IRUtilities.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ private Type getDecayedType(Type type) {
1717
*/
1818
predicate isNonReferenceStructuredBinding(Variable v) {
1919
v.isStructuredBinding() and
20-
not v.getUnderlyingType() instanceof ReferenceType
20+
not v.getUnspecifiedType() instanceof ReferenceType
2121
}
2222

2323
/**
@@ -41,7 +41,7 @@ Type getVariableType(Variable v) {
4141
not exists(v.getInitializer()) and result = v.getType()
4242
else
4343
if isNonReferenceStructuredBinding(v)
44-
then exists(LValueReferenceType r | r.getBaseType() = v.getUnderlyingType() | result = r)
44+
then exists(LValueReferenceType r | r.getBaseType() = v.getUnspecifiedType() | result = r)
4545
else result = v.getType()
4646
)
4747
}

0 commit comments

Comments
 (0)