Skip to content

Commit 0c2cfa1

Browse files
committed
C++: Add comment on the existence of reference types
1 parent 497991b commit 0c2cfa1

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,7 @@ class TranslatedStructuredBindingVariableAccess extends TranslatedNonConstantExp
912912
}
913913

914914
private LValueReferenceType getLValueReferenceType() {
915+
// The extractor ensures `result` exists when `isNonReferenceStructuredBinding(expr.getTarget())` holds.
915916
result.getBaseType() = expr.getUnspecifiedType()
916917
}
917918

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ 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.getUnspecifiedType() | result = r)
44+
then
45+
// The extractor ensures `r` exists when `isNonReferenceStructuredBinding(v)` holds.
46+
exists(LValueReferenceType r | r.getBaseType() = v.getUnspecifiedType() | result = r)
4547
else result = v.getType()
4648
)
4749
}

0 commit comments

Comments
 (0)