forked from OSchip/llvm-project
				
			Revert "Correctly pass ownership of MemoryBuffers."
llvm-svn: 178918
This commit is contained in:
		
							parent
							
								
									eb108bad50
								
							
						
					
					
						commit
						e6d5609de4
					
				| 
						 | 
					@ -260,18 +260,17 @@ public:
 | 
				
			||||||
  /// \param [out] result The instantiated lld::File object is returned here.
 | 
					  /// \param [out] result The instantiated lld::File object is returned here.
 | 
				
			||||||
  /// The \p result is a vector because some input files parse into more than
 | 
					  /// The \p result is a vector because some input files parse into more than
 | 
				
			||||||
  /// one lld::File (e.g. YAML). 
 | 
					  /// one lld::File (e.g. YAML). 
 | 
				
			||||||
  virtual error_code
 | 
					  virtual error_code parseFile(std::unique_ptr<MemoryBuffer> &inputBuff,
 | 
				
			||||||
  parseFile(std::unique_ptr<MemoryBuffer> inputBuff,
 | 
					                        std::vector<std::unique_ptr<File>> &result) const = 0;
 | 
				
			||||||
            std::vector<std::unique_ptr<File>> &result) const = 0;
 | 
					  
 | 
				
			||||||
 | 
					 | 
				
			||||||
  /// This is a wrapper around parseFile() where the input file is specified
 | 
					  /// This is a wrapper around parseFile() where the input file is specified
 | 
				
			||||||
  /// by file system path.  The default implementation reads the input file
 | 
					  /// by file system path.  The default implementation reads the input file
 | 
				
			||||||
  /// into a memory buffer and calls parseFile().
 | 
					  /// into a memory buffer and calls parseFile().
 | 
				
			||||||
  ///
 | 
					  ///
 | 
				
			||||||
  /// \param path This is the file system path to the input file.
 | 
					  /// \param path This is the file system path to the input file.
 | 
				
			||||||
  /// \param [out] result The instantiated lld::File object is returned here.
 | 
					  /// \param [out] result The instantiated lld::File object is returned here.
 | 
				
			||||||
  virtual error_code
 | 
					  virtual error_code readFile(StringRef path,
 | 
				
			||||||
  readFile(StringRef path, std::vector<std::unique_ptr<File>> &result) const;
 | 
					                        std::vector<std::unique_ptr<File>> &result) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// This method is called by core linking to give the Writer a chance
 | 
					  /// This method is called by core linking to give the Writer a chance
 | 
				
			||||||
  /// to add file format specific "files" to set of files to be linked. This is
 | 
					  /// to add file format specific "files" to set of files to be linked. This is
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,10 +30,10 @@ public:
 | 
				
			||||||
  virtual ErrorOr<Reference::Kind>    relocKindFromString(StringRef str) const;
 | 
					  virtual ErrorOr<Reference::Kind>    relocKindFromString(StringRef str) const;
 | 
				
			||||||
  virtual ErrorOr<std::string> stringFromRelocKind(Reference::Kind kind) const;
 | 
					  virtual ErrorOr<std::string> stringFromRelocKind(Reference::Kind kind) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  virtual error_code
 | 
					 | 
				
			||||||
  parseFile(std::unique_ptr<MemoryBuffer> mb,
 | 
					 | 
				
			||||||
            std::vector<std::unique_ptr<File>> &result) const;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  virtual error_code parseFile(std::unique_ptr<MemoryBuffer> &mb,
 | 
				
			||||||
 | 
					                        std::vector<std::unique_ptr<File>> &result) const;
 | 
				
			||||||
 | 
					                        
 | 
				
			||||||
  void addPassNamed(StringRef name) {
 | 
					  void addPassNamed(StringRef name) {
 | 
				
			||||||
    _passNames.push_back(name);
 | 
					    _passNames.push_back(name);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -57,10 +57,10 @@ public:
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  virtual bool validate(raw_ostream &diagnostics);
 | 
					  virtual bool validate(raw_ostream &diagnostics);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  virtual error_code
 | 
					 | 
				
			||||||
  parseFile(std::unique_ptr<MemoryBuffer> mb,
 | 
					 | 
				
			||||||
            std::vector<std::unique_ptr<File>> &result) const;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  virtual error_code parseFile(std::unique_ptr<MemoryBuffer> &mb,
 | 
				
			||||||
 | 
					                        std::vector<std::unique_ptr<File>> &result) const;
 | 
				
			||||||
 | 
					   
 | 
				
			||||||
  static std::unique_ptr<ELFTargetInfo> create(llvm::Triple);
 | 
					  static std::unique_ptr<ELFTargetInfo> create(llvm::Triple);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// \brief Does this relocation belong in the dynamic plt relocation table?
 | 
					  /// \brief Does this relocation belong in the dynamic plt relocation table?
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,10 +31,9 @@ public:
 | 
				
			||||||
  virtual ErrorOr<Reference::Kind> relocKindFromString(StringRef str) const;
 | 
					  virtual ErrorOr<Reference::Kind> relocKindFromString(StringRef str) const;
 | 
				
			||||||
  virtual ErrorOr<std::string> stringFromRelocKind(Reference::Kind kind) const;
 | 
					  virtual ErrorOr<std::string> stringFromRelocKind(Reference::Kind kind) const;
 | 
				
			||||||
  virtual bool validate(raw_ostream &diagnostics);
 | 
					  virtual bool validate(raw_ostream &diagnostics);
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
  virtual error_code
 | 
					  virtual error_code parseFile(std::unique_ptr<MemoryBuffer> &mb,
 | 
				
			||||||
  parseFile(std::unique_ptr<MemoryBuffer> mb,
 | 
					                        std::vector<std::unique_ptr<File>> &result) const;
 | 
				
			||||||
            std::vector<std::unique_ptr<File>> &result) const;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  uint32_t getCPUType() const;
 | 
					  uint32_t getCPUType() const;
 | 
				
			||||||
  uint32_t getCPUSubType() const;
 | 
					  uint32_t getCPUSubType() const;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,9 +39,8 @@ public:
 | 
				
			||||||
  /// file) and create a File object.
 | 
					  /// file) and create a File object.
 | 
				
			||||||
  ///
 | 
					  ///
 | 
				
			||||||
  /// On success, the resulting File object takes ownership of the MemoryBuffer.
 | 
					  /// On success, the resulting File object takes ownership of the MemoryBuffer.
 | 
				
			||||||
  virtual error_code
 | 
					  virtual error_code parseFile(std::unique_ptr<MemoryBuffer> &mb,
 | 
				
			||||||
  parseFile(std::unique_ptr<MemoryBuffer> mb,
 | 
					                          std::vector<std::unique_ptr<File>> &result) const = 0;
 | 
				
			||||||
            std::vector<std::unique_ptr<File>> &result) const = 0;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
  // only concrete subclasses can be instantiated
 | 
					  // only concrete subclasses can be instantiated
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,7 +35,7 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// \brief Returns a vector of Files that are contained in the archive file
 | 
					  /// \brief Returns a vector of Files that are contained in the archive file
 | 
				
			||||||
  ///        pointed to by the Memorybuffer
 | 
					  ///        pointed to by the Memorybuffer
 | 
				
			||||||
  error_code parseFile(std::unique_ptr<llvm::MemoryBuffer> mb,
 | 
					  error_code parseFile(std::unique_ptr<llvm::MemoryBuffer> &mb,
 | 
				
			||||||
                       std::vector<std::unique_ptr<File>> &result) const;
 | 
					                       std::vector<std::unique_ptr<File>> &result) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,7 +26,7 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// \brief Returns a vector of Files that are contained in the archive file
 | 
					  /// \brief Returns a vector of Files that are contained in the archive file
 | 
				
			||||||
  ///        pointed to by the Memorybuffer
 | 
					  ///        pointed to by the Memorybuffer
 | 
				
			||||||
  error_code parseFile(std::unique_ptr<llvm::MemoryBuffer> mb,
 | 
					  error_code parseFile(std::unique_ptr<llvm::MemoryBuffer> &mb,
 | 
				
			||||||
                       std::vector<std::unique_ptr<File>> &result) const;
 | 
					                       std::vector<std::unique_ptr<File>> &result) const;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,7 +38,8 @@ error_code TargetInfo::readFile(StringRef path,
 | 
				
			||||||
  if (error_code ec = llvm::MemoryBuffer::getFileOrSTDIN(path, opmb))
 | 
					  if (error_code ec = llvm::MemoryBuffer::getFileOrSTDIN(path, opmb))
 | 
				
			||||||
    return ec;
 | 
					    return ec;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return this->parseFile(std::unique_ptr<MemoryBuffer>(opmb.take()), result);
 | 
					  std::unique_ptr<MemoryBuffer> mb(opmb.take());
 | 
				
			||||||
 | 
					  return this->parseFile(mb, result);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
error_code TargetInfo::writeFile(const File &linkedFile) const {
 | 
					error_code TargetInfo::writeFile(const File &linkedFile) const {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -358,12 +358,11 @@ void CoreTargetInfo::addPasses(PassManager &pm) const {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
error_code
 | 
					error_code CoreTargetInfo::parseFile(std::unique_ptr<MemoryBuffer> &mb,
 | 
				
			||||||
CoreTargetInfo::parseFile(std::unique_ptr<MemoryBuffer> mb,
 | 
					                            std::vector<std::unique_ptr<File>> &result) const {
 | 
				
			||||||
                          std::vector<std::unique_ptr<File>> &result) const {
 | 
					 | 
				
			||||||
  if (!_reader)
 | 
					  if (!_reader)
 | 
				
			||||||
    _reader = createReaderYAML(*this);
 | 
					    _reader = createReaderYAML(*this);
 | 
				
			||||||
  return _reader->parseFile(std::move(mb), result);
 | 
					  return _reader->parseFile(mb,result);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Writer &CoreTargetInfo::writer() const {
 | 
					Writer &CoreTargetInfo::writer() const {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -91,27 +91,27 @@ bool ELFTargetInfo::isDynamic() const {
 | 
				
			||||||
  return false;
 | 
					  return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
error_code
 | 
					error_code ELFTargetInfo::parseFile(std::unique_ptr<MemoryBuffer> &mb,
 | 
				
			||||||
ELFTargetInfo::parseFile(std::unique_ptr<MemoryBuffer> mb,
 | 
					                          std::vector<std::unique_ptr<File>> &result) const {
 | 
				
			||||||
                         std::vector<std::unique_ptr<File>> &result) const {
 | 
					 | 
				
			||||||
  if (!_elfReader)
 | 
					  if (!_elfReader)
 | 
				
			||||||
    _elfReader = createReaderELF(*this);
 | 
					    _elfReader = createReaderELF(*this);
 | 
				
			||||||
  std::string path = mb->getBufferIdentifier();
 | 
					  error_code ec = _elfReader->parseFile(mb, result);
 | 
				
			||||||
  auto magic = llvm::sys::fs::identify_magic(mb->getBuffer());
 | 
					  if (ec) {
 | 
				
			||||||
  if (magic == llvm::sys::fs::file_magic::elf_relocatable ||
 | 
					    // Not an ELF file, check file extension to see if it might be yaml
 | 
				
			||||||
      magic == llvm::sys::fs::file_magic::elf_shared_object ||
 | 
					    StringRef path = mb->getBufferIdentifier();
 | 
				
			||||||
      magic == llvm::sys::fs::file_magic::archive)
 | 
					    if ( path.endswith(".objtxt") ) {
 | 
				
			||||||
    return _elfReader->parseFile(std::move(mb), result);
 | 
					      if (!_yamlReader)
 | 
				
			||||||
  // Not an ELF file, check file extension to see if it might be yaml
 | 
					          _yamlReader = createReaderYAML(*this);
 | 
				
			||||||
  if (StringRef(path).endswith(".objtxt")) {
 | 
					      ec = _yamlReader->parseFile(mb, result);
 | 
				
			||||||
    if (!_yamlReader)
 | 
					    }
 | 
				
			||||||
      _yamlReader = createReaderYAML(*this);
 | 
					    if (ec) {
 | 
				
			||||||
    return _yamlReader->parseFile(std::move(mb), result);
 | 
					      // Not a yaml file, assume it is a linkerscript
 | 
				
			||||||
 | 
					      if (!_linkerScriptReader)
 | 
				
			||||||
 | 
					        _linkerScriptReader.reset(new ReaderLinkerScript(*this));
 | 
				
			||||||
 | 
					      ec = _linkerScriptReader->parseFile(mb, result);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  // Not a yaml file, assume it is a linkerscript
 | 
					  return ec;
 | 
				
			||||||
  if (!_linkerScriptReader)
 | 
					 | 
				
			||||||
    _linkerScriptReader.reset(new ReaderLinkerScript(*this));
 | 
					 | 
				
			||||||
  return _linkerScriptReader->parseFile(std::move(mb), result);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Writer &ELFTargetInfo::writer() const {
 | 
					Writer &ELFTargetInfo::writer() const {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -82,8 +82,8 @@ public:
 | 
				
			||||||
      : lld::Reader(ti), _elfTargetInfo(ti), _readerArchive(ti, *this) {
 | 
					      : lld::Reader(ti), _elfTargetInfo(ti), _readerArchive(ti, *this) {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  error_code parseFile(std::unique_ptr<MemoryBuffer> mb,
 | 
					  error_code parseFile(std::unique_ptr<MemoryBuffer> &mb,
 | 
				
			||||||
                       std::vector<std::unique_ptr<File>> &result) const {
 | 
					                       std::vector<std::unique_ptr<File> > &result) const {
 | 
				
			||||||
    using llvm::object::ELFType;
 | 
					    using llvm::object::ELFType;
 | 
				
			||||||
    llvm::sys::LLVMFileType fileType =
 | 
					    llvm::sys::LLVMFileType fileType =
 | 
				
			||||||
        llvm::sys::IdentifyFileType(mb->getBufferStart(),
 | 
					        llvm::sys::IdentifyFileType(mb->getBufferStart(),
 | 
				
			||||||
| 
						 | 
					@ -96,7 +96,7 @@ public:
 | 
				
			||||||
    switch (fileType) {
 | 
					    switch (fileType) {
 | 
				
			||||||
    case llvm::sys::ELF_Relocatable_FileType: {
 | 
					    case llvm::sys::ELF_Relocatable_FileType: {
 | 
				
			||||||
      std::unique_ptr<File> f(createELF<ELFFileCreateELFTraits>(
 | 
					      std::unique_ptr<File> f(createELF<ELFFileCreateELFTraits>(
 | 
				
			||||||
          getElfArchType(mb.get()), MaxAlignment, _elfTargetInfo, std::move(mb),
 | 
					          getElfArchType(&*mb), MaxAlignment, _elfTargetInfo, std::move(mb),
 | 
				
			||||||
          ec));
 | 
					          ec));
 | 
				
			||||||
      if (ec)
 | 
					      if (ec)
 | 
				
			||||||
        return ec;
 | 
					        return ec;
 | 
				
			||||||
| 
						 | 
					@ -105,15 +105,14 @@ public:
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    case llvm::sys::ELF_SharedObject_FileType: {
 | 
					    case llvm::sys::ELF_SharedObject_FileType: {
 | 
				
			||||||
      auto f = createELF<DynamicFileCreateELFTraits>(
 | 
					      auto f = createELF<DynamicFileCreateELFTraits>(
 | 
				
			||||||
          getElfArchType(mb.get()), MaxAlignment, _elfTargetInfo,
 | 
					          getElfArchType(&*mb), MaxAlignment, _elfTargetInfo, std::move(mb));
 | 
				
			||||||
                         std::move(mb));
 | 
					 | 
				
			||||||
      if (!f)
 | 
					      if (!f)
 | 
				
			||||||
        return f;
 | 
					        return f;
 | 
				
			||||||
      result.push_back(std::move(*f));
 | 
					      result.push_back(std::move(*f));
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    case llvm::sys::Archive_FileType:
 | 
					    case llvm::sys::Archive_FileType:
 | 
				
			||||||
      ec = _readerArchive.parseFile(std::move(mb), result);
 | 
					      ec = _readerArchive.parseFile(mb, result);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
    default:
 | 
					    default:
 | 
				
			||||||
      return llvm::make_error_code(llvm::errc::executable_format_error);
 | 
					      return llvm::make_error_code(llvm::errc::executable_format_error);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -209,16 +209,15 @@ void MachOTargetInfo::addPasses(PassManager &pm) const {
 | 
				
			||||||
  pm.add(std::unique_ptr<Pass>(new LayoutPass()));
 | 
					  pm.add(std::unique_ptr<Pass>(new LayoutPass()));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
error_code MachOTargetInfo::parseFile(
 | 
					error_code MachOTargetInfo::parseFile(std::unique_ptr<MemoryBuffer> &mb,
 | 
				
			||||||
    std::unique_ptr<MemoryBuffer> mb,
 | 
					                          std::vector<std::unique_ptr<File>> &result) const {
 | 
				
			||||||
    std::vector<std::unique_ptr<File>> &result) const {
 | 
					 | 
				
			||||||
//  if (!_machoReader)
 | 
					//  if (!_machoReader)
 | 
				
			||||||
//    _machoReader = createReaderMachO(*this);
 | 
					//    _machoReader = createReaderMachO(*this);
 | 
				
			||||||
//  error_code ec = _machoReader->parseFile(mb,result);
 | 
					//  error_code ec = _machoReader->parseFile(mb,result);
 | 
				
			||||||
//  if (ec) {
 | 
					//  if (ec) {
 | 
				
			||||||
    if (!_yamlReader)
 | 
					    if (!_yamlReader)
 | 
				
			||||||
      _yamlReader = createReaderYAML(*this);
 | 
					      _yamlReader = createReaderYAML(*this);
 | 
				
			||||||
    return _yamlReader->parseFile(std::move(mb), result);
 | 
					    return _yamlReader->parseFile(mb, result);
 | 
				
			||||||
//  }
 | 
					//  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return error_code::success();
 | 
					  return error_code::success();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -915,9 +915,9 @@ public:
 | 
				
			||||||
  Reader(const TargetInfo &ti)
 | 
					  Reader(const TargetInfo &ti)
 | 
				
			||||||
   : lld::Reader(ti) {}
 | 
					   : lld::Reader(ti) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  virtual error_code
 | 
					  virtual error_code parseFile(
 | 
				
			||||||
  parseFile(std::unique_ptr<MemoryBuffer> mb,
 | 
					      std::unique_ptr<MemoryBuffer> &mb,
 | 
				
			||||||
            std::vector<std::unique_ptr<lld::File>> &result) const {
 | 
					      std::vector<std::unique_ptr<lld::File> > &result) const {
 | 
				
			||||||
    return File::make(_targetInfo, mb, mb->getBufferIdentifier(), result);
 | 
					    return File::make(_targetInfo, mb, mb->getBufferIdentifier(), result);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -369,8 +369,8 @@ class ReaderCOFF : public Reader {
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
  ReaderCOFF(const TargetInfo &ti) : Reader(ti) {}
 | 
					  ReaderCOFF(const TargetInfo &ti) : Reader(ti) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  error_code parseFile(std::unique_ptr<MemoryBuffer> mb,
 | 
					  error_code parseFile(std::unique_ptr<MemoryBuffer> &mb,
 | 
				
			||||||
                       std::vector<std::unique_ptr<File>> &result) const {
 | 
					                       std::vector<std::unique_ptr<File> > &result) const {
 | 
				
			||||||
    llvm::error_code ec;
 | 
					    llvm::error_code ec;
 | 
				
			||||||
    std::unique_ptr<File> f(new FileCOFF(_targetInfo, std::move(mb), ec));
 | 
					    std::unique_ptr<File> f(new FileCOFF(_targetInfo, std::move(mb), ec));
 | 
				
			||||||
    if (ec) {
 | 
					    if (ec) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,6 +24,7 @@ error_code Reader::readFile(StringRef path,
 | 
				
			||||||
  if (error_code ec = llvm::MemoryBuffer::getFileOrSTDIN(path, opmb))
 | 
					  if (error_code ec = llvm::MemoryBuffer::getFileOrSTDIN(path, opmb))
 | 
				
			||||||
    return ec;
 | 
					    return ec;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return parseFile(std::unique_ptr<MemoryBuffer>(opmb.take()), result);
 | 
					  std::unique_ptr<MemoryBuffer> mb(opmb.take());
 | 
				
			||||||
 | 
					  return this->parseFile(mb, result);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
} // end namespace lld
 | 
					} // end namespace lld
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,7 +48,7 @@ public:
 | 
				
			||||||
    if (_targetInfo.logInputFiles())
 | 
					    if (_targetInfo.logInputFiles())
 | 
				
			||||||
      llvm::outs() << buff->getBufferIdentifier() << "\n";
 | 
					      llvm::outs() << buff->getBufferIdentifier() << "\n";
 | 
				
			||||||
    std::unique_ptr<MemoryBuffer> mb(buff.take());
 | 
					    std::unique_ptr<MemoryBuffer> mb(buff.take());
 | 
				
			||||||
    if (_targetInfo.parseFile(std::move(mb), result))
 | 
					    if (_targetInfo.parseFile(mb, result))
 | 
				
			||||||
      return nullptr;
 | 
					      return nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    assert(result.size() == 1);
 | 
					    assert(result.size() == 1);
 | 
				
			||||||
| 
						 | 
					@ -159,9 +159,8 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Returns a vector of Files that are contained in the archive file
 | 
					// Returns a vector of Files that are contained in the archive file
 | 
				
			||||||
// pointed to by the MemoryBuffer
 | 
					// pointed to by the MemoryBuffer
 | 
				
			||||||
error_code
 | 
					error_code ReaderArchive::parseFile(std::unique_ptr<llvm::MemoryBuffer> &mb,
 | 
				
			||||||
ReaderArchive::parseFile(std::unique_ptr<llvm::MemoryBuffer> mb,
 | 
					                            std::vector<std::unique_ptr<File>> &result) const {
 | 
				
			||||||
                         std::vector<std::unique_ptr<File>> &result) const {
 | 
					 | 
				
			||||||
  error_code ec;
 | 
					  error_code ec;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (_targetInfo.forceLoadAllArchives()) {
 | 
					  if (_targetInfo.forceLoadAllArchives()) {
 | 
				
			||||||
| 
						 | 
					@ -177,7 +176,7 @@ ReaderArchive::parseFile(std::unique_ptr<llvm::MemoryBuffer> mb,
 | 
				
			||||||
      std::unique_ptr<MemoryBuffer> mbc(buff.take());
 | 
					      std::unique_ptr<MemoryBuffer> mbc(buff.take());
 | 
				
			||||||
      if (_targetInfo.logInputFiles())
 | 
					      if (_targetInfo.logInputFiles())
 | 
				
			||||||
        llvm::outs() << buff->getBufferIdentifier() << "\n";
 | 
					        llvm::outs() << buff->getBufferIdentifier() << "\n";
 | 
				
			||||||
      if ((ec = _targetInfo.parseFile(std::move(mbc), result)))
 | 
					      if ((ec = _targetInfo.parseFile(mbc, result)))
 | 
				
			||||||
        return ec;
 | 
					        return ec;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -79,9 +79,9 @@ private:
 | 
				
			||||||
} // end anon namespace
 | 
					} // end anon namespace
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace lld {
 | 
					namespace lld {
 | 
				
			||||||
error_code ReaderLinkerScript::parseFile(
 | 
					error_code
 | 
				
			||||||
    std::unique_ptr<llvm::MemoryBuffer> mb,
 | 
					ReaderLinkerScript::parseFile(std::unique_ptr<llvm::MemoryBuffer> &mb,
 | 
				
			||||||
    std::vector<std::unique_ptr<File>> &result) const {
 | 
					                            std::vector<std::unique_ptr<File> > &result) const {
 | 
				
			||||||
  auto lsf = LinkerScriptFile::create(_targetInfo, std::move(mb));
 | 
					  auto lsf = LinkerScriptFile::create(_targetInfo, std::move(mb));
 | 
				
			||||||
  if (!lsf)
 | 
					  if (!lsf)
 | 
				
			||||||
    return lsf;
 | 
					    return lsf;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1342,7 +1342,7 @@ class ReaderYAML : public Reader {
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
  ReaderYAML(const TargetInfo &ti) : Reader(ti) {}
 | 
					  ReaderYAML(const TargetInfo &ti) : Reader(ti) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  error_code parseFile(std::unique_ptr<MemoryBuffer> mb,
 | 
					  error_code parseFile(std::unique_ptr<MemoryBuffer> &mb,
 | 
				
			||||||
                       std::vector<std::unique_ptr<File>> &result) const {
 | 
					                       std::vector<std::unique_ptr<File>> &result) const {
 | 
				
			||||||
    // Note: we do not take ownership of the MemoryBuffer.  That is
 | 
					    // Note: we do not take ownership of the MemoryBuffer.  That is
 | 
				
			||||||
    // because yaml may produce multiple File objects, so there is no
 | 
					    // because yaml may produce multiple File objects, so there is no
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue