[PATCH] [LLD] COFF: Remove BitcodeFile::BitcodFile(StringRef Filename)

Rui Ueyama ruiu at google.com
Mon Jun 1 14:14:40 PDT 2015


Hi pcc,

In r238690 I made all files have only MemoryBufferRefs. This change is to do
the same thing for the bitcode file reader. Also updated a few variable names
to match with other code.

http://reviews.llvm.org/D10170

Files:
  COFF/Driver.cpp
  COFF/InputFiles.cpp
  COFF/InputFiles.h

Index: COFF/Driver.cpp
===================================================================
--- COFF/Driver.cpp
+++ COFF/Driver.cpp
@@ -77,7 +77,7 @@
   if (Magic == file_magic::archive)
     return std::unique_ptr<InputFile>(new ArchiveFile(MBRef));
   if (Magic == file_magic::bitcode)
-    return std::unique_ptr<InputFile>(new BitcodeFile(Path));
+    return std::unique_ptr<InputFile>(new BitcodeFile(MBRef));
   return std::unique_ptr<InputFile>(new ObjectFile(MBRef));
 }
 
Index: COFF/InputFiles.cpp
===================================================================
--- COFF/InputFiles.cpp
+++ COFF/InputFiles.cpp
@@ -246,14 +246,9 @@
 
 std::error_code BitcodeFile::parse() {
   std::string Err;
-  if (!Filename.empty()) {
-    M.reset(LTOModule::createFromFile(Filename.c_str(), llvm::TargetOptions(),
-                                      Err));
-  } else {
-    M.reset(LTOModule::createFromBuffer(MBRef.getBufferStart(),
-                                        MBRef.getBufferSize(),
-                                        llvm::TargetOptions(), Err));
-  }
+  M.reset(LTOModule::createFromBuffer(MB.getBufferStart(),
+                                      MB.getBufferSize(),
+                                      llvm::TargetOptions(), Err));
   if (!Err.empty()) {
     llvm::errs() << Err << '\n';
     return make_error_code(LLDError::BrokenFile);
@@ -268,8 +263,8 @@
       SymbolBodies.push_back(new (Alloc) DefinedBitcode(SymName));
     }
   }
-
   return std::error_code();
 }
+
 } // namespace coff
 } // namespace lld
Index: COFF/InputFiles.h
===================================================================
--- COFF/InputFiles.h
+++ COFF/InputFiles.h
@@ -162,10 +162,9 @@
 // Used for LTO.
 class BitcodeFile : public InputFile {
 public:
-  explicit BitcodeFile(StringRef S) : InputFile(BitcodeKind), Filename(S) {}
-  explicit BitcodeFile(MemoryBufferRef M) : InputFile(BitcodeKind), MBRef(M) {}
+  explicit BitcodeFile(MemoryBufferRef M) : InputFile(BitcodeKind), MB(M) {}
   static bool classof(const InputFile *F) { return F->kind() == BitcodeKind; }
-  StringRef getName() override { return Filename; }
+  StringRef getName() override { return MB.getBufferIdentifier(); }
   std::vector<SymbolBody *> &getSymbols() override { return SymbolBodies; }
 
   LTOModule *getModule() const { return M.get(); }
@@ -174,8 +173,7 @@
 private:
   std::error_code parse() override;
 
-  std::string Filename;
-  MemoryBufferRef MBRef;
+  MemoryBufferRef MB;
   std::vector<SymbolBody *> SymbolBodies;
   llvm::BumpPtrAllocator Alloc;
   std::unique_ptr<LTOModule> M;

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10170.26930.patch
Type: text/x-patch
Size: 2597 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150601/1abe0251/attachment.bin>


More information about the llvm-commits mailing list