Skip to content

Commit c705797

Browse files
author
Dave Bartolomeo
committed
C++: IR construction for _Imaginary types
Includes a fairly exhaustive test case for arithmetic operations involving `_Complex` and/or `_Imaginary` types. Thanks to these new tests, I discovered that the extractor treats certain arithmetic operations on `_Imaginary` types as separate expression kinds, so I added support for those kinds in IR construction.
1 parent 3dd3b53 commit c705797

File tree

5 files changed

+2219
-79
lines changed

5 files changed

+2219
-79
lines changed

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

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,13 +1100,36 @@ private Opcode binaryBitwiseOpcode(BinaryBitwiseOperation expr) {
11001100
}
11011101

11021102
private Opcode binaryArithmeticOpcode(BinaryArithmeticOperation expr) {
1103-
expr instanceof AddExpr and result instanceof Opcode::Add
1103+
(
1104+
expr instanceof AddExpr
1105+
or
1106+
expr instanceof ImaginaryRealAddExpr
1107+
or
1108+
expr instanceof RealImaginaryAddExpr
1109+
) and
1110+
result instanceof Opcode::Add
11041111
or
1105-
expr instanceof SubExpr and result instanceof Opcode::Sub
1112+
(
1113+
expr instanceof SubExpr
1114+
or
1115+
expr instanceof ImaginaryRealSubExpr
1116+
or
1117+
expr instanceof RealImaginarySubExpr
1118+
) and
1119+
result instanceof Opcode::Sub
11061120
or
1107-
expr instanceof MulExpr and result instanceof Opcode::Mul
1121+
(
1122+
expr instanceof MulExpr
1123+
or
1124+
expr instanceof ImaginaryMulExpr
1125+
) and
1126+
result instanceof Opcode::Mul
11081127
or
1109-
expr instanceof DivExpr and result instanceof Opcode::Div
1128+
(
1129+
expr instanceof DivExpr or
1130+
expr instanceof ImaginaryDivExpr
1131+
) and
1132+
result instanceof Opcode::Div
11101133
or
11111134
expr instanceof RemExpr and result instanceof Opcode::Rem
11121135
or

0 commit comments

Comments
 (0)