mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
C++: Ensure we use lvalue reference types for structured bindings
This also adds a test for rvalue reference uses in the tuple structured binding case.
This commit is contained in:
@@ -903,7 +903,7 @@ class TranslatedStructuredBindingVariableAccess extends TranslatedNonConstantExp
|
||||
}
|
||||
|
||||
private Type getReferenceType() {
|
||||
result.(ReferenceType).getBaseType() = expr.getUnderlyingType()
|
||||
result.(LValueReferenceType).getBaseType() = expr.getUnderlyingType()
|
||||
}
|
||||
|
||||
override Instruction getInstructionRegisterOperand(InstructionTag tag, OperandTag operandTag) {
|
||||
|
||||
@@ -41,7 +41,7 @@ Type getVariableType(Variable v) {
|
||||
not exists(v.getInitializer()) and result = v.getType()
|
||||
else
|
||||
if isNonReferenceStructuredBinding(v)
|
||||
then exists(ReferenceType r | r.getBaseType() = v.getUnderlyingType() | result = r)
|
||||
then exists(LValueReferenceType r | r.getBaseType() = v.getUnderlyingType() | result = r)
|
||||
else result = v.getType()
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user