From d1daca541e882c84313b290c5d01519ad273fd55 Mon Sep 17 00:00:00 2001 From: Sauyon Lee Date: Tue, 20 Apr 2021 13:45:53 -0700 Subject: [PATCH] Add types for more tuple extractions Specifically, extractions where the RHS is a map element read or a channel receive will now have types. --- ql/src/semmle/go/controlflow/IR.qll | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ql/src/semmle/go/controlflow/IR.qll b/ql/src/semmle/go/controlflow/IR.qll index f5313794506..ec25b62ad69 100644 --- a/ql/src/semmle/go/controlflow/IR.qll +++ b/ql/src/semmle/go/controlflow/IR.qll @@ -751,6 +751,18 @@ module IR { result = tae.getType().(TupleType).getComponentType(pragma[only_bind_into](i)) ) or + exists(Instruction mapBase | this.getBase().readsElement(mapBase, _) | + i = 0 and result = mapBase.getResultType().getUnderlyingType().(MapType).getValueType() + or + i = 1 and result = any(BoolExprType b) + ) + or + exists(RecvExpr re | this.getBase() = evalExprInstruction(re) | + i = 0 and result = re.getOperand().getType().getUnderlyingType().(ChanType).getElementType() + or + i = 1 and result = any(BoolExprType b) + ) + or exists(Type rangeType | rangeType = s.(RangeStmt).getDomain().getType().getUnderlyingType() | exists(Type baseType | baseType = rangeType.(ArrayType).getElementType() or