Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 953537e

Browse files
authored
Merge pull request #174 from nickrolfe/vec_fill
C++: support for clang `__builtin_addressof` and GNU vector fill operations
2 parents 272bed7 + ab05be7 commit 953537e

13 files changed

Lines changed: 3041 additions & 3175 deletions

File tree

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,20 @@ class BuiltInOperationBuiltInShuffleVector extends BuiltInOperation, @builtinshu
202202
override string toString() { result = "__builtin_shufflevector" }
203203
}
204204

205+
/**
206+
* A clang `__builtin_addressof` expression (can be used to implement C++'s std::addressof).
207+
*/
208+
class BuiltInOperationBuiltInAddressOf extends UnaryOperation, BuiltInOperation, @builtinaddressof {
209+
/** Gets the function or variable whose address is taken. */
210+
Declaration getAddressable() {
211+
result = this.getOperand().(Access).getTarget()
212+
// this handles the case where we are taking the address of a reference variable
213+
or result = this.getOperand().(ReferenceDereferenceExpr).getChild(0).(Access).getTarget()
214+
}
215+
216+
override string getOperator() { result = "__builtin_addressof" }
217+
}
218+
205219
/**
206220
* The `__is_trivially_constructible` type trait.
207221
*/
@@ -369,3 +383,10 @@ class BuiltInOperationIsFinal extends BuiltInOperation, @isfinalexpr {
369383
class BuiltInChooseExpr extends BuiltInOperation, @builtinchooseexpr {
370384
override string toString() { result = "__builtin_choose_expr" }
371385
}
386+
387+
/**
388+
* Fill operation on a GNU vector.
389+
*/
390+
class VectorFillOperation extends UnaryOperation, @vec_fill {
391+
override string getOperator() { result = "(vector fill)" }
392+
}

cpp/ql/src/semmlecode.cpp.dbscheme

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,6 +1429,8 @@ case @expr.kind of
14291429
| 319 = @noexceptexpr
14301430
| 320 = @builtinshufflevector
14311431
| 321 = @builtinchooseexpr
1432+
| 322 = @builtinaddressof
1433+
| 323 = @vec_fill
14321434
;
14331435

14341436
new_allocated_type(

0 commit comments

Comments
 (0)