Skip to content

Commit 53720a3

Browse files
Merge pull request github#2115 from nickrolfe/builtin_complex
C++: support `__builtin_complex`
2 parents dca8081 + 22fa657 commit 53720a3

File tree

9 files changed

+4241
-377
lines changed

9 files changed

+4241
-377
lines changed

cpp/ql/src/semmle/code/cpp/exprs/BuiltInOperations.qll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,3 +519,18 @@ class BuiltInChooseExpr extends BuiltInOperation, @builtinchooseexpr {
519519
class VectorFillOperation extends UnaryOperation, @vec_fill {
520520
override string getOperator() { result = "(vector fill)" }
521521
}
522+
523+
/**
524+
* The GNU `__builtin_complex` operation.
525+
*/
526+
class BuiltInComplexOperation extends BuiltInOperation, @builtincomplex {
527+
override string toString() { result = "__builtin_complex" }
528+
529+
override string getCanonicalQLClass() { result = "BuiltInComplexOperation" }
530+
531+
/** Gets the operand corresponding to the real part of the complex number. */
532+
Expr getRealOperand() { this.hasChild(result, 0) }
533+
534+
/** Gets the operand corresponding to the imaginary part of the complex number. */
535+
Expr getImaginaryOperand() { this.hasChild(result, 1) }
536+
}

cpp/ql/src/semmlecode.cpp.dbscheme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,7 @@ case @expr.kind of
15151515
| 322 = @builtinaddressof
15161516
| 323 = @vec_fill
15171517
| 324 = @builtinconvertvector
1518+
| 325 = @builtincomplex
15181519
;
15191520

15201521
new_allocated_type(

0 commit comments

Comments
 (0)