File tree Expand file tree Collapse file tree 3 files changed +16
-12
lines changed
cpp/ql/src/semmle/code/cpp
implementation/raw/internal Expand file tree Collapse file tree 3 files changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -442,6 +442,20 @@ class Expr extends StmtParent, @expr {
442442 else result = this
443443 }
444444
445+ /**
446+ * Gets the unique non-`Conversion` expression `e` for which
447+ * `this = e.getConversion*()`.
448+ *
449+ * For example, if called on the expression `(int)(char)x`, this predicate
450+ * gets the expression `x`.
451+ */
452+ Expr getUnconverted ( ) {
453+ not this instanceof Conversion and
454+ result = this
455+ or
456+ result = this .( Conversion ) .getExpr ( ) .getUnconverted ( )
457+ }
458+
445459 /**
446460 * Gets the type of this expression, after any implicit conversions and explicit casts, and after resolving typedefs.
447461 *
Original file line number Diff line number Diff line change @@ -131,10 +131,7 @@ class ExprNode extends InstructionNode {
131131 * `Conversion`, then the result is that `Conversion`'s non-`Conversion` base
132132 * expression.
133133 */
134- Expr getExpr ( ) {
135- result .getConversion * ( ) = instr .getConvertedResultExpression ( ) and
136- not result instanceof Conversion
137- }
134+ Expr getExpr ( ) { result = instr .getUnconvertedResultExpression ( ) }
138135
139136 /**
140137 * Gets the expression corresponding to this node, if any. The returned
Original file line number Diff line number Diff line change @@ -68,14 +68,7 @@ private module Cached {
6868
6969 cached
7070 Expr getInstructionUnconvertedResultExpression ( Instruction instruction ) {
71- exists ( Expr converted |
72- result = converted .( Conversion ) .getExpr + ( )
73- or
74- result = converted
75- |
76- not result instanceof Conversion and
77- converted = getInstructionConvertedResultExpression ( instruction )
78- )
71+ result = getInstructionConvertedResultExpression ( instruction ) .getUnconverted ( )
7972 }
8073
8174 cached
You can’t perform that action at this time.
0 commit comments