xref: /aosp_15_r20/external/clang/test/PCH/include-timestamp.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // Test that the timestamp is not included in the produced pch file with
2*67e74705SXin Li // -fno-pch-timestamp.
3*67e74705SXin Li 
4*67e74705SXin Li // Copying files allow for read-only checkouts to run this test.
5*67e74705SXin Li // RUN: cp %S/Inputs/pragma-once2-pch.h %T
6*67e74705SXin Li // RUN: cp %S/Inputs/pragma-once2.h %T
7*67e74705SXin Li // RUN: cp %s %t1.cpp
8*67e74705SXin Li 
9*67e74705SXin Li // Check timestamp is included by default.
10*67e74705SXin Li // RUN: %clang_cc1 -x c++-header -emit-pch -o %t %T/pragma-once2-pch.h
11*67e74705SXin Li // RUN: touch -m -a -t 201008011501 %T/pragma-once2.h
12*67e74705SXin Li // RUN: not %clang_cc1 -include-pch %t %t1.cpp 2>&1 | FileCheck -check-prefix=CHECK-TIMESTAMP %s
13*67e74705SXin Li 
14*67e74705SXin Li // Check bitcode output as well.
15*67e74705SXin Li // RUN: llvm-bcanalyzer -dump %t | FileCheck -check-prefix=CHECK-BITCODE-TIMESTAMP-ON %s
16*67e74705SXin Li 
17*67e74705SXin Li // Check timestamp inclusion is disabled by -fno-pch-timestamp.
18*67e74705SXin Li // RUN: %clang_cc1 -x c++-header -emit-pch -o %t %T/pragma-once2-pch.h -fno-pch-timestamp
19*67e74705SXin Li // RUN: touch -m -a -t 201008011502 %T/pragma-once2.h
20*67e74705SXin Li // RUN: %clang_cc1 -include-pch %t %t1.cpp 2>&1
21*67e74705SXin Li 
22*67e74705SXin Li // Check bitcode output as well.
23*67e74705SXin Li // RUN: llvm-bcanalyzer -dump %t | FileCheck -check-prefix=CHECK-BITCODE-TIMESTAMP-OFF %s
24*67e74705SXin Li 
25*67e74705SXin Li #include "pragma-once2.h"
26*67e74705SXin Li 
g()27*67e74705SXin Li void g() { f(); }
28*67e74705SXin Li 
29*67e74705SXin Li // CHECK-BITCODE-TIMESTAMP-ON: <INPUT_FILE abbrevid={{.*}} op0={{.*}} op1={{.*}} op2={{[^0]}}
30*67e74705SXin Li // CHECK-BITCODE-TIMESTAMP-OFF: <INPUT_FILE abbrevid={{.*}} op0={{.*}} op1={{.*}} op2={{[0]}}
31*67e74705SXin Li 
32*67e74705SXin Li // CHECK-TIMESTAMP: fatal error: file {{.*}} has been modified since the precompiled header {{.*}} was built
33