From ea0117fbc60fd03749405102aff6963231c6c849 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 13 Apr 2015 11:14:39 +0000 Subject: [PATCH] Bring r234620 back now that llvm is fixed. 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 | 11 +++++------ test/PCH/emit-pth.c | 7 +++++++ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 test/PCH/emit-pth.c diff --git a/lib/Frontend/FrontendActions.cpp b/lib/Frontend/FrontendActions.cpp index 5f91ed0a97..5ffe65f9f2 100644 --- a/lib/Frontend/FrontendActions.cpp +++ b/lib/Frontend/FrontendActions.cpp @@ -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 index 0000000000..7f863cf1d4 --- /dev/null +++ b/test/PCH/emit-pth.c @@ -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! -- 2.40.0