]> granicus.if.org Git - clang/commitdiff
Bring r234620 back now that llvm is fixed.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 13 Apr 2015 11:14:39 +0000 (11:14 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 13 Apr 2015 11:14:39 +0000 (11:14 +0000)
LLVM can now detect if a fd is seekable on windows.

Original commit message:

Actually check if lseek works instead of using a filename based heuristic.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234738 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/FrontendActions.cpp
test/PCH/emit-pth.c [new file with mode: 0644]

index 5f91ed0a974e533dbe271cfcde4e813ddebc20e5..5ffe65f9f2a817a30b840d179364d5ec770f07c9 100644 (file)
@@ -599,16 +599,15 @@ void DumpTokensAction::ExecuteAction() {
 
 void GeneratePTHAction::ExecuteAction() {
   CompilerInstance &CI = getCompilerInstance();
-  if (CI.getFrontendOpts().OutputFile.empty() ||
-      CI.getFrontendOpts().OutputFile == "-") {
-    // FIXME: Don't fail this way.
-    // FIXME: Verify that we can actually seek in the given file.
-    llvm::report_fatal_error("PTH requires a seekable file for output!");
-  }
   llvm::raw_fd_ostream *OS = CI.createDefaultOutputFile(true, getCurrentFile());
   if (!OS)
     return;
 
+  if (!OS->supportsSeeking()) {
+    // FIXME: Don't fail this way.
+    llvm::report_fatal_error("PTH requires a seekable file for output!");
+  }
+
   CacheTokens(CI.getPreprocessor(), OS);
 }
 
diff --git a/test/PCH/emit-pth.c b/test/PCH/emit-pth.c
new file mode 100644 (file)
index 0000000..7f863cf
--- /dev/null
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-pth -o %t1 %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-pth -o - %s > %t2
+// RUN: cmp %t1 %t2
+// RUN: not %clang_cc1 -triple i386-unknown-unknown -emit-pth -o - %s 2>&1 | \
+// RUN: FileCheck %s
+
+// CHECK: PTH requires a seekable file for output!