[lld] r282454 - Create FileOutputBuffer lazily.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 26 16:53:56 PDT 2016
Author: ruiu
Date: Mon Sep 26 18:53:55 2016
New Revision: 282454
URL: http://llvm.org/viewvc/llvm-project?rev=282454&view=rev
Log:
Create FileOutputBuffer lazily.
So that it is clear that FileOutputBuffer does not depend on
PDB file builder. Eventually we will have to to get the file size
info from the file builder to create a file with the exact size.
NFC.
Modified:
lld/trunk/COFF/PDB.cpp
Modified: lld/trunk/COFF/PDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/PDB.cpp?rev=282454&r1=282453&r2=282454&view=diff
==============================================================================
--- lld/trunk/COFF/PDB.cpp (original)
+++ lld/trunk/COFF/PDB.cpp Mon Sep 26 18:53:55 2016
@@ -33,14 +33,6 @@ static ExitOnError ExitOnErr;
const int BlockSize = 4096;
void coff::createPDB(StringRef Path) {
- // Create a file.
- size_t FileSize = BlockSize * 10;
- auto BufferOrErr = FileOutputBuffer::create(Path, FileSize);
- if (auto EC = BufferOrErr.getError())
- fatal(EC, "failed to open " + Path);
- auto FileByteStream =
- llvm::make_unique<msf::FileBufferByteStream>(std::move(*BufferOrErr));
-
// Create the superblock.
msf::SuperBlock SB;
memcpy(SB.MagicBytes, msf::Magic, sizeof(msf::Magic));
@@ -76,6 +68,12 @@ void coff::createPDB(StringRef Path) {
auto &TpiBuilder = Builder.getTpiBuilder();
TpiBuilder.setVersionHeader(pdb::PdbTpiV80);
- // Write the root directory. Root stream is on page 2.
+ // Write to a file.
+ size_t FileSize = BlockSize * 10;
+ auto BufferOrErr = FileOutputBuffer::create(Path, FileSize);
+ if (auto EC = BufferOrErr.getError())
+ fatal(EC, "failed to open " + Path);
+ auto FileByteStream =
+ llvm::make_unique<msf::FileBufferByteStream>(std::move(*BufferOrErr));
ExitOnErr(Builder.commit(*FileByteStream));
}
More information about the llvm-commits
mailing list