mirror of
https://github.com/github/codeql.git
synced 2026-05-02 04:05:14 +02:00
Merge pull request #2115 from nickrolfe/builtin_complex
C++: support `__builtin_complex`
This commit is contained in:
@@ -519,3 +519,18 @@ class BuiltInChooseExpr extends BuiltInOperation, @builtinchooseexpr {
|
||||
class VectorFillOperation extends UnaryOperation, @vec_fill {
|
||||
override string getOperator() { result = "(vector fill)" }
|
||||
}
|
||||
|
||||
/**
|
||||
* The GNU `__builtin_complex` operation.
|
||||
*/
|
||||
class BuiltInComplexOperation extends BuiltInOperation, @builtincomplex {
|
||||
override string toString() { result = "__builtin_complex" }
|
||||
|
||||
override string getCanonicalQLClass() { result = "BuiltInComplexOperation" }
|
||||
|
||||
/** Gets the operand corresponding to the real part of the complex number. */
|
||||
Expr getRealOperand() { this.hasChild(result, 0) }
|
||||
|
||||
/** Gets the operand corresponding to the imaginary part of the complex number. */
|
||||
Expr getImaginaryOperand() { this.hasChild(result, 1) }
|
||||
}
|
||||
|
||||
@@ -1515,6 +1515,7 @@ case @expr.kind of
|
||||
| 322 = @builtinaddressof
|
||||
| 323 = @vec_fill
|
||||
| 324 = @builtinconvertvector
|
||||
| 325 = @builtincomplex
|
||||
;
|
||||
|
||||
new_allocated_type(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,4 @@
|
||||
| complex.c:3:23:3:51 | __builtin_complex | file://:0:0:0:0 | _Complex double | complex.c:3:41:3:44 | real | file://:0:0:0:0 | double | complex.c:3:47:3:50 | imag | file://:0:0:0:0 | double |
|
||||
| complex.c:4:23:4:57 | __builtin_complex | file://:0:0:0:0 | _Complex double | complex.c:4:41:4:47 | 2.71828000000000003 | file://:0:0:0:0 | double | complex.c:4:50:4:56 | 3.141589999999999883 | file://:0:0:0:0 | double |
|
||||
| complex.c:8:22:8:52 | __builtin_complex | file://:0:0:0:0 | _Complex float | complex.c:8:40:8:44 | realf | file://:0:0:0:0 | float | complex.c:8:47:8:51 | imagf | file://:0:0:0:0 | float |
|
||||
| complex.c:9:22:9:52 | __builtin_complex | file://:0:0:0:0 | _Complex float | complex.c:9:40:9:44 | 1.230000019 | file://:0:0:0:0 | float | complex.c:9:47:9:51 | 4.559999943 | file://:0:0:0:0 | float |
|
||||
7
cpp/ql/test/library-tests/builtins/complex/builtin.ql
Normal file
7
cpp/ql/test/library-tests/builtins/complex/builtin.ql
Normal file
@@ -0,0 +1,7 @@
|
||||
import cpp
|
||||
|
||||
from BuiltInComplexOperation bico, Expr real, Expr imag
|
||||
where
|
||||
real = bico.getRealOperand() and
|
||||
imag = bico.getImaginaryOperand()
|
||||
select bico, bico.getType(), real, real.getType(), imag, imag.getType()
|
||||
10
cpp/ql/test/library-tests/builtins/complex/complex.c
Normal file
10
cpp/ql/test/library-tests/builtins/complex/complex.c
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
void builtin_double(double real, double imag) {
|
||||
_Complex double a = __builtin_complex(real, imag);
|
||||
_Complex double b = __builtin_complex(2.71828, 3.14159);
|
||||
}
|
||||
|
||||
void builtin_float(float realf, float imagf) {
|
||||
_Complex float c = __builtin_complex(realf, imagf);
|
||||
_Complex float d = __builtin_complex(1.23f, 4.56f);
|
||||
}
|
||||
1915
cpp/upgrades/0ed3da4a31c3a3dd01d9bb84d7908cf64b9f31a3/old.dbscheme
Normal file
1915
cpp/upgrades/0ed3da4a31c3a3dd01d9bb84d7908cf64b9f31a3/old.dbscheme
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
description: Add support for __builtin_complex
|
||||
compatibility: backwards
|
||||
Reference in New Issue
Block a user