C++: class and test for clang's __builtin_addressof

This commit is contained in:
Nick Rolfe
2018-09-07 12:35:12 +01:00
parent 93103e1042
commit 2abf91b6ab
6 changed files with 36 additions and 7 deletions

View File

@@ -202,6 +202,20 @@ class BuiltInOperationBuiltInShuffleVector extends BuiltInOperation, @builtinshu
override string toString() { result = "__builtin_shufflevector" }
}
/**
* A clang `__builtin_addressof` expression (can be used to implement C++'s std::addressof).
*/
class BuiltInOperationBuiltInAddressOf extends UnaryOperation, BuiltInOperation, @builtinaddressof {
/** Gets the function or variable whose address is taken. */
Declaration getAddressable() {
result = this.getOperand().(Access).getTarget()
// this handles the case where we are taking the address of a reference variable
or result = this.getOperand().(ReferenceDereferenceExpr).getChild(0).(Access).getTarget()
}
override string getOperator() { result = "__builtin_addressof" }
}
/**
* The `__is_trivially_constructible` type trait.
*/