C++: Add comment on the existence of reference types

This commit is contained in:
Jeroen Ketema
2022-02-28 19:09:36 +01:00
parent 497991b6b1
commit 0c2cfa1307
2 changed files with 4 additions and 1 deletions

View File

@@ -912,6 +912,7 @@ class TranslatedStructuredBindingVariableAccess extends TranslatedNonConstantExp
}
private LValueReferenceType getLValueReferenceType() {
// The extractor ensures `result` exists when `isNonReferenceStructuredBinding(expr.getTarget())` holds.
result.getBaseType() = expr.getUnspecifiedType()
}

View File

@@ -41,7 +41,9 @@ Type getVariableType(Variable v) {
not exists(v.getInitializer()) and result = v.getType()
else
if isNonReferenceStructuredBinding(v)
then exists(LValueReferenceType r | r.getBaseType() = v.getUnspecifiedType() | result = r)
then
// The extractor ensures `r` exists when `isNonReferenceStructuredBinding(v)` holds.
exists(LValueReferenceType r | r.getBaseType() = v.getUnspecifiedType() | result = r)
else result = v.getType()
)
}