summaryrefslogtreecommitdiffstats
path: root/test/PCH
diff options
context:
space:
mode:
authorPierre Gousseau <pierregousseau14@gmail.com>2016-07-13 14:21:11 +0000
committerPierre Gousseau <pierregousseau14@gmail.com>2016-07-13 14:21:11 +0000
commit4e7c8ba2f78c17974062fc0f239f4ed0b87ed611 (patch)
treef68f9bac46553295abd67fa4c92d9cf7dda3a011 /test/PCH
parent36278344077d6e44af7f1793a07fbbc650573cac (diff)
[PCH] Add a fno-pch-timestamp option to cc1 to disable inclusion of timestamps in PCH files.
This is to allow distributed build systems, that do not preserve time stamps, to use PCH files. Second and last part of the patch proposed at: Differential Revision: http://reviews.llvm.org/D20867 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@275267 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/PCH')
-rw-r--r--test/PCH/Inputs/pragma-once2-pch.h1
-rw-r--r--test/PCH/Inputs/pragma-once2.h3
-rw-r--r--test/PCH/include-timestamp.cpp27
3 files changed, 31 insertions, 0 deletions
diff --git a/test/PCH/Inputs/pragma-once2-pch.h b/test/PCH/Inputs/pragma-once2-pch.h
new file mode 100644
index 0000000000..642b50f15a
--- /dev/null
+++ b/test/PCH/Inputs/pragma-once2-pch.h
@@ -0,0 +1 @@
+#include "pragma-once2.h"
diff --git a/test/PCH/Inputs/pragma-once2.h b/test/PCH/Inputs/pragma-once2.h
new file mode 100644
index 0000000000..7ed4a95520
--- /dev/null
+++ b/test/PCH/Inputs/pragma-once2.h
@@ -0,0 +1,3 @@
+#pragma once
+
+inline void f() {}
diff --git a/test/PCH/include-timestamp.cpp b/test/PCH/include-timestamp.cpp
new file mode 100644
index 0000000000..1add189c69
--- /dev/null
+++ b/test/PCH/include-timestamp.cpp
@@ -0,0 +1,27 @@
+// Test that the timestamp is not included in the produced pch file with
+// -fno-pch-timestamp.
+
+// Check timestamp is included by default.
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/Inputs/pragma-once2-pch.h
+// RUN: touch -m -a -t 201008011501 %S/Inputs/pragma-once2.h
+// RUN: not %clang_cc1 -include-pch %t %s 2>&1 | FileCheck -check-prefix=CHECK-TIMESTAMP %s
+
+// Check bitcode output as well.
+// RUN: llvm-bcanalyzer -dump %t | FileCheck -check-prefix=CHECK-BITCODE-TIMESTAMP-ON %s
+
+// Check timestamp inclusion is disabled by -fno-pch-timestamp.
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/Inputs/pragma-once2-pch.h -fno-pch-timestamp
+// RUN: touch -m -a -t 201008011502 %S/Inputs/pragma-once2.h
+// RUN: %clang_cc1 -include-pch %t %s 2>&1
+
+// Check bitcode output as well.
+// RUN: llvm-bcanalyzer -dump %t | FileCheck -check-prefix=CHECK-BITCODE-TIMESTAMP-OFF %s
+
+#include "Inputs/pragma-once2.h"
+
+void g() { f(); }
+
+// CHECK-BITCODE-TIMESTAMP-ON: <INPUT_FILE abbrevid={{.*}} op0={{.*}} op1={{.*}} op2={{[^0]}}
+// CHECK-BITCODE-TIMESTAMP-OFF: <INPUT_FILE abbrevid={{.*}} op0={{.*}} op1={{.*}} op2={{[0]}}
+
+// CHECK-TIMESTAMP: fatal error: file {{.*}} has been modified since the precompiled header {{.*}} was built