& operator (ignoring any overloaded operator& for the type). The purpose of this builtin is for use in std::addressof, to allow it to be made constexpr; the existing implementation technique (reinterpret_cast to some reference type, take address, reinterpert_cast back) does not permit this because reinterpret_cast between reference types is not permitted in a constant expression in C++11 onwards. llvm-svn: 186053
18 lines
377 B
C++
18 lines
377 B
C++
// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
|
|
|
|
// PR8839
|
|
extern "C" char memmove();
|
|
|
|
int main() {
|
|
// CHECK: call {{signext i8|i8}} @memmove()
|
|
return memmove();
|
|
}
|
|
|
|
struct S;
|
|
// CHECK: define {{.*}} @_Z9addressofbR1SS0_(
|
|
S *addressof(bool b, S &s, S &t) {
|
|
// CHECK: %[[LVALUE:.*]] = phi
|
|
// CHECK: ret {{.*}}* %[[LVALUE]]
|
|
return __builtin_addressof(b ? s : t);
|
|
}
|