Mercurial > hg > CbC > CbC_llvm
comparison lib/Object/IRObjectFile.cpp @ 147:c2174574ed3a
LLVM 10
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 14 Aug 2019 16:55:33 +0900 |
parents | 3a76565eade5 |
children |
comparison
equal
deleted
inserted
replaced
134:3a76565eade5 | 147:c2174574ed3a |
---|---|
1 //===- IRObjectFile.cpp - IR object file implementation ---------*- C++ -*-===// | 1 //===- IRObjectFile.cpp - IR object file implementation ---------*- C++ -*-===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 // | 4 // See https://llvm.org/LICENSE.txt for license information. |
5 // This file is distributed under the University of Illinois Open Source | 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 // License. See LICENSE.TXT for details. | |
7 // | 6 // |
8 //===----------------------------------------------------------------------===// | 7 //===----------------------------------------------------------------------===// |
9 // | 8 // |
10 // Part of the IRObjectFile class implementation. | 9 // Part of the IRObjectFile class implementation. |
11 // | 10 // |
41 | 40 |
42 void IRObjectFile::moveSymbolNext(DataRefImpl &Symb) const { | 41 void IRObjectFile::moveSymbolNext(DataRefImpl &Symb) const { |
43 Symb.p += sizeof(ModuleSymbolTable::Symbol); | 42 Symb.p += sizeof(ModuleSymbolTable::Symbol); |
44 } | 43 } |
45 | 44 |
46 std::error_code IRObjectFile::printSymbolName(raw_ostream &OS, | 45 Error IRObjectFile::printSymbolName(raw_ostream &OS, DataRefImpl Symb) const { |
47 DataRefImpl Symb) const { | |
48 SymTab.printSymbolName(OS, getSym(Symb)); | 46 SymTab.printSymbolName(OS, getSym(Symb)); |
49 return std::error_code(); | 47 return Error::success(); |
50 } | 48 } |
51 | 49 |
52 uint32_t IRObjectFile::getSymbolFlags(DataRefImpl Symb) const { | 50 uint32_t IRObjectFile::getSymbolFlags(DataRefImpl Symb) const { |
53 return SymTab.getSymbolFlags(getSym(Symb)); | 51 return SymTab.getSymbolFlags(getSym(Symb)); |
54 } | 52 } |
74 | 72 |
75 Expected<MemoryBufferRef> | 73 Expected<MemoryBufferRef> |
76 IRObjectFile::findBitcodeInObject(const ObjectFile &Obj) { | 74 IRObjectFile::findBitcodeInObject(const ObjectFile &Obj) { |
77 for (const SectionRef &Sec : Obj.sections()) { | 75 for (const SectionRef &Sec : Obj.sections()) { |
78 if (Sec.isBitcode()) { | 76 if (Sec.isBitcode()) { |
79 StringRef SecContents; | 77 Expected<StringRef> Contents = Sec.getContents(); |
80 if (std::error_code EC = Sec.getContents(SecContents)) | 78 if (!Contents) |
81 return errorCodeToError(EC); | 79 return Contents.takeError(); |
82 return MemoryBufferRef(SecContents, Obj.getFileName()); | 80 if (Contents->size() <= 1) |
81 return errorCodeToError(object_error::bitcode_section_not_found); | |
82 return MemoryBufferRef(*Contents, Obj.getFileName()); | |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 return errorCodeToError(object_error::bitcode_section_not_found); | 86 return errorCodeToError(object_error::bitcode_section_not_found); |
87 } | 87 } |