C++: Consistently use getUnspecifiedType in structured binding IR translation

This commit is contained in:
Jeroen Ketema
2022-02-27 16:13:08 +01:00
parent 4ffbc2d148
commit 0a4d8132e6
2 changed files with 6 additions and 6 deletions

View File

@@ -895,15 +895,15 @@ class TranslatedStructuredBindingVariableAccess extends TranslatedNonConstantExp
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
tag = StructuredBindingAccessTag() and
opcode instanceof Opcode::VariableAddress and
resultType = getTypeForGLValue(this.getReferenceType())
resultType = getTypeForGLValue(this.getLValueReferenceType())
or
tag = LoadTag() and
opcode instanceof Opcode::Load and
resultType = getTypeForPRValue(this.getReferenceType())
resultType = getTypeForPRValue(this.getLValueReferenceType())
}
private Type getReferenceType() {
result.(LValueReferenceType).getBaseType() = expr.getUnderlyingType()
private LValueReferenceType getLValueReferenceType() {
result.getBaseType() = expr.getUnspecifiedType()
}
override Instruction getInstructionRegisterOperand(InstructionTag tag, OperandTag operandTag) {

View File

@@ -17,7 +17,7 @@ private Type getDecayedType(Type type) {
*/
predicate isNonReferenceStructuredBinding(Variable v) {
v.isStructuredBinding() and
not v.getUnderlyingType() instanceof ReferenceType
not v.getUnspecifiedType() instanceof ReferenceType
}
/**
@@ -41,7 +41,7 @@ Type getVariableType(Variable v) {
not exists(v.getInitializer()) and result = v.getType()
else
if isNonReferenceStructuredBinding(v)
then exists(LValueReferenceType r | r.getBaseType() = v.getUnderlyingType() | result = r)
then exists(LValueReferenceType r | r.getBaseType() = v.getUnspecifiedType() | result = r)
else result = v.getType()
)
}