xref: /llvm-project/clang/test/CodeGen/uwtable-attr.c (revision 46b0d0eef9e0a7290851cce0d44002b750584f1b)
1 // Test that function and modules attributes react on the command-line options,
2 // it does not state the current behaviour makes sense in all cases (it does not).
3 
4 // RUN: %clang -target x86_64-linux -S -emit-llvm -o - %s                                                    | FileCheck %s -check-prefixes=CHECK,DEFAULT
5 // RUN: %clang -target x86_64-linux -S -emit-llvm -o - %s -funwind-tables    -fno-asynchronous-unwind-tables | FileCheck %s -check-prefixes=CHECK,TABLES
6 // RUN: %clang -target x86_64-linux -S -emit-llvm -o - %s -fno-unwind-tables -fno-asynchronous-unwind-tables | FileCheck %s -check-prefixes=CHECK,NO_TABLES
7 
8 // RUN: %clang -target x86_64-linux -S -emit-llvm -o - -x c++ %s                                                                     | FileCheck %s -check-prefixes=CHECK,DEFAULT
9 // RUN: %clang -target x86_64-linux -S -emit-llvm -o - -x c++ %s                  -funwind-tables    -fno-asynchronous-unwind-tables | FileCheck %s -check-prefixes=CHECK,TABLES
10 // RUN: %clang -target x86_64-linux -S -emit-llvm -o - -x c++ %s  -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables | FileCheck %s -check-prefixes=CHECK,NO_TABLES
11 
12 // REQUIRES: x86-registered-target
13 
14 #ifdef __cplusplus
15 extern "C" void g(void);
16 struct S { ~S(); };
f()17 extern "C" int f() { S s; g(); return 0;};
18 #else
19 void g(void);
f(void)20 int f(void) { g(); return 0; };
21 #endif
22 
23 // CHECK: define {{.*}} @f() #[[#F:]]
24 // CHECK: declare {{.*}} @g() #[[#]]
25 
26 // DEFAULT: attributes #[[#F]] = { {{.*}} uwtable{{ }}{{.*}} }
27 // DEFAULT: ![[#]] = !{i32 7, !"uwtable", i32 2}
28 
29 // TABLES: attributes #[[#F]] = { {{.*}} uwtable(sync){{.*}} }
30 // TABLES: ![[#]] = !{i32 7, !"uwtable", i32 1}
31 
32 // NO_TABLES-NOT: uwtable
33