Debian Codegraph @

clang/test/AST/ByteCode/pointer-to-fnptr.cpp

raw
1 // RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -o - %s -fexperimental-new-constant-interpreter | FileCheck %s
3
4 template<typename T>
5 struct Wrapper {
6 T *Val;
7
8 template<typename _Up>
9 constexpr Wrapper(_Up&& __u) {
10 T& __f = static_cast<_Up&&>(__u);
11 Val = &__f;
12 }
13 constexpr T& get() const { return *Val; }
14 };
15
16 void f(){}
17 int main() {
18 auto W = Wrapper<decltype(f)>(f);
19
20 if (&W.get() != &f)
21 __builtin_abort();
22 }
23
24 /// We used to convert do the pointer->fnptr conversion
25 /// by doing an integer conversion in between, which caused the
26 /// %0 line to be:
27 /// store ptr inttoptr (i64 138574454870464 to ptr), ptr %__f, align 8
28 // CHECK: @_ZN7WrapperIFvvEEC2IRS0_EEOT_
29 // CHECK: %0 = load ptr, ptr %__u.addr