mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
C++: Consistently use getUnspecifiedType in structured binding IR translation
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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()
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user