[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / test / CodeGenCXX / mangle-address-space.cpp
blobd5294e3de499194def0eab8d39020869614bef8d
1 // RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -o - %s | FileCheck %s --check-prefixes=CHECK,CHECKNOOCL
2 // RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-msvc -o - %s | FileCheck %s --check-prefixes=WIN,WINNOOCL
3 // RUN: %clang_cc1 -cl-std=clc++ -emit-llvm -triple %itanium_abi_triple -o - %s | FileCheck %s --check-prefixes=CHECK,CHECKOCL
4 // RUN: %clang_cc1 -cl-std=clc++ -emit-llvm -triple x86_64-windows-msvc -o - %s | FileCheck %s --check-prefixes=WIN,WINOCL
6 // CHECKNOOCL-LABEL: define {{.*}}void @_Z2f0Pc
7 // WINNOOCL-LABEL: define {{.*}}void @"?f0@@YAXPEAD@Z"
8 // CHECKOCL-LABEL: define {{.*}}void @_Z2f0PU9CLgenericc
9 // WINOCL-LABEL: define {{.*}}void @"?f0@@YAXPEAU?$_ASCLgeneric@$$CAD@__clang@@@Z"
10 void f0(char *p) { }
11 // CHECK-LABEL: define {{.*}}void @_Z2f0PU3AS1c
12 // WIN-LABEL: define {{.*}}void @"?f0@@YAXPEAU?$_AS@$00$$CAD@__clang@@@Z"
13 void f0(char __attribute__((address_space(1))) *p) { }
15 struct OpaqueType;
16 typedef OpaqueType __attribute__((address_space(100))) * OpaqueTypePtr;
18 // CHECK-LABEL: define {{.*}}void @_Z2f0PU5AS10010OpaqueType
19 // WIN-LABEL: define {{.*}}void @"?f0@@YAXPEAU?$_AS@$0GE@$$CAUOpaqueType@@@__clang@@@Z"
20 void f0(OpaqueTypePtr) { }
22 // CHECK-LABEL: define {{.*}}void @_Z2f1PU3AS1Kc
23 // WIN-LABEL: define {{.*}}void @"?f1@@YAXPEAU?$_AS@$00$$CBD@__clang@@@Z"
24 void f1(char __attribute__((address_space(1))) const *p) {}
26 // Ensure we can do return values, which change in MS mode.
27 // CHECK-LABEL: define {{.*}}ptr addrspace(1) @_Z2f1PU3AS2Kc
28 // WIN-LABEL: define {{.*}}ptr addrspace(1) @"?f1@@YAPEAU?$_AS@$00$$CAM@__clang@@PEAU?$_AS@$01$$CBD@2@@Z"
29 __attribute__((address_space(1))) float *f1(char __attribute__((address_space(2))) const *p) { return 0;}
31 #if !defined(__OPENCL_CPP_VERSION__)
32 // Return value of address space without a pointer is invalid in opencl.
33 // Ensure we skip return values, since non-pointers aren't supposed to have an AS.
34 // CHECKNOOCL-LABEL: define {{.*}}float @_Z2f2PU3AS2Kc
35 // WINNOOCL-LABEL: define {{.*}}float @"?f2@@YA?AMQEAU?$_AS@$01$$CBD@__clang@@@Z"
36 __attribute__((address_space(1))) float f2(char __attribute__((address_space(2))) const * const p) { return 0;}
37 #endif
39 #ifdef __OPENCL_CPP_VERSION__
40 // CHECKOCL-LABEL: define {{.*}}void @_Z6ocl_f0PU9CLprivatec
41 // WINOCL-LABEL: define {{.*}}void @"?ocl_f0@@YAXPEAU?$_ASCLprivate@$$CAD@__clang@@@Z"
42 void ocl_f0(char __private *p) { }
44 struct ocl_OpaqueType;
45 typedef ocl_OpaqueType __global * ocl_OpaqueTypePtr;
46 typedef ocl_OpaqueType __attribute__((opencl_global_host)) * ocl_OpaqueTypePtrH;
47 typedef ocl_OpaqueType
48 __attribute__((opencl_global_device)) *
49 ocl_OpaqueTypePtrD;
51 // CHECKOCL-LABEL: define {{.*}}void @_Z6ocl_f0PU8CLglobal14ocl_OpaqueType
52 // WINOCL-LABEL: define {{.*}}void @"?ocl_f0@@YAXPEAU?$_ASCLglobal@$$CAUocl_OpaqueType@@@__clang@@@Z"
53 void ocl_f0(ocl_OpaqueTypePtr) { }
55 // CHECKOCL-LABEL: define {{.*}}void @_Z6ocl_f1PU10CLconstantKc
56 // WINOCL-LABEL: define {{.*}}void @"?ocl_f1@@YAXPEAU?$_ASCLconstant@$$CBD@__clang@@@Z"
57 void ocl_f1(char __constant const *p) {}
59 // Ensure we can do return values, which change in MS mode.
60 // CHECKOCL-LABEL: define {{.*}}ptr @_Z6ocl_f1PU9CLgenericKc
61 // WINOCL-LABEL: define {{.*}}ptr @"?ocl_f1@@YAPEAU?$_ASCLconstant@$$CAM@__clang@@PEAU?$_ASCLgeneric@$$CBD@2@@Z"
62 __constant float *ocl_f1(char __generic const *p) { return 0;}
64 // Ensure we skip return values, since non-pointers aren't supposed to have an AS.
65 // CHECKOCL-LABEL: define {{.*}}ptr @_Z6ocl_f2PU9CLgenericKc
66 // WINOCL-LABEL: define {{.*}}ptr @"?ocl_f2@@YAPEAU?$_ASCLgeneric@$$CAM@__clang@@QEAU?$_ASCLgeneric@$$CBD@2@@Z"
67 __generic float *ocl_f2(__generic char const * const p) { return 0;}
69 // CHECKOCL-LABEL: define {{.*}}void @_Z6ocl_f3PU6CLhost14ocl_OpaqueType
70 // WINOCL-LABEL: define {{.*}}void @"?ocl_f3@@YAXPEAU?$_ASCLhost@$$CAUocl_OpaqueType@@@__clang@@@Z"
71 void ocl_f3(ocl_OpaqueTypePtrH) {}
73 // CHECKOCL-LABEL: define {{.*}}void @_Z6ocl_f4PU8CLdevice14ocl_OpaqueType
74 // WINOCL-LABEL: define {{.*}}void @"?ocl_f4@@YAXPEAU?$_ASCLdevice@$$CAUocl_OpaqueType@@@__clang@@@Z"
75 void ocl_f4(ocl_OpaqueTypePtrD) {}
76 #endif