summaryrefslogtreecommitdiff
path: root/lib/ReaderWriter/PECOFF/PDBPass.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ReaderWriter/PECOFF/PDBPass.h')
-rw-r--r--lib/ReaderWriter/PECOFF/PDBPass.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/ReaderWriter/PECOFF/PDBPass.h b/lib/ReaderWriter/PECOFF/PDBPass.h
new file mode 100644
index 0000000000000..0efa054db8231
--- /dev/null
+++ b/lib/ReaderWriter/PECOFF/PDBPass.h
@@ -0,0 +1,43 @@
+//===- lib/ReaderWriter/PECOFF/PDBPass.h ----------------------------------===//
+//
+// The LLVM Linker
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLD_READER_WRITER_PE_COFF_PDB_PASS_H
+#define LLD_READER_WRITER_PE_COFF_PDB_PASS_H
+
+#include "lld/Core/Pass.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Process.h"
+
+namespace lld {
+namespace pecoff {
+
+class PDBPass : public lld::Pass {
+public:
+ PDBPass(PECOFFLinkingContext &ctx) : _ctx(ctx) {}
+
+ void perform(std::unique_ptr<MutableFile> &file) override {
+ if (_ctx.getDebug())
+ touch(_ctx.getPDBFilePath());
+ }
+
+private:
+ void touch(StringRef path) {
+ int fd;
+ if (llvm::sys::fs::openFileForWrite(path, fd, llvm::sys::fs::F_Append))
+ llvm::report_fatal_error("failed to create a PDB file");
+ llvm::sys::Process::SafelyCloseFileDescriptor(fd);
+ }
+
+ PECOFFLinkingContext &_ctx;
+};
+
+} // namespace pecoff
+} // namespace lld
+
+#endif