xref: /llvm-project/clang/test/CodeGenCXX/mangle-exception-spec.cpp (revision 82da19ddb327df5d6f1a78d3fc012525ed2c7309)
1*82da19ddSRichard Smith // RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -Wno-dynamic-exception-spec | FileCheck %s --check-prefix CHECK --check-prefix CHECK-CXX11
2*82da19ddSRichard Smith // RUN: %clang_cc1 -std=c++1z -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -Wno-dynamic-exception-spec | FileCheck %s --check-prefix CHECK --check-prefix CHECK-CXX17
3fda59e58SRichard Smith 
4fda59e58SRichard Smith // CHECK: define {{.*}} @_Z1aPFivE(
a(int ()throw (int,float))5fda59e58SRichard Smith void a(int() throw(int, float)) {}
6fda59e58SRichard Smith // CHECK-CXX11: define {{.*}} @_Z1bPFivE(
7ef09aa90SRichard Smith // CHECK-CXX17: define {{.*}} @_Z1bPDoFivE(
b(int ()noexcept)8fda59e58SRichard Smith void b(int() noexcept) {}
9fda59e58SRichard Smith // CHECK-CXX11: define {{.*}} @_Z1cPFivE(
10ef09aa90SRichard Smith // CHECK-CXX17: define {{.*}} @_Z1cPDoFivE(
c(int ()throw ())11fda59e58SRichard Smith void c(int() throw()) {}
12fda59e58SRichard Smith // CHECK: define {{.*}} @_Z1dPFivE(
d(int ()noexcept (false))13fda59e58SRichard Smith void d(int() noexcept(false)) {}
14fda59e58SRichard Smith // CHECK-CXX11: define {{.*}} @_Z1ePFivE(
15ef09aa90SRichard Smith // CHECK-CXX17: define {{.*}} @_Z1ePDoFivE(
e(int ()noexcept (true))16fda59e58SRichard Smith void e(int() noexcept(true)) {}
17fda59e58SRichard Smith 
f(int ()noexcept (B))18fda59e58SRichard Smith template<bool B> void f(int() noexcept(B)) {}
19ef09aa90SRichard Smith // CHECK: define {{.*}} @_Z1fILb0EEvPDOT_EFivE(
20fda59e58SRichard Smith template void f<false>(int());
21ef09aa90SRichard Smith // CHECK: define {{.*}} @_Z1fILb1EEvPDOT_EFivE(
22fda59e58SRichard Smith template void f<true>(int() noexcept);
23fda59e58SRichard Smith 
g(int ()throw (T...))24fda59e58SRichard Smith template<typename...T> void g(int() throw(T...)) {}
25ef09aa90SRichard Smith // CHECK: define {{.*}} @_Z1gIJEEvPDwDpT_EFivE(
26fda59e58SRichard Smith template void g<>(int() noexcept);
27ef09aa90SRichard Smith // CHECK: define {{.*}} @_Z1gIJfEEvPDwDpT_EFivE(
28fda59e58SRichard Smith template void g<float>(int());
29fda59e58SRichard Smith 
30fda59e58SRichard Smith // We consider the exception specifications in parameter and return type here
31fda59e58SRichard Smith // to be different.
h(int ()throw (int,T...))32fda59e58SRichard Smith template<typename...T> auto h(int() throw(int, T...)) -> int (*)() throw(T..., int) { return nullptr; }
33ef09aa90SRichard Smith // CHECK: define {{.*}} @_Z1hIJEEPDwDpT_iEFivEPDwiS1_EFivE(
34fda59e58SRichard Smith template auto h<>(int()) -> int (*)();
35ef09aa90SRichard Smith // CHECK: define {{.*}} @_Z1hIJfEEPDwDpT_iEFivEPDwiS1_EFivE(
36fda59e58SRichard Smith template auto h<float>(int()) -> int (*)();
37fda59e58SRichard Smith 
38fda59e58SRichard Smith // FIXME: The C++11 manglings here are wrong; they should be the same as the
39fda59e58SRichard Smith // C++17 manglings.
40fda59e58SRichard Smith // The mangler mishandles substitutions for instantiation-dependent types that
41fda59e58SRichard Smith // differ only in type sugar that is not relevant for mangling. (In this case,
42fda59e58SRichard Smith // the types differ in presence/absence of ParenType nodes under the pointer.)
i(int ()throw (int,T...))43fda59e58SRichard Smith template<typename...T> auto i(int() throw(int, T...)) -> int (*)() throw(int, T...) { return nullptr; }
44ef09aa90SRichard Smith // CHECK-CXX11: define {{.*}} @_Z1iIJEEPDwiDpT_EFivEPS2_(
45ef09aa90SRichard Smith // CHECK-CXX17: define {{.*}} @_Z1iIJEEPDwiDpT_EFivES3_(
46fda59e58SRichard Smith template auto i<>(int()) -> int (*)();
47ef09aa90SRichard Smith // CHECK-CXX11: define {{.*}} @_Z1iIJfEEPDwiDpT_EFivEPS2_(
48ef09aa90SRichard Smith // CHECK-CXX17: define {{.*}} @_Z1iIJfEEPDwiDpT_EFivES3_(
49fda59e58SRichard Smith template auto i<float>(int()) -> int (*)();
50