[PATCH] D20243: [PCH] Disable inclusion of timestamps when generating pch files on windows.

pierre gousseau via cfe-commits cfe-commits at lists.llvm.org
Tue May 24 01:50:32 PDT 2016


pgousseau updated this revision to Diff 58207.
pgousseau added a comment.

Moving REQUIRE line higher following Bruno's comments.


http://reviews.llvm.org/D20243

Files:
  lib/Frontend/FrontendActions.cpp
  lib/Serialization/ASTReader.cpp
  test/PCH/Inputs/pragma-once2-pch.h
  test/PCH/Inputs/pragma-once2.h
  test/PCH/pragma-once-timestamp.cpp

Index: test/PCH/pragma-once-timestamp.cpp
===================================================================
--- /dev/null
+++ test/PCH/pragma-once-timestamp.cpp
@@ -0,0 +1,24 @@
+// On Windows, timestamps for pch are not handled correctly.
+// This would cause pragma once to be ignored on distributed builds.
+// pragma-once2-pch.h includes pragma-once2.h which has a pragma once directive.
+// pragma-once2.h is then touched before using the generated pch.
+// On Linux this will cause an expected error, but on Windows we want to
+// ignore the timestamp as the timestamp handling on Windows is
+// inconsistent at the moment.
+
+// REQUIRES: system-windows
+
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/Inputs/pragma-once2-pch.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t -x c++-header %S/Inputs/pragma-once2-pch.h
+// RUN: touch %S/Inputs/pragma-once2.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+#include "Inputs/pragma-once2.h"
+
+void g() { f(); }
+
Index: test/PCH/Inputs/pragma-once2.h
===================================================================
--- /dev/null
+++ test/PCH/Inputs/pragma-once2.h
@@ -0,0 +1,4 @@
+#pragma once
+
+inline void f() {}
+
Index: test/PCH/Inputs/pragma-once2-pch.h
===================================================================
--- /dev/null
+++ test/PCH/Inputs/pragma-once2-pch.h
@@ -0,0 +1,2 @@
+#include "pragma-once2.h"
+
Index: lib/Serialization/ASTReader.cpp
===================================================================
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -2013,6 +2013,8 @@
        // In our regression testing, the Windows file system seems to
        // have inconsistent modification times that sometimes
        // erroneously trigger this error-handling path.
+       // For now timestamps are disabled for pch files on Windows (c.f
+       // GeneratePCHAction::CreateASTConsumer).
        //
        // FIXME: This probably also breaks HeaderFileInfo lookups on Windows.
        (StoredTime && StoredTime != File->getModificationTime() &&
Index: lib/Frontend/FrontendActions.cpp
===================================================================
--- lib/Frontend/FrontendActions.cpp
+++ lib/Frontend/FrontendActions.cpp
@@ -90,9 +90,15 @@
 
   auto Buffer = std::make_shared<PCHBuffer>();
   std::vector<std::unique_ptr<ASTConsumer>> Consumers;
+  // FIXME: There is a known issue with timestamps appearing to be inconsistent
+  // on Windows (c.f. ASTReader::getInputFile) so we disable timestamps checks
+  // on Windows for now.
+  llvm::Triple HostTriple(LLVM_HOST_TRIPLE);
   Consumers.push_back(llvm::make_unique<PCHGenerator>(
                         CI.getPreprocessor(), OutputFile, nullptr, Sysroot,
-                        Buffer, CI.getFrontendOpts().ModuleFileExtensions));
+                        Buffer, CI.getFrontendOpts().ModuleFileExtensions,
+                        /*AllowASTWithErrors*/false,
+                        /*IncludeTimestamps*/!HostTriple.isOSWindows()));
   Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator(
       CI, InFile, OutputFile, OS, Buffer));
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20243.58207.patch
Type: text/x-patch
Size: 3237 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160524/a9ea9f57/attachment.bin>


More information about the cfe-commits mailing list