xref: /aosp_15_r20/external/clang/test/PCH/pragma-optimize.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // Test this without pch.
2*67e74705SXin Li // RUN: %clang_cc1 %s -include %s -verify -fsyntax-only
3*67e74705SXin Li 
4*67e74705SXin Li // Test with pch.
5*67e74705SXin Li // RUN: %clang_cc1 %s -emit-pch -o %t
6*67e74705SXin Li // RUN: %clang_cc1 %s -emit-llvm -include-pch %t -o - | FileCheck %s
7*67e74705SXin Li 
8*67e74705SXin Li // The first run line creates a pch, and since at that point HEADER is not
9*67e74705SXin Li // defined, the only thing contained in the pch is the pragma. The second line
10*67e74705SXin Li // then includes that pch, so HEADER is defined and the actual code is compiled.
11*67e74705SXin Li // The check then makes sure that the pragma is in effect in the file that
12*67e74705SXin Li // includes the pch.
13*67e74705SXin Li 
14*67e74705SXin Li // expected-no-diagnostics
15*67e74705SXin Li 
16*67e74705SXin Li #ifndef HEADER
17*67e74705SXin Li #define HEADER
18*67e74705SXin Li #pragma clang optimize off
19*67e74705SXin Li 
20*67e74705SXin Li #else
21*67e74705SXin Li 
22*67e74705SXin Li int a;
23*67e74705SXin Li 
f()24*67e74705SXin Li void f() {
25*67e74705SXin Li   a = 12345;
26*67e74705SXin Li }
27*67e74705SXin Li 
28*67e74705SXin Li // Check that the function is decorated with optnone
29*67e74705SXin Li 
30*67e74705SXin Li // CHECK-DAG: @f() [[ATTRF:#[0-9]+]]
31*67e74705SXin Li // CHECK-DAG: attributes [[ATTRF]] = { {{.*}}noinline{{.*}}optnone{{.*}} }
32*67e74705SXin Li 
33*67e74705SXin Li #endif
34