1 // REQUIRES: x86-registered-target
2 // RUN: %clang -DINLINE=inline -target x86_64-unknown-linux-gnu -o - \
3 // RUN: -emit-interface-stubs \
4 // RUN: -interface-stub-version=experimental-ifs-v1 -std=gnu89 -xc %s | \
5 // RUN: FileCheck -check-prefix=CHECK-GNU %s
6 // RUN: %clang -DINLINE=inline -target x86_64-linux-gnu -O0 -o - -c \
7 // RUN: -std=gnu89 -xc %s | llvm-nm - | FileCheck -check-prefix=CHECK-GNU %s
8 
9 // RUN: %clang -DINLINE="__attribute__((always_inline))" \
10 // RUN: -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
11 // RUN: -interface-stub-version=experimental-ifs-v1 -xc %s | \
12 // RUN: FileCheck -check-prefix=CHECK-GNU %s
13 // RUN: %clang -DINLINE="__attribute__((always_inline))" \
14 // RUN: -target x86_64-linux-gnu -O0 -o - -c -xc %s | \
15 // RUN: llvm-nm - | FileCheck -check-prefix=CHECK-GNU %s
16 
17 // RUN: %clang -DINLINE=inline -target x86_64-unknown-linux-gnu -o - \
18 // RUN: -emit-interface-stubs \
19 // RUN: -interface-stub-version=experimental-ifs-v1 -std=c99 -xc %s | \
20 // RUN: FileCheck -check-prefix=CHECK-STD %s
21 // RUN: %clang -DINLINE=inline -target x86_64-linux-gnu -O0 -o - -c -std=c99 \
22 // RUN: -xc %s | llvm-nm - 2>&1 | FileCheck -check-prefix=CHECK-STD %s
23 
24 // RUN: %clang -DINLINE="__attribute__((noinline))" \
25 // RUN: -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
26 // RUN: -interface-stub-version=experimental-ifs-v1 -std=c99 -xc %s | \
27 // RUN: FileCheck -check-prefix=CHECK-NOINLINE %s
28 // RUN: %clang -DINLINE="__attribute__((noinline))" -target x86_64-linux-gnu \
29 // RUN: -O0 -o - -c -std=c99 -xc %s | llvm-nm - 2>&1 | \
30 // RUN: FileCheck -check-prefix=CHECK-NOINLINE %s
31 
32 // RUN: %clang -DINLINE="static" -target x86_64-unknown-linux-gnu -o - \
33 // RUN: -emit-interface-stubs \
34 // RUN: -interface-stub-version=experimental-ifs-v1 -std=c99 -xc %s | \
35 // RUN: FileCheck -check-prefix=CHECK-STATIC %s
36 // RUN: %clang -DINLINE="static" -target x86_64-linux-gnu -O0 -o - -c \
37 // RUN: -std=c99 -xc %s | llvm-nm - 2>&1 | \
38 // RUN: FileCheck -check-prefix=CHECK-STATIC %s
39 
40 // CHECK-GNU-DAG: foo
41 // CHECK-GNU-DAG: foo.var
42 // CHECK-NOINLINE-DAG: foo
43 // CHECK-NOINLINE-DAG: foo.var
44 // CHECK-STATIC-NOT: foo
45 // CHECK-STATIC-NOT: foo.var
46 // CHECK-STD-NOT: foo
47 #pragma clang diagnostic ignored "-Wstatic-local-in-inline"
48 INLINE int foo() {
49   static int var = 42;
50   return var;
51 }
52 
53 // RUN: %clang -DINLINE=inline -target x86_64-linux-gnu -o - \
54 // RUN: -emit-interface-stubs -interface-stub-version=experimental-ifs-v1 \
55 // RUN: -std=gnu89 -xc %s | FileCheck -check-prefix=CHECK-TAPI %s
56 
57 // RUN: %clang -DINLINE=inline -target x86_64-linux-gnu -o - \
58 // RUN: -emit-interface-stubs -interface-stub-version=experimental-ifs-v1 \
59 // RUN: -std=gnu89 -xc %s | FileCheck -check-prefix=CHECK-SYMBOLS %s
60 // RUN: %clang -DINLINE=inline -target x86_64-linux-gnu -o - \
61 // RUN: -c -std=gnu89 -xc %s | llvm-nm - 2>&1 | \
62 // RUN: FileCheck -check-prefix=CHECK-SYMBOLS %s
63 
64 // CHECK-TAPI-DAG: foo: { Type: Func }
65 // CHECK-TAPI-DAG: foo.var: { Type: Object, Size: 4 }
66 // CHECK-SYMBOLS-DAG: foo
67 // CHECK-SYMBOLS-DAG: foo.var
68 #include "inline.h"
69