1 //===- lib/ReaderWriter/PECOFF/PDBPass.h ----------------------------------===//
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLD_READER_WRITER_PE_COFF_PDB_PASS_H
11 #define LLD_READER_WRITER_PE_COFF_PDB_PASS_H
13 #include "lld/Core/Pass.h"
14 #include "llvm/ADT/StringRef.h"
15 #include "llvm/Support/Process.h"
20 class PDBPass : public lld::Pass {
22 PDBPass(PECOFFLinkingContext &ctx) : _ctx(ctx) {}
24 void perform(std::unique_ptr<MutableFile> &file) override {
26 touch(_ctx.getPDBFilePath());
30 void touch(StringRef path) {
32 if (llvm::sys::fs::openFileForWrite(path, fd, llvm::sys::fs::F_Append))
33 llvm::report_fatal_error("failed to create a PDB file");
34 llvm::sys::Process::SafelyCloseFileDescriptor(fd);
37 PECOFFLinkingContext &_ctx;