Skip to content

Commit 9429b03

Browse files
committed
C++: Provide a hook for overriding 'getResultType'.
1 parent 6dd1c5e commit 9429b03

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,19 @@ abstract class TranslatedExpr extends TranslatedElement {
5959

6060
final CppType getResultType() {
6161
if this.isResultGLValue()
62-
then result = getTypeForGLValue(expr.getType())
63-
else result = getTypeForPRValue(expr.getType())
62+
then result = getTypeForGLValue(this.getExprType())
63+
else result = getTypeForPRValue(this.getExprType())
6464
}
6565

66+
/**
67+
* Gets the type of `expr`.
68+
*
69+
* This predicate can be overwritten in subclasses to modify the result
70+
* of `getResultType` which determines the type of the instruction that
71+
* generates the result of `expr`.
72+
*/
73+
Type getExprType() { result = expr.getType() }
74+
6675
/**
6776
* Holds if the result of this `TranslatedExpr` is a glvalue.
6877
*/

0 commit comments

Comments
 (0)