File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
cpp/ql/lib/semmle/code/cpp/ir
implementation/raw/internal Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -1088,15 +1088,31 @@ private module GetConvertedResultExpression {
10881088 }
10891089
10901090 private Expr getConvertedResultExpressionImpl0 ( Instruction instr ) {
1091+ // For an expression such as `i += 2` we pretend that the generated
1092+ // `StoreInstruction` contains the result of the expression even though
1093+ // this isn't totally aligned with the C/C++ standard.
10911094 exists ( TranslatedAssignOperation tao |
10921095 result = tao .getExpr ( ) and
10931096 instr = tao .getInstruction ( any ( AssignmentStoreTag tag ) )
10941097 )
10951098 or
1099+ // Similarly for `i++` and `++i` we pretend that the generated
1100+ // `StoreInstruction` is contains the result of the expression even though
1101+ // this isn't totally aligned with the C/C++ standard.
10961102 exists ( TranslatedCrementOperation tco |
10971103 result = tco .getExpr ( ) and
10981104 instr = tco .getInstruction ( any ( CrementStoreTag tag ) )
10991105 )
1106+ or
1107+ // IR construction inserts an additional cast to a `size_t` on the extent
1108+ // of a `new[]` expression. The resulting `ConvertInstruction` doesn't have
1109+ // a result for `getConvertedResultExpression`. We remap this here so that
1110+ // this `ConvertInstruction` maps to the result of the expression that
1111+ // represents the extent.
1112+ exists ( TranslatedNonConstantAllocationSize tas |
1113+ result = tas .getExtent ( ) .getExpr ( ) and
1114+ instr = tas .getInstruction ( any ( AllocationExtentConvertTag tag ) )
1115+ )
11001116 }
11011117
11021118 private Expr getConvertedResultExpressionImpl ( Instruction instr ) {
Original file line number Diff line number Diff line change @@ -1956,9 +1956,7 @@ class TranslatedNonConstantAllocationSize extends TranslatedAllocationSize {
19561956 result = this .getExtent ( ) .getResult ( )
19571957 }
19581958
1959- private TranslatedExpr getExtent ( ) {
1960- result = getTranslatedExpr ( expr .getExtent ( ) .getFullyConverted ( ) )
1961- }
1959+ TranslatedExpr getExtent ( ) { result = getTranslatedExpr ( expr .getExtent ( ) .getFullyConverted ( ) ) }
19621960}
19631961
19641962/**
You can’t perform that action at this time.
0 commit comments