llvm.org GIT mirror llvm / 5c792fa
Don't use 'using std::error_code' in include/llvm. This should make sure that most new uses use the std prefix. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210835 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 5 years ago
107 changed file(s) with 695 addition(s) and 566 deletion(s). Raw diff Collapse all Expand all
2020 #include "llvm/Support/Memory.h"
2121
2222 namespace llvm {
23
2423 /// This is a simple memory manager which implements the methods called by
2524 /// the RuntimeDyld class to allocate memory for section-based loading of
2625 /// objects, usually those generated by the MCJIT execution engine.
9291 uint8_t *allocateSection(MemoryGroup &MemGroup, uintptr_t Size,
9392 unsigned Alignment);
9493
95 error_code applyMemoryGroupPermissions(MemoryGroup &MemGroup,
96 unsigned Permissions);
94 std::error_code applyMemoryGroupPermissions(MemoryGroup &MemGroup,
95 unsigned Permissions);
9796
9897 MemoryGroup CodeMem;
9998 MemoryGroup RWDataMem;
2020 #include
2121
2222 namespace llvm {
23 using std::error_code;
2423 class Function;
2524 class GlobalValue;
2625 class Module;
4241
4342 /// Make sure the given GlobalValue is fully read.
4443 ///
45 virtual error_code Materialize(GlobalValue *GV) = 0;
44 virtual std::error_code Materialize(GlobalValue *GV) = 0;
4645
4746 /// If the given GlobalValue is read in, and if the GVMaterializer supports
4847 /// it, release the memory for the GV, and set it up to be materialized
5352
5453 /// Make sure the entire Module has been completely read.
5554 ///
56 virtual error_code MaterializeModule(Module *M) = 0;
55 virtual std::error_code MaterializeModule(Module *M) = 0;
5756 };
5857
5958 } // End llvm namespace
2525 #include
2626
2727 namespace llvm {
28
2928 class FunctionType;
3029 class GVMaterializer;
3130 class LLVMContext;
453452 void Dematerialize(GlobalValue *GV);
454453
455454 /// Make sure all GlobalValues in this Module are fully read.
456 error_code materializeAll();
455 std::error_code materializeAll();
457456
458457 /// Make sure all GlobalValues in this Module are fully read and clear the
459458 /// Materializer. If the module is corrupt, this DOES NOT clear the old
460459 /// Materializer.
461 error_code materializeAllPermanently();
460 std::error_code materializeAllPermanently();
462461
463462 /// @}
464463 /// @name Direct access to the globals list, functions list, and symbol table
7171
7272 Child getNext() const;
7373
74 error_code getName(StringRef &Result) const;
74 std::error_code getName(StringRef &Result) const;
7575 StringRef getRawName() const { return getHeader()->getName(); }
7676 sys::TimeValue getLastModified() const {
7777 return getHeader()->getLastModified();
8888 return StringRef(Data.data() + StartOfFile, getSize());
8989 }
9090
91 error_code getMemoryBuffer(std::unique_ptr &Result,
92 bool FullPath = false) const;
93
94 error_code getAsBinary(std::unique_ptr &Result,
95 LLVMContext *Context = nullptr) const;
91 std::error_code getMemoryBuffer(std::unique_ptr &Result,
92 bool FullPath = false) const;
93
94 std::error_code getAsBinary(std::unique_ptr &Result,
95 LLVMContext *Context = nullptr) const;
9696 };
9797
9898 class child_iterator {
136136 : Parent(p)
137137 , SymbolIndex(symi)
138138 , StringIndex(stri) {}
139 error_code getName(StringRef &Result) const;
140 error_code getMember(child_iterator &Result) const;
139 std::error_code getName(StringRef &Result) const;
140 std::error_code getMember(child_iterator &Result) const;
141141 Symbol getNext() const;
142142 };
143143
163163 }
164164 };
165165
166 Archive(MemoryBuffer *source, error_code &ec);
166 Archive(MemoryBuffer *source, std::error_code &ec);
167167 static ErrorOr create(MemoryBuffer *Source);
168168
169169 enum Kind {
352352 uint32_t NumberOfImportDirectory;
353353 const export_directory_table_entry *ExportDirectory;
354354
355 error_code getString(uint32_t offset, StringRef &Res) const;
355 std::error_code getString(uint32_t offset, StringRef &Res) const;
356356
357357 const coff_symbol *toSymb(DataRefImpl Symb) const;
358358 const coff_section *toSec(DataRefImpl Sec) const;
359359 const coff_relocation *toRel(DataRefImpl Rel) const;
360360
361 error_code initSymbolTablePtr();
362 error_code initImportTablePtr();
363 error_code initExportTablePtr();
361 std::error_code initSymbolTablePtr();
362 std::error_code initImportTablePtr();
363 std::error_code initExportTablePtr();
364364
365365 protected:
366366 void moveSymbolNext(DataRefImpl &Symb) const override;
367 error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const override;
368 error_code getSymbolAddress(DataRefImpl Symb, uint64_t &Res) const override;
369 error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const override;
367 std::error_code getSymbolName(DataRefImpl Symb,
368 StringRef &Res) const override;
369 std::error_code getSymbolAddress(DataRefImpl Symb,
370 uint64_t &Res) const override;
371 std::error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const override;
370372 uint32_t getSymbolFlags(DataRefImpl Symb) const override;
371 error_code getSymbolType(DataRefImpl Symb,
372 SymbolRef::Type &Res) const override;
373 error_code getSymbolSection(DataRefImpl Symb,
374 section_iterator &Res) const override;
373 std::error_code getSymbolType(DataRefImpl Symb,
374 SymbolRef::Type &Res) const override;
375 std::error_code getSymbolSection(DataRefImpl Symb,
376 section_iterator &Res) const override;
375377 void moveSectionNext(DataRefImpl &Sec) const override;
376 error_code getSectionName(DataRefImpl Sec, StringRef &Res) const override;
377 error_code getSectionAddress(DataRefImpl Sec, uint64_t &Res) const override;
378 error_code getSectionSize(DataRefImpl Sec, uint64_t &Res) const override;
379 error_code getSectionContents(DataRefImpl Sec, StringRef &Res) const override;
380 error_code getSectionAlignment(DataRefImpl Sec, uint64_t &Res) const override;
381 error_code isSectionText(DataRefImpl Sec, bool &Res) const override;
382 error_code isSectionData(DataRefImpl Sec, bool &Res) const override;
383 error_code isSectionBSS(DataRefImpl Sec, bool &Res) const override;
384 error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const override;
385 error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const override;
386 error_code isSectionReadOnlyData(DataRefImpl Sec, bool &Res) const override;
387 error_code isSectionRequiredForExecution(DataRefImpl Sec,
388 bool &Res) const override;
389 error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb,
390 bool &Result) const override;
378 std::error_code getSectionName(DataRefImpl Sec,
379 StringRef &Res) const override;
380 std::error_code getSectionAddress(DataRefImpl Sec,
381 uint64_t &Res) const override;
382 std::error_code getSectionSize(DataRefImpl Sec, uint64_t &Res) const override;
383 std::error_code getSectionContents(DataRefImpl Sec,
384 StringRef &Res) const override;
385 std::error_code getSectionAlignment(DataRefImpl Sec,
386 uint64_t &Res) const override;
387 std::error_code isSectionText(DataRefImpl Sec, bool &Res) const override;
388 std::error_code isSectionData(DataRefImpl Sec, bool &Res) const override;
389 std::error_code isSectionBSS(DataRefImpl Sec, bool &Res) const override;
390 std::error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const override;
391 std::error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const override;
392 std::error_code isSectionReadOnlyData(DataRefImpl Sec,
393 bool &Res) const override;
394 std::error_code isSectionRequiredForExecution(DataRefImpl Sec,
395 bool &Res) const override;
396 std::error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb,
397 bool &Result) const override;
391398 relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
392399 relocation_iterator section_rel_end(DataRefImpl Sec) const override;
393400
394401 void moveRelocationNext(DataRefImpl &Rel) const override;
395 error_code getRelocationAddress(DataRefImpl Rel,
396 uint64_t &Res) const override;
397 error_code getRelocationOffset(DataRefImpl Rel, uint64_t &Res) const override;
402 std::error_code getRelocationAddress(DataRefImpl Rel,
403 uint64_t &Res) const override;
404 std::error_code getRelocationOffset(DataRefImpl Rel,
405 uint64_t &Res) const override;
398406 symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
399 error_code getRelocationType(DataRefImpl Rel, uint64_t &Res) const override;
400 error_code
407 std::error_code getRelocationType(DataRefImpl Rel,
408 uint64_t &Res) const override;
409 std::error_code
401410 getRelocationTypeName(DataRefImpl Rel,
402411 SmallVectorImpl &Result) const override;
403 error_code
412 std::error_code
404413 getRelocationValueString(DataRefImpl Rel,
405414 SmallVectorImpl &Result) const override;
406415
407 error_code getLibraryNext(DataRefImpl LibData,
408 LibraryRef &Result) const override;
409 error_code getLibraryPath(DataRefImpl LibData,
410 StringRef &Result) const override;
416 std::error_code getLibraryNext(DataRefImpl LibData,
417 LibraryRef &Result) const override;
418 std::error_code getLibraryPath(DataRefImpl LibData,
419 StringRef &Result) const override;
411420
412421 public:
413 COFFObjectFile(MemoryBuffer *Object, error_code &EC, bool BufferOwned = true);
422 COFFObjectFile(MemoryBuffer *Object, std::error_code &EC,
423 bool BufferOwned = true);
414424 basic_symbol_iterator symbol_begin_impl() const override;
415425 basic_symbol_iterator symbol_end_impl() const override;
416426 library_iterator needed_library_begin() const override;
432442 export_directory_iterator export_directory_begin() const;
433443 export_directory_iterator export_directory_end() const;
434444
435 error_code getHeader(const coff_file_header *&Res) const;
436 error_code getCOFFHeader(const coff_file_header *&Res) const;
437 error_code getPE32Header(const pe32_header *&Res) const;
438 error_code getPE32PlusHeader(const pe32plus_header *&Res) const;
439 error_code getDataDirectory(uint32_t index, const data_directory *&Res) const;
440 error_code getSection(int32_t index, const coff_section *&Res) const;
441 error_code getSymbol(uint32_t index, const coff_symbol *&Res) const;
445 std::error_code getHeader(const coff_file_header *&Res) const;
446 std::error_code getCOFFHeader(const coff_file_header *&Res) const;
447 std::error_code getPE32Header(const pe32_header *&Res) const;
448 std::error_code getPE32PlusHeader(const pe32plus_header *&Res) const;
449 std::error_code getDataDirectory(uint32_t index,
450 const data_directory *&Res) const;
451 std::error_code getSection(int32_t index, const coff_section *&Res) const;
452 std::error_code getSymbol(uint32_t index, const coff_symbol *&Res) const;
442453 template
443 error_code getAuxSymbol(uint32_t index, const T *&Res) const {
454 std::error_code getAuxSymbol(uint32_t index, const T *&Res) const {
444455 const coff_symbol *s;
445 error_code ec = getSymbol(index, s);
456 std::error_code ec = getSymbol(index, s);
446457 Res = reinterpret_cast(s);
447458 return ec;
448459 }
449 error_code getSymbolName(const coff_symbol *symbol, StringRef &Res) const;
460 std::error_code getSymbolName(const coff_symbol *symbol,
461 StringRef &Res) const;
450462 ArrayRef getSymbolAuxData(const coff_symbol *symbol) const;
451463
452 error_code getSectionName(const coff_section *Sec, StringRef &Res) const;
453 error_code getSectionContents(const coff_section *Sec,
454 ArrayRef &Res) const;
455
456 error_code getVaPtr(uint64_t VA, uintptr_t &Res) const;
457 error_code getRvaPtr(uint32_t Rva, uintptr_t &Res) const;
458 error_code getHintName(uint32_t Rva, uint16_t &Hint, StringRef &Name) const;
464 std::error_code getSectionName(const coff_section *Sec, StringRef &Res) const;
465 std::error_code getSectionContents(const coff_section *Sec,
466 ArrayRef &Res) const;
467
468 std::error_code getVaPtr(uint64_t VA, uintptr_t &Res) const;
469 std::error_code getRvaPtr(uint32_t Rva, uintptr_t &Res) const;
470 std::error_code getHintName(uint32_t Rva, uint16_t &Hint,
471 StringRef &Name) const;
459472
460473 static inline bool classof(const Binary *v) { return v->isCOFF(); }
461474 };
470483
471484 bool operator==(const ImportDirectoryEntryRef &Other) const;
472485 void moveNext();
473 error_code getName(StringRef &Result) const;
474
475 error_code
486 std::error_code getName(StringRef &Result) const;
487
488 std::error_code
476489 getImportTableEntry(const import_directory_table_entry *&Result) const;
477490
478 error_code
491 std::error_code
479492 getImportLookupEntry(const import_lookup_table_entry32 *&Result) const;
480493
481494 private:
495508 bool operator==(const ExportDirectoryEntryRef &Other) const;
496509 void moveNext();
497510
498 error_code getDllName(StringRef &Result) const;
499 error_code getOrdinalBase(uint32_t &Result) const;
500 error_code getOrdinal(uint32_t &Result) const;
501 error_code getExportRVA(uint32_t &Result) const;
502 error_code getSymbolName(StringRef &Result) const;
511 std::error_code getDllName(StringRef &Result) const;
512 std::error_code getOrdinalBase(uint32_t &Result) const;
513 std::error_code getOrdinal(uint32_t &Result) const;
514 std::error_code getExportRVA(uint32_t &Result) const;
515 std::error_code getSymbolName(StringRef &Result) const;
503516
504517 private:
505518 const export_directory_table_entry *ExportTable;
316316 std::pair
317317 getRelocationSymbol(const Elf_Shdr *RelSec, const RelT *Rel) const;
318318
319 ELFFile(MemoryBuffer *Object, error_code &ec);
319 ELFFile(MemoryBuffer *Object, std::error_code &ec);
320320
321321 bool isMipsELF64() const {
322322 return Header->e_machine == ELF::EM_MIPS &&
620620 }
621621
622622 template
623 ELFFile::ELFFile(MemoryBuffer *Object, error_code &ec)
624 : Buf(Object),
625 SectionHeaderTable(nullptr),
626 dot_shstrtab_sec(nullptr),
627 dot_strtab_sec(nullptr),
628 dot_symtab_sec(nullptr),
629 SymbolTableSectionHeaderIndex(nullptr),
630 dot_gnu_version_sec(nullptr),
631 dot_gnu_version_r_sec(nullptr),
632 dot_gnu_version_d_sec(nullptr),
623 ELFFile::ELFFile(MemoryBuffer *Object, std::error_code &ec)
624 : Buf(Object), SectionHeaderTable(nullptr), dot_shstrtab_sec(nullptr),
625 dot_strtab_sec(nullptr), dot_symtab_sec(nullptr),
626 SymbolTableSectionHeaderIndex(nullptr), dot_gnu_version_sec(nullptr),
627 dot_gnu_version_r_sec(nullptr), dot_gnu_version_d_sec(nullptr),
633628 dt_soname(nullptr) {
634629 const uint64_t FileSize = Buf->getBufferSize();
635630
747742 }
748743 }
749744
750 ec = error_code();
745 ec = std::error_code();
751746 }
752747
753748 // Get the symbol table index in the symtab section given a symbol
5656 ELFFile EF;
5757
5858 void moveSymbolNext(DataRefImpl &Symb) const override;
59 error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const override;
60 error_code getSymbolAddress(DataRefImpl Symb, uint64_t &Res) const override;
61 error_code getSymbolAlignment(DataRefImpl Symb, uint32_t &Res) const override;
62 error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const override;
59 std::error_code getSymbolName(DataRefImpl Symb,
60 StringRef &Res) const override;
61 std::error_code getSymbolAddress(DataRefImpl Symb,
62 uint64_t &Res) const override;
63 std::error_code getSymbolAlignment(DataRefImpl Symb,
64 uint32_t &Res) const override;
65 std::error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const override;
6366 uint32_t getSymbolFlags(DataRefImpl Symb) const override;
64 error_code getSymbolType(DataRefImpl Symb,
65 SymbolRef::Type &Res) const override;
66 error_code getSymbolSection(DataRefImpl Symb,
67 section_iterator &Res) const override;
68
69 error_code getLibraryNext(DataRefImpl Data,
70 LibraryRef &Result) const override;
71 error_code getLibraryPath(DataRefImpl Data, StringRef &Res) const override;
67 std::error_code getSymbolType(DataRefImpl Symb,
68 SymbolRef::Type &Res) const override;
69 std::error_code getSymbolSection(DataRefImpl Symb,
70 section_iterator &Res) const override;
71
72 std::error_code getLibraryNext(DataRefImpl Data,
73 LibraryRef &Result) const override;
74 std::error_code getLibraryPath(DataRefImpl Data,
75 StringRef &Res) const override;
7276
7377 void moveSectionNext(DataRefImpl &Sec) const override;
74 error_code getSectionName(DataRefImpl Sec, StringRef &Res) const override;
75 error_code getSectionAddress(DataRefImpl Sec, uint64_t &Res) const override;
76 error_code getSectionSize(DataRefImpl Sec, uint64_t &Res) const override;
77 error_code getSectionContents(DataRefImpl Sec, StringRef &Res) const override;
78 error_code getSectionAlignment(DataRefImpl Sec, uint64_t &Res) const override;
79 error_code isSectionText(DataRefImpl Sec, bool &Res) const override;
80 error_code isSectionData(DataRefImpl Sec, bool &Res) const override;
81 error_code isSectionBSS(DataRefImpl Sec, bool &Res) const override;
82 error_code isSectionRequiredForExecution(DataRefImpl Sec,
83 bool &Res) const override;
84 error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const override;
85 error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const override;
86 error_code isSectionReadOnlyData(DataRefImpl Sec, bool &Res) const override;
87 error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb,
88 bool &Result) const override;
78 std::error_code getSectionName(DataRefImpl Sec,
79 StringRef &Res) const override;
80 std::error_code getSectionAddress(DataRefImpl Sec,
81 uint64_t &Res) const override;
82 std::error_code getSectionSize(DataRefImpl Sec, uint64_t &Res) const override;
83 std::error_code getSectionContents(DataRefImpl Sec,
84 StringRef &Res) const override;
85 std::error_code getSectionAlignment(DataRefImpl Sec,
86 uint64_t &Res) const override;
87 std::error_code isSectionText(DataRefImpl Sec, bool &Res) const override;
88 std::error_code isSectionData(DataRefImpl Sec, bool &Res) const override;
89 std::error_code isSectionBSS(DataRefImpl Sec, bool &Res) const override;
90 std::error_code isSectionRequiredForExecution(DataRefImpl Sec,
91 bool &Res) const override;
92 std::error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const override;
93 std::error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const override;
94 std::error_code isSectionReadOnlyData(DataRefImpl Sec,
95 bool &Res) const override;
96 std::error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb,
97 bool &Result) const override;
8998 relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
9099 relocation_iterator section_rel_end(DataRefImpl Sec) const override;
91100 section_iterator getRelocatedSection(DataRefImpl Sec) const override;
92101
93102 void moveRelocationNext(DataRefImpl &Rel) const override;
94 error_code getRelocationAddress(DataRefImpl Rel,
95 uint64_t &Res) const override;
96 error_code getRelocationOffset(DataRefImpl Rel, uint64_t &Res) const override;
103 std::error_code getRelocationAddress(DataRefImpl Rel,
104 uint64_t &Res) const override;
105 std::error_code getRelocationOffset(DataRefImpl Rel,
106 uint64_t &Res) const override;
97107 symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
98 error_code getRelocationType(DataRefImpl Rel, uint64_t &Res) const override;
99 error_code getRelocationTypeName(DataRefImpl Rel,
100 SmallVectorImpl &Result) const override;
101 error_code getRelocationValueString(DataRefImpl Rel,
102 SmallVectorImpl &Result) const override;
108 std::error_code getRelocationType(DataRefImpl Rel,
109 uint64_t &Res) const override;
110 std::error_code
111 getRelocationTypeName(DataRefImpl Rel,
112 SmallVectorImpl &Result) const override;
113 std::error_code
114 getRelocationValueString(DataRefImpl Rel,
115 SmallVectorImpl &Result) const override;
103116
104117 uint64_t getROffset(DataRefImpl Rel) const;
105118 StringRef getRelocationTypeName(uint32_t Type) const;
163176 bool isDyldELFObject;
164177
165178 public:
166 ELFObjectFile(MemoryBuffer *Object, error_code &EC, bool BufferOwned = true);
179 ELFObjectFile(MemoryBuffer *Object, std::error_code &EC,
180 bool BufferOwned = true);
167181
168182 const Elf_Sym *getSymbol(DataRefImpl Symb) const;
169183
179193 library_iterator needed_library_begin() const override;
180194 library_iterator needed_library_end() const override;
181195
182 error_code getRelocationAddend(DataRefImpl Rel, int64_t &Res) const;
183 error_code getSymbolVersion(SymbolRef Symb, StringRef &Version,
184 bool &IsDefault) const;
185
196 std::error_code getRelocationAddend(DataRefImpl Rel, int64_t &Res) const;
197 std::error_code getSymbolVersion(SymbolRef Symb, StringRef &Version,
198 bool &IsDefault) const;
186199
187200 uint8_t getBytesInAddress() const override;
188201 StringRef getFileFormatName() const override;
211224 }
212225
213226 template
214 error_code ELFObjectFile::getSymbolName(DataRefImpl Symb,
215 StringRef &Result) const {
227 std::error_code ELFObjectFile::getSymbolName(DataRefImpl Symb,
228 StringRef &Result) const {
216229 ErrorOr Name = EF.getSymbolName(toELFSymIter(Symb));
217230 if (!Name)
218231 return Name.getError();
221234 }
222235
223236 template
224 error_code ELFObjectFile::getSymbolVersion(SymbolRef SymRef,
225 StringRef &Version,
226 bool &IsDefault) const {
237 std::error_code ELFObjectFile::getSymbolVersion(SymbolRef SymRef,
238 StringRef &Version,
239 bool &IsDefault) const {
227240 DataRefImpl Symb = SymRef.getRawDataRefImpl();
228241 const Elf_Sym *symb = getSymbol(Symb);
229242 ErrorOr Ver =
235248 }
236249
237250 template
238 error_code ELFObjectFile::getSymbolAddress(DataRefImpl Symb,
239 uint64_t &Result) const {
251 std::error_code ELFObjectFile::getSymbolAddress(DataRefImpl Symb,
252 uint64_t &Result) const {
240253 const Elf_Sym *ESym = getSymbol(Symb);
241254 switch (EF.getSymbolTableIndex(ESym)) {
242255 case ELF::SHN_COMMON:
264277 }
265278
266279 template
267 error_code ELFObjectFile::getSymbolAlignment(DataRefImpl Symb,
268 uint32_t &Res) const {
280 std::error_code ELFObjectFile::getSymbolAlignment(DataRefImpl Symb,
281 uint32_t &Res) const {
269282 Elf_Sym_Iter Sym = toELFSymIter(Symb);
270283 if (Sym->st_shndx == ELF::SHN_COMMON)
271284 Res = Sym->st_value;
275288 }
276289
277290 template
278 error_code ELFObjectFile::getSymbolSize(DataRefImpl Symb,
279 uint64_t &Result) const {
291 std::error_code ELFObjectFile::getSymbolSize(DataRefImpl Symb,
292 uint64_t &Result) const {
280293 Result = toELFSymIter(Symb)->st_size;
281294 return object_error::success;
282295 }
283296
284297 template
285 error_code ELFObjectFile::getSymbolType(DataRefImpl Symb,
286 SymbolRef::Type &Result) const {
298 std::error_code
299 ELFObjectFile::getSymbolType(DataRefImpl Symb,
300 SymbolRef::Type &Result) const {
287301 const Elf_Sym *ESym = getSymbol(Symb);
288302
289303 switch (ESym->getType()) {
342356 }
343357
344358 template
345 error_code ELFObjectFile::getSymbolSection(DataRefImpl Symb,
346 section_iterator &Res) const {
359 std::error_code
360 ELFObjectFile::getSymbolSection(DataRefImpl Symb,
361 section_iterator &Res) const {
347362 const Elf_Sym *ESym = getSymbol(Symb);
348363 const Elf_Shdr *ESec = EF.getSection(ESym);
349364 if (!ESec)
362377 }
363378
364379 template
365 error_code ELFObjectFile::getSectionName(DataRefImpl Sec,
366 StringRef &Result) const {
380 std::error_code ELFObjectFile::getSectionName(DataRefImpl Sec,
381 StringRef &Result) const {
367382 ErrorOr Name = EF.getSectionName(&*toELFShdrIter(Sec));
368383 if (!Name)
369384 return Name.getError();
372387 }
373388
374389 template
375 error_code ELFObjectFile::getSectionAddress(DataRefImpl Sec,
376 uint64_t &Result) const {
390 std::error_code ELFObjectFile::getSectionAddress(DataRefImpl Sec,
391 uint64_t &Result) const {
377392 Result = toELFShdrIter(Sec)->sh_addr;
378393 return object_error::success;
379394 }
380395
381396 template
382 error_code ELFObjectFile::getSectionSize(DataRefImpl Sec,
383 uint64_t &Result) const {
397 std::error_code ELFObjectFile::getSectionSize(DataRefImpl Sec,
398 uint64_t &Result) const {
384399 Result = toELFShdrIter(Sec)->sh_size;
385400 return object_error::success;
386401 }
387402
388403 template
389 error_code ELFObjectFile::getSectionContents(DataRefImpl Sec,
390 StringRef &Result) const {
404 std::error_code
405 ELFObjectFile::getSectionContents(DataRefImpl Sec,
406 StringRef &Result) const {
391407 Elf_Shdr_Iter EShdr = toELFShdrIter(Sec);
392408 Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
393409 return object_error::success;
394410 }
395411
396412 template
397 error_code ELFObjectFile::getSectionAlignment(DataRefImpl Sec,
398 uint64_t &Result) const {
413 std::error_code
414 ELFObjectFile::getSectionAlignment(DataRefImpl Sec,
415 uint64_t &Result) const {
399416 Result = toELFShdrIter(Sec)->sh_addralign;
400417 return object_error::success;
401418 }
402419
403420 template
404 error_code ELFObjectFile::isSectionText(DataRefImpl Sec,
405 bool &Result) const {
421 std::error_code ELFObjectFile::isSectionText(DataRefImpl Sec,
422 bool &Result) const {
406423 Result = toELFShdrIter(Sec)->sh_flags & ELF::SHF_EXECINSTR;
407424 return object_error::success;
408425 }
409426
410427 template
411 error_code ELFObjectFile::isSectionData(DataRefImpl Sec,
412 bool &Result) const {
428 std::error_code ELFObjectFile::isSectionData(DataRefImpl Sec,
429 bool &Result) const {
413430 Elf_Shdr_Iter EShdr = toELFShdrIter(Sec);
414431 Result = EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
415432 EShdr->sh_type == ELF::SHT_PROGBITS;
417434 }
418435
419436 template
420 error_code ELFObjectFile::isSectionBSS(DataRefImpl Sec,
421 bool &Result) const {
437 std::error_code ELFObjectFile::isSectionBSS(DataRefImpl Sec,
438 bool &Result) const {
422439 Elf_Shdr_Iter EShdr = toELFShdrIter(Sec);
423440 Result = EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
424441 EShdr->sh_type == ELF::SHT_NOBITS;
426443 }
427444
428445 template
429 error_code
446 std::error_code
430447 ELFObjectFile::isSectionRequiredForExecution(DataRefImpl Sec,
431448 bool &Result) const {
432449 Result = toELFShdrIter(Sec)->sh_flags & ELF::SHF_ALLOC;
434451 }
435452
436453 template
437 error_code ELFObjectFile::isSectionVirtual(DataRefImpl Sec,
438 bool &Result) const {
454 std::error_code ELFObjectFile::isSectionVirtual(DataRefImpl Sec,
455 bool &Result) const {
439456 Result = toELFShdrIter(Sec)->sh_type == ELF::SHT_NOBITS;
440457 return object_error::success;
441458 }
442459
443460 template
444 error_code ELFObjectFile::isSectionZeroInit(DataRefImpl Sec,
445 bool &Result) const {
461 std::error_code ELFObjectFile::isSectionZeroInit(DataRefImpl Sec,
462 bool &Result) const {
446463 Result = toELFShdrIter(Sec)->sh_type == ELF::SHT_NOBITS;
447464 return object_error::success;
448465 }
449466
450467 template
451 error_code ELFObjectFile::isSectionReadOnlyData(DataRefImpl Sec,
452 bool &Result) const {
468 std::error_code ELFObjectFile::isSectionReadOnlyData(DataRefImpl Sec,
469 bool &Result) const {
453470 Elf_Shdr_Iter EShdr = toELFShdrIter(Sec);
454471 Result = !(EShdr->sh_flags & (ELF::SHF_WRITE | ELF::SHF_EXECINSTR));
455472 return object_error::success;
456473 }
457474
458475 template
459 error_code ELFObjectFile::sectionContainsSymbol(DataRefImpl Sec,
460 DataRefImpl Symb,
461 bool &Result) const {
476 std::error_code ELFObjectFile::sectionContainsSymbol(DataRefImpl Sec,
477 DataRefImpl Symb,
478 bool &Result) const {
462479 Elf_Sym_Iter ESym = toELFSymIter(Symb);
463480
464481 uintX_t Index = ESym->st_shndx;
552569 }
553570
554571 template
555 error_code ELFObjectFile::getRelocationAddress(DataRefImpl Rel,
556 uint64_t &Result) const {
572 std::error_code
573 ELFObjectFile::getRelocationAddress(DataRefImpl Rel,
574 uint64_t &Result) const {
557575 uint64_t ROffset = getROffset(Rel);
558576 const Elf_Ehdr *Header = EF.getHeader();
559577
569587 }
570588
571589 template
572 error_code ELFObjectFile::getRelocationOffset(DataRefImpl Rel,
573 uint64_t &Result) const {
590 std::error_code
591 ELFObjectFile::getRelocationOffset(DataRefImpl Rel,
592 uint64_t &Result) const {
574593 assert(EF.getHeader()->e_type == ELF::ET_REL &&
575594 "Only relocatable object files have relocation offsets");
576595 Result = getROffset(Rel);
591610 }
592611
593612 template
594 error_code ELFObjectFile::getRelocationType(DataRefImpl Rel,
595 uint64_t &Result) const {
613 std::error_code ELFObjectFile::getRelocationType(DataRefImpl Rel,
614 uint64_t &Result) const {
596615 const Elf_Shdr *sec = getRelSection(Rel);
597616 switch (sec->sh_type) {
598617 default:
615634 }
616635
617636 template
618 error_code ELFObjectFile::getRelocationTypeName(
637 std::error_code ELFObjectFile::getRelocationTypeName(
619638 DataRefImpl Rel, SmallVectorImpl &Result) const {
620639 const Elf_Shdr *sec = getRelSection(Rel);
621640 uint32_t type;
637656 }
638657
639658 template
640 error_code ELFObjectFile::getRelocationAddend(DataRefImpl Rel,
641 int64_t &Result) const {
659 std::error_code
660 ELFObjectFile::getRelocationAddend(DataRefImpl Rel,
661 int64_t &Result) const {
642662 const Elf_Shdr *sec = getRelSection(Rel);
643663 switch (sec->sh_type) {
644664 default:
655675 }
656676
657677 template
658 error_code ELFObjectFile::getRelocationValueString(
678 std::error_code ELFObjectFile::getRelocationValueString(
659679 DataRefImpl Rel, SmallVectorImpl &Result) const {
660680 const Elf_Shdr *sec = getRelSection(Rel);
661681 uint8_t type;
753773 }
754774
755775 template
756 ELFObjectFile::ELFObjectFile(MemoryBuffer *Object, error_code &ec,
776 ELFObjectFile::ELFObjectFile(MemoryBuffer *Object, std::error_code &ec,
757777 bool BufferOwned)
758778 : ObjectFile(getELFType(static_cast(ELFT::TargetEndianness) ==
759779 support::little,
816836 }
817837
818838 template
819 error_code ELFObjectFile::getLibraryNext(DataRefImpl Data,
820 LibraryRef &Result) const {
839 std::error_code ELFObjectFile::getLibraryNext(DataRefImpl Data,
840 LibraryRef &Result) const {
821841 Elf_Dyn_Iter DI = toELFDynIter(Data);
822842 Elf_Dyn_Iter DE = EF.end_dynamic_table();
823843
831851 }
832852
833853 template
834 error_code ELFObjectFile::getLibraryPath(DataRefImpl Data,
835 StringRef &Res) const {
854 std::error_code ELFObjectFile::getLibraryPath(DataRefImpl Data,
855 StringRef &Res) const {
836856 Res = EF.getDynamicString(toELFDynIter(Data)->getVal());
837857 return object_error::success;
838858 }
930950
931951 /// FIXME: Maybe we should have a base ElfObjectFile that is not a template
932952 /// and make these member functions?
933 inline error_code getELFRelocationAddend(const RelocationRef R,
934 int64_t &Addend) {
953 inline std::error_code getELFRelocationAddend(const RelocationRef R,
954 int64_t &Addend) {
935955 const ObjectFile *Obj = R.getObjectFile();
936956 DataRefImpl DRI = R.getRawDataRefImpl();
937957 // Little-endian 32-bit
974994
975995 /// This is a generic interface for retrieving GNU symbol version
976996 /// information from an ELFObjectFile.
977 inline error_code GetELFSymbolVersion(const ObjectFile *Obj,
978 const SymbolRef &Sym, StringRef &Version,
979 bool &IsDefault) {
997 inline std::error_code GetELFSymbolVersion(const ObjectFile *Obj,
998 const SymbolRef &Sym,
999 StringRef &Version,
1000 bool &IsDefault) {
9801001 // Little-endian 32-bit
9811002 if (const ELF32LEObjectFile *ELFObj = dyn_cast(Obj))
9821003 return ELFObj->getSymbolVersion(Sym, Version, IsDefault);
1616 #include
1717
1818 namespace llvm {
19 using std::error_code;
2019 namespace object {
2120
2221 const std::error_category &object_category();
2928 unexpected_eof
3029 };
3130
32 inline error_code make_error_code(object_error e) {
33 return error_code(static_cast(e), object_category());
31 inline std::error_code make_error_code(object_error e) {
32 return std::error_code(static_cast(e), object_category());
3433 }
3534
3635 } // end namespace object.
2626 std::unique_ptr Mang;
2727
2828 public:
29 IRObjectFile(MemoryBuffer *Object, error_code &EC, LLVMContext &Context,
29 IRObjectFile(MemoryBuffer *Object, std::error_code &EC, LLVMContext &Context,
3030 bool BufferOwned);
3131 void moveSymbolNext(DataRefImpl &Symb) const override;
32 error_code printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override;
32 std::error_code printSymbolName(raw_ostream &OS,
33 DataRefImpl Symb) const override;
3334 uint32_t getSymbolFlags(DataRefImpl Symb) const override;
3435 const GlobalValue &getSymbolGV(DataRefImpl Symb) const;
3536 basic_symbol_iterator symbol_begin_impl() const override;
3939
4040 void moveNext();
4141
42 error_code getOffset(uint32_t &Result) const;
43 error_code getLength(uint16_t &Result) const;
44 error_code getKind(uint16_t &Result) const;
42 std::error_code getOffset(uint32_t &Result) const;
43 std::error_code getLength(uint16_t &Result) const;
44 std::error_code getKind(uint16_t &Result) const;
4545
4646 DataRefImpl getRawDataRefImpl() const;
4747 const ObjectFile *getObjectFile() const;
5656 };
5757
5858 MachOObjectFile(MemoryBuffer *Object, bool IsLittleEndian, bool Is64Bits,
59 error_code &EC, bool BufferOwned = true);
59 std::error_code &EC, bool BufferOwned = true);
6060
6161 void moveSymbolNext(DataRefImpl &Symb) const override;
62 error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const override;
62 std::error_code getSymbolName(DataRefImpl Symb,
63 StringRef &Res) const override;
6364
6465 // MachO specific.
65 error_code getIndirectName(DataRefImpl Symb, StringRef &Res) const;
66
67 error_code getSymbolAddress(DataRefImpl Symb, uint64_t &Res) const override;
68 error_code getSymbolAlignment(DataRefImpl Symb, uint32_t &Res) const override;
69 error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const override;
70 error_code getSymbolType(DataRefImpl Symb,
71 SymbolRef::Type &Res) const override;
66 std::error_code getIndirectName(DataRefImpl Symb, StringRef &Res) const;
67
68 std::error_code getSymbolAddress(DataRefImpl Symb,
69 uint64_t &Res) const override;
70 std::error_code getSymbolAlignment(DataRefImpl Symb,
71 uint32_t &Res) const override;
72 std::error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const override;
73 std::error_code getSymbolType(DataRefImpl Symb,
74 SymbolRef::Type &Res) const override;
7275 uint32_t getSymbolFlags(DataRefImpl Symb) const override;
73 error_code getSymbolSection(DataRefImpl Symb,
74 section_iterator &Res) const override;
76 std::error_code getSymbolSection(DataRefImpl Symb,
77 section_iterator &Res) const override;
7578
7679 void moveSectionNext(DataRefImpl &Sec) const override;
77 error_code getSectionName(DataRefImpl Sec, StringRef &Res) const override;
78 error_code getSectionAddress(DataRefImpl Sec, uint64_t &Res) const override;
79 error_code getSectionSize(DataRefImpl Sec, uint64_t &Res) const override;
80 error_code getSectionContents(DataRefImpl Sec, StringRef &Res) const override;
81 error_code getSectionAlignment(DataRefImpl Sec, uint64_t &Res) const override;
82 error_code isSectionText(DataRefImpl Sec, bool &Res) const override;
83 error_code isSectionData(DataRefImpl Sec, bool &Res) const override;
84 error_code isSectionBSS(DataRefImpl Sec, bool &Res) const override;
85 error_code isSectionRequiredForExecution(DataRefImpl Sec,
86 bool &Res) const override;
87 error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const override;
88 error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const override;
89 error_code isSectionReadOnlyData(DataRefImpl Sec, bool &Res) const override;
90 error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb,
91 bool &Result) const override;
80 std::error_code getSectionName(DataRefImpl Sec,
81 StringRef &Res) const override;
82 std::error_code getSectionAddress(DataRefImpl Sec,
83 uint64_t &Res) const override;
84 std::error_code getSectionSize(DataRefImpl Sec, uint64_t &Res) const override;
85 std::error_code getSectionContents(DataRefImpl Sec,
86 StringRef &Res) const override;
87 std::error_code getSectionAlignment(DataRefImpl Sec,
88 uint64_t &Res) const override;
89 std::error_code isSectionText(DataRefImpl Sec, bool &Res) const override;
90 std::error_code isSectionData(DataRefImpl Sec, bool &Res) const override;
91 std::error_code isSectionBSS(DataRefImpl Sec, bool &Res) const override;
92 std::error_code isSectionRequiredForExecution(DataRefImpl Sec,
93 bool &Res) const override;
94 std::error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const override;
95 std::error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const override;
96 std::error_code isSectionReadOnlyData(DataRefImpl Sec,
97 bool &Res) const override;
98 std::error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb,
99 bool &Result) const override;
92100 relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
93101 relocation_iterator section_rel_end(DataRefImpl Sec) const override;
94102
95103 void moveRelocationNext(DataRefImpl &Rel) const override;
96 error_code getRelocationAddress(DataRefImpl Rel,
97 uint64_t &Res) const override;
98 error_code getRelocationOffset(DataRefImpl Rel, uint64_t &Res) const override;
104 std::error_code getRelocationAddress(DataRefImpl Rel,
105 uint64_t &Res) const override;
106 std::error_code getRelocationOffset(DataRefImpl Rel,
107 uint64_t &Res) const override;
99108 symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
100 error_code getRelocationType(DataRefImpl Rel, uint64_t &Res) const override;
101 error_code getRelocationTypeName(DataRefImpl Rel,
102 SmallVectorImpl &Result) const override;
103 error_code getRelocationValueString(DataRefImpl Rel,
104 SmallVectorImpl &Result) const override;
105 error_code getRelocationHidden(DataRefImpl Rel, bool &Result) const override;
106
107 error_code getLibraryNext(DataRefImpl LibData,
108 LibraryRef &Res) const override;
109 error_code getLibraryPath(DataRefImpl LibData, StringRef &Res) const override;
109 std::error_code getRelocationType(DataRefImpl Rel,
110 uint64_t &Res) const override;
111 std::error_code
112 getRelocationTypeName(DataRefImpl Rel,
113 SmallVectorImpl &Result) const override;
114 std::error_code
115 getRelocationValueString(DataRefImpl Rel,
116 SmallVectorImpl &Result) const override;
117 std::error_code getRelocationHidden(DataRefImpl Rel,
118 bool &Result) const override;
119
120 std::error_code getLibraryNext(DataRefImpl LibData,
121 LibraryRef &Res) const override;
122 std::error_code getLibraryPath(DataRefImpl LibData,
123 StringRef &Res) const override;
110124
111125 // MachO specific.
112 error_code getLibraryShortNameByIndex(unsigned Index, StringRef &Res);
126 std::error_code getLibraryShortNameByIndex(unsigned Index, StringRef &Res);
113127
114128 // TODO: Would be useful to have an iterator based version
115129 // of the load command interface too.
247261 // the OwningObject ObjectFile is a MachOObjectFile a static_cast<> is used for
248262 // the methods that get the values of the fields of the reference.
249263
250 inline error_code DiceRef::getOffset(uint32_t &Result) const {
264 inline std::error_code DiceRef::getOffset(uint32_t &Result) const {
251265 const MachOObjectFile *MachOOF =
252266 static_cast(OwningObject);
253267 MachO::data_in_code_entry Dice = MachOOF->getDice(DicePimpl);
255269 return object_error::success;
256270 }
257271
258 inline error_code DiceRef::getLength(uint16_t &Result) const {
272 inline std::error_code DiceRef::getLength(uint16_t &Result) const {
259273 const MachOObjectFile *MachOOF =
260274 static_cast(OwningObject);
261275 MachO::data_in_code_entry Dice = MachOOF->getDice(DicePimpl);
263277 return object_error::success;
264278 }
265279
266 inline error_code DiceRef::getKind(uint16_t &Result) const {
280 inline std::error_code DiceRef::getKind(uint16_t &Result) const {
267281 const MachOObjectFile *MachOOF =
268282 static_cast(OwningObject);
269283 MachO::data_in_code_entry Dice = MachOOF->getDice(DicePimpl);
5252 ObjectForArch getNext() const { return ObjectForArch(Parent, Index + 1); }
5353 uint32_t getCPUType() const { return Header.cputype; }
5454
55 error_code getAsObjectFile(std::unique_ptr &Result) const;
55 std::error_code getAsObjectFile(std::unique_ptr &Result) const;
5656
57 error_code getAsArchive(std::unique_ptr &Result) const;
57 std::error_code getAsArchive(std::unique_ptr &Result) const;
5858 };
5959
6060 class object_iterator {
7878 }
7979 };
8080
81 MachOUniversalBinary(MemoryBuffer *Source, error_code &ec);
81 MachOUniversalBinary(MemoryBuffer *Source, std::error_code &ec);
8282 static ErrorOr create(MemoryBuffer *Source);
8383
8484 object_iterator begin_objects() const {
9595 return V->isMachOUniversalBinary();
9696 }
9797
98 error_code getObjectForArch(Triple::ArchType Arch,
99 std::unique_ptr &Result) const;
98 std::error_code getObjectForArch(Triple::ArchType Arch,
99 std::unique_ptr &Result) const;
100100 };
101101
102102 }
4545
4646 void moveNext();
4747
48 error_code getAddress(uint64_t &Result) const;
49 error_code getOffset(uint64_t &Result) const;
48 std::error_code getAddress(uint64_t &Result) const;
49 std::error_code getOffset(uint64_t &Result) const;
5050 symbol_iterator getSymbol() const;
51 error_code getType(uint64_t &Result) const;
51 std::error_code getType(uint64_t &Result) const;
5252
5353 /// @brief Indicates whether this relocation should hidden when listing
5454 /// relocations, usually because it is the trailing part of a multipart
5555 /// relocation that will be printed as part of the leading relocation.
56 error_code getHidden(bool &Result) const;
56 std::error_code getHidden(bool &Result) const;
5757
5858 /// @brief Get a string that represents the type of this relocation.
5959 ///
6060 /// This is for display purposes only.
61 error_code getTypeName(SmallVectorImpl &Result) const;
61 std::error_code getTypeName(SmallVectorImpl &Result) const;
6262
6363 /// @brief Get a string that represents the calculation of the value of this
6464 /// relocation.
6565 ///
6666 /// This is for display purposes only.
67 error_code getValueString(SmallVectorImpl &Result) const;
67 std::error_code getValueString(SmallVectorImpl &Result) const;
6868
6969 DataRefImpl getRawDataRefImpl() const;
7070 const ObjectFile *getObjectFile() const;
9191
9292 void moveNext();
9393
94 error_code getName(StringRef &Result) const;
95 error_code getAddress(uint64_t &Result) const;
96 error_code getSize(uint64_t &Result) const;
97 error_code getContents(StringRef &Result) const;
94 std::error_code getName(StringRef &Result) const;
95 std::error_code getAddress(uint64_t &Result) const;
96 std::error_code getSize(uint64_t &Result) const;
97 std::error_code getContents(StringRef &Result) const;
9898
9999 /// @brief Get the alignment of this section as the actual value (not log 2).
100 error_code getAlignment(uint64_t &Result) const;
100 std::error_code getAlignment(uint64_t &Result) const;
101101
102102 // FIXME: Move to the normalization layer when it's created.
103 error_code isText(bool &Result) const;
104 error_code isData(bool &Result) const;
105 error_code isBSS(bool &Result) const;
106 error_code isRequiredForExecution(bool &Result) const;
107 error_code isVirtual(bool &Result) const;
108 error_code isZeroInit(bool &Result) const;
109 error_code isReadOnlyData(bool &Result) const;
110
111 error_code containsSymbol(SymbolRef S, bool &Result) const;
103 std::error_code isText(bool &Result) const;
104 std::error_code isData(bool &Result) const;
105 std::error_code isBSS(bool &Result) const;
106 std::error_code isRequiredForExecution(bool &Result) const;
107 std::error_code isVirtual(bool &Result) const;
108 std::error_code isZeroInit(bool &Result) const;
109 std::error_code isReadOnlyData(bool &Result) const;
110
111 std::error_code containsSymbol(SymbolRef S, bool &Result) const;
112112
113113 relocation_iterator relocation_begin() const;
114114 relocation_iterator relocation_end() const;
140140
141141 SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner);
142142
143 error_code getName(StringRef &Result) const;
143 std::error_code getName(StringRef &Result) const;
144144 /// Returns the symbol virtual address (i.e. address at which it will be
145145 /// mapped).
146 error_code getAddress(uint64_t &Result) const;
146 std::error_code getAddress(uint64_t &Result) const;
147147 /// @brief Get the alignment of this symbol as the actual value (not log 2).
148 error_code getAlignment(uint32_t &Result) const;
149 error_code getSize(uint64_t &Result) const;
150 error_code getType(SymbolRef::Type &Result) const;
148 std::error_code getAlignment(uint32_t &Result) const;
149 std::error_code getSize(uint64_t &Result) const;
150 std::error_code getType(SymbolRef::Type &Result) const;
151151
152152 /// @brief Get section this symbol is defined in reference to. Result is
153153 /// end_sections() if it is undefined or is an absolute symbol.
154 error_code getSection(section_iterator &Result) const;
154 std::error_code getSection(section_iterator &Result) const;
155155
156156 const ObjectFile *getObject() const;
157157 };
189189 bool operator==(const LibraryRef &Other) const;
190190 bool operator<(const LibraryRef &Other) const;
191191
192 error_code getNext(LibraryRef &Result) const;
192 std::error_code getNext(LibraryRef &Result) const;
193193
194194 // Get the path to this library, as stored in the object file.
195 error_code getPath(StringRef &Result) const;
195 std::error_code getPath(StringRef &Result) const;
196196
197197 DataRefImpl getRawDataRefImpl() const;
198198 };
222222 // Implementations assume that the DataRefImpl is valid and has not been
223223 // modified externally. It's UB otherwise.
224224 friend class SymbolRef;
225 virtual error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const = 0;
226 error_code printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override;
227 virtual error_code getSymbolAddress(DataRefImpl Symb, uint64_t &Res) const = 0;
228 virtual error_code getSymbolAlignment(DataRefImpl Symb, uint32_t &Res) const;
229 virtual error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const = 0;
230 virtual error_code getSymbolType(DataRefImpl Symb,
231 SymbolRef::Type &Res) const = 0;
232 virtual error_code getSymbolSection(DataRefImpl Symb,
233 section_iterator &Res) const = 0;
225 virtual std::error_code getSymbolName(DataRefImpl Symb,
226 StringRef &Res) const = 0;
227 std::error_code printSymbolName(raw_ostream &OS,
228 DataRefImpl Symb) const override;
229 virtual std::error_code getSymbolAddress(DataRefImpl Symb,
230 uint64_t &Res) const = 0;
231 virtual std::error_code getSymbolAlignment(DataRefImpl Symb,
232 uint32_t &Res) const;
233 virtual std::error_code getSymbolSize(DataRefImpl Symb,
234 uint64_t &Res) const = 0;
235 virtual std::error_code getSymbolType(DataRefImpl Symb,
236 SymbolRef::Type &Res) const = 0;
237 virtual std::error_code getSymbolSection(DataRefImpl Symb,
238 section_iterator &Res) const = 0;
234239
235240 // Same as above for SectionRef.
236241 friend class SectionRef;
237242 virtual void moveSectionNext(DataRefImpl &Sec) const = 0;
238 virtual error_code getSectionName(DataRefImpl Sec, StringRef &Res) const = 0;
239 virtual error_code getSectionAddress(DataRefImpl Sec, uint64_t &Res) const =0;
240 virtual error_code getSectionSize(DataRefImpl Sec, uint64_t &Res) const = 0;
241 virtual error_code getSectionContents(DataRefImpl Sec, StringRef &Res)const=0;
242 virtual error_code getSectionAlignment(DataRefImpl Sec, uint64_t &Res)const=0;
243 virtual error_code isSectionText(DataRefImpl Sec, bool &Res) const = 0;
244 virtual error_code isSectionData(DataRefImpl Sec, bool &Res) const = 0;
245 virtual error_code isSectionBSS(DataRefImpl Sec, bool &Res) const = 0;
246 virtual error_code isSectionRequiredForExecution(DataRefImpl Sec,
247 bool &Res) const = 0;
243 virtual std::error_code getSectionName(DataRefImpl Sec,
244 StringRef &Res) const = 0;
245 virtual std::error_code getSectionAddress(DataRefImpl Sec,
246 uint64_t &Res) const = 0;
247 virtual std::error_code getSectionSize(DataRefImpl Sec,
248 uint64_t &Res) const = 0;
249 virtual std::error_code getSectionContents(DataRefImpl Sec,
250 StringRef &Res) const = 0;
251 virtual std::error_code getSectionAlignment(DataRefImpl Sec,
252 uint64_t &Res) const = 0;
253 virtual std::error_code isSectionText(DataRefImpl Sec, bool &Res) const = 0;
254 virtual std::error_code isSectionData(DataRefImpl Sec, bool &Res) const = 0;
255 virtual std::error_code isSectionBSS(DataRefImpl Sec, bool &Res) const = 0;
256 virtual std::error_code isSectionRequiredForExecution(DataRefImpl Sec,
257 bool &Res) const = 0;
248258 // A section is 'virtual' if its contents aren't present in the object image.
249 virtual error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const = 0;
250 virtual error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const = 0;
251 virtual error_code isSectionReadOnlyData(DataRefImpl Sec, bool &Res) const =0;
252 virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb,
253 bool &Result) const = 0;
259 virtual std::error_code isSectionVirtual(DataRefImpl Sec,
260 bool &Res) const = 0;
261 virtual std::error_code isSectionZeroInit(DataRefImpl Sec,
262 bool &Res) const = 0;
263 virtual std::error_code isSectionReadOnlyData(DataRefImpl Sec,
264 bool &Res) const = 0;
265 virtual std::error_code sectionContainsSymbol(DataRefImpl Sec,
266 DataRefImpl Symb,
267 bool &Result) const = 0;
254268 virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const = 0;
255269 virtual relocation_iterator section_rel_end(DataRefImpl Sec) const = 0;
256270 virtual section_iterator getRelocatedSection(DataRefImpl Sec) const;
258272 // Same as above for RelocationRef.
259273 friend class RelocationRef;
260274 virtual void moveRelocationNext(DataRefImpl &Rel) const = 0;
261 virtual error_code getRelocationAddress(DataRefImpl Rel,
262 uint64_t &Res) const =0;
263 virtual error_code getRelocationOffset(DataRefImpl Rel,
264 uint64_t &Res) const =0;
275 virtual std::error_code getRelocationAddress(DataRefImpl Rel,
276 uint64_t &Res) const = 0;
277 virtual std::error_code getRelocationOffset(DataRefImpl Rel,
278 uint64_t &Res) const = 0;
265279 virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const = 0;
266 virtual error_code getRelocationType(DataRefImpl Rel,
267 uint64_t &Res) const = 0;
268 virtual error_code getRelocationTypeName(DataRefImpl Rel,
269 SmallVectorImpl &Result) const = 0;
270 virtual error_code getRelocationValueString(DataRefImpl Rel,
271 SmallVectorImpl &Result) const = 0;
272 virtual error_code getRelocationHidden(DataRefImpl Rel, bool &Result) const {
280 virtual std::error_code getRelocationType(DataRefImpl Rel,
281 uint64_t &Res) const = 0;
282 virtual std::error_code
283 getRelocationTypeName(DataRefImpl Rel,
284 SmallVectorImpl &Result) const = 0;
285 virtual std::error_code
286 getRelocationValueString(DataRefImpl Rel,
287 SmallVectorImpl &Result) const = 0;
288 virtual std::error_code getRelocationHidden(DataRefImpl Rel,
289 bool &Result) const {
273290 Result = false;
274291 return object_error::success;
275292 }
276293
277294 // Same for LibraryRef
278295 friend class LibraryRef;
279 virtual error_code getLibraryNext(DataRefImpl Lib, LibraryRef &Res) const = 0;
280 virtual error_code getLibraryPath(DataRefImpl Lib, StringRef &Res) const = 0;
296 virtual std::error_code getLibraryNext(DataRefImpl Lib,
297 LibraryRef &Res) const = 0;
298 virtual std::error_code getLibraryPath(DataRefImpl Lib,
299 StringRef &Res) const = 0;
281300
282301 public:
283302 typedef iterator_range symbol_iterator_range;
338357 inline SymbolRef::SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner)
339358 : BasicSymbolRef(SymbolP, Owner) {}
340359
341 inline error_code SymbolRef::getName(StringRef &Result) const {
360 inline std::error_code SymbolRef::getName(StringRef &Result) const {
342361 return getObject()->getSymbolName(getRawDataRefImpl(), Result);
343362 }
344363
345 inline error_code SymbolRef::getAddress(uint64_t &Result) const {
364 inline std::error_code SymbolRef::getAddress(uint64_t &Result) const {
346365 return getObject()->getSymbolAddress(getRawDataRefImpl(), Result);
347366 }
348367
349 inline error_code SymbolRef::getAlignment(uint32_t &Result) const {
368 inline std::error_code SymbolRef::getAlignment(uint32_t &Result) const {
350369 return getObject()->getSymbolAlignment(getRawDataRefImpl(), Result);
351370 }
352371
353 inline error_code SymbolRef::getSize(uint64_t &Result) const {
372 inline std::error_code SymbolRef::getSize(uint64_t &Result) const {
354373 return getObject()->getSymbolSize(getRawDataRefImpl(), Result);
355374 }
356375
357 inline error_code SymbolRef::getSection(section_iterator &Result) const {
376 inline std::error_code SymbolRef::getSection(section_iterator &Result) const {
358377 return getObject()->getSymbolSection(getRawDataRefImpl(), Result);
359378 }
360379
361 inline error_code SymbolRef::getType(SymbolRef::Type &Result) const {
380 inline std::error_code SymbolRef::getType(SymbolRef::Type &Result) const {
362381 return getObject()->getSymbolType(getRawDataRefImpl(), Result);
363382 }
364383
390409 return OwningObject->moveSectionNext(SectionPimpl);
391410 }
392411
393 inline error_code SectionRef::getName(StringRef &Result) const {
412 inline std::error_code SectionRef::getName(StringRef &Result) const {
394413 return OwningObject->getSectionName(SectionPimpl, Result);
395414 }
396415
397 inline error_code SectionRef::getAddress(uint64_t &Result) const {
416 inline std::error_code SectionRef::getAddress(uint64_t &Result) const {
398417 return OwningObject->getSectionAddress(SectionPimpl, Result);
399418 }
400419
401 inline error_code SectionRef::getSize(uint64_t &Result) const {
420 inline std::error_code SectionRef::getSize(uint64_t &Result) const {
402421 return OwningObject->getSectionSize(SectionPimpl, Result);
403422 }
404423
405 inline error_code SectionRef::getContents(StringRef &Result) const {
424 inline std::error_code SectionRef::getContents(StringRef &Result) const {
406425 return OwningObject->getSectionContents(SectionPimpl, Result);
407426 }
408427
409 inline error_code SectionRef::getAlignment(uint64_t &Result) const {
428 inline std::error_code SectionRef::getAlignment(uint64_t &Result) const {
410429 return OwningObject->getSectionAlignment(SectionPimpl, Result);
411430 }
412431
413 inline error_code SectionRef::isText(bool &Result) const {
432 inline std::error_code SectionRef::isText(bool &Result) const {
414433 return OwningObject->isSectionText(SectionPimpl, Result);
415434 }
416435
417 inline error_code SectionRef::isData(bool &Result) const {
436 inline std::error_code SectionRef::isData(bool &Result) const {
418437 return OwningObject->isSectionData(SectionPimpl, Result);
419438 }
420439
421 inline error_code SectionRef::isBSS(bool &Result) const {
440 inline std::error_code SectionRef::isBSS(bool &Result) const {
422441 return OwningObject->isSectionBSS(SectionPimpl, Result);
423442 }
424443
425 inline error_code SectionRef::isRequiredForExecution(bool &Result) const {
444 inline std::error_code SectionRef::isRequiredForExecution(bool &Result) const {
426445 return OwningObject->isSectionRequiredForExecution(SectionPimpl, Result);
427446 }
428447
429 inline error_code SectionRef::isVirtual(bool &Result) const {
448 inline std::error_code SectionRef::isVirtual(bool &Result) const {
430449 return OwningObject->isSectionVirtual(SectionPimpl, Result);
431450 }
432451
433 inline error_code SectionRef::isZeroInit(bool &Result) const {
452 inline std::error_code SectionRef::isZeroInit(bool &Result) const {
434453 return OwningObject->isSectionZeroInit(SectionPimpl, Result);
435454 }
436455
437 inline error_code SectionRef::isReadOnlyData(bool &Result) const {
456 inline std::error_code SectionRef::isReadOnlyData(bool &Result) const {
438457 return OwningObject->isSectionReadOnlyData(SectionPimpl, Result);
439458 }
440459
441 inline error_code SectionRef::containsSymbol(SymbolRef S, bool &Result) const {
460 inline std::error_code SectionRef::containsSymbol(SymbolRef S,
461 bool &Result) const {
442462 return OwningObject->sectionContainsSymbol(SectionPimpl,
443463 S.getRawDataRefImpl(), Result);
444464 }
473493 return OwningObject->moveRelocationNext(RelocationPimpl);
474494 }
475495
476 inline error_code RelocationRef::getAddress(uint64_t &Result) const {
496 inline std::error_code RelocationRef::getAddress(uint64_t &Result) const {
477497 return OwningObject->getRelocationAddress(RelocationPimpl, Result);
478498 }
479499
480 inline error_code RelocationRef::getOffset(uint64_t &Result) const {
500 inline std::error_code RelocationRef::getOffset(uint64_t &Result) const {
481501 return OwningObject->getRelocationOffset(RelocationPimpl, Result);
482502 }
483503
485505 return OwningObject->getRelocationSymbol(RelocationPimpl);
486506 }
487507
488 inline error_code RelocationRef::getType(uint64_t &Result) const {
508 inline std::error_code RelocationRef::getType(uint64_t &Result) const {
489509 return OwningObject->getRelocationType(RelocationPimpl, Result);
490510 }
491511
492 inline error_code RelocationRef::getTypeName(SmallVectorImpl &Result)
493 const {
512 inline std::error_code
513 RelocationRef::getTypeName(SmallVectorImpl &Result) const {
494514 return OwningObject->getRelocationTypeName(RelocationPimpl, Result);
495515 }
496516
497 inline error_code RelocationRef::getValueString(SmallVectorImpl &Result)
498 const {
517 inline std::error_code
518 RelocationRef::getValueString(SmallVectorImpl &Result) const {
499519 return OwningObject->getRelocationValueString(RelocationPimpl, Result);
500520 }
501521
502 inline error_code RelocationRef::getHidden(bool &Result) const {
522 inline std::error_code RelocationRef::getHidden(bool &Result) const {
503523 return OwningObject->getRelocationHidden(RelocationPimpl, Result);
504524 }
505525
524544 return LibraryPimpl < Other.LibraryPimpl;
525545 }
526546
527 inline error_code LibraryRef::getNext(LibraryRef &Result) const {
547 inline std::error_code LibraryRef::getNext(LibraryRef &Result) const {
528548 return OwningObject->getLibraryNext(LibraryPimpl, Result);
529549 }
530550
531 inline error_code LibraryRef::getPath(StringRef &Result) const {
551 inline std::error_code LibraryRef::getPath(StringRef &Result) const {
532552 return OwningObject->getLibraryPath(LibraryPimpl, Result);
533553 }
534554
9898
9999 void moveNext();
100100
101 error_code printName(raw_ostream &OS) const;
101 std::error_code printName(raw_ostream &OS) const;
102102
103103 /// Get symbol flags (bitwise OR of SymbolRef::Flags)
104104 uint32_t getFlags() const;
119119 // virtual interface.
120120 virtual void moveSymbolNext(DataRefImpl &Symb) const = 0;
121121
122 virtual error_code printSymbolName(raw_ostream &OS,
123 DataRefImpl Symb) const = 0;
122 virtual std::error_code printSymbolName(raw_ostream &OS,
123 DataRefImpl Symb) const = 0;
124124
125125 virtual uint32_t getSymbolFlags(DataRefImpl Symb) const = 0;
126126
173173 return OwningObject->moveSymbolNext(SymbolPimpl);
174174 }
175175
176 inline error_code BasicSymbolRef::printName(raw_ostream &OS) const {
176 inline std::error_code BasicSymbolRef::printName(raw_ostream &OS) const {
177177 return OwningObject->printSymbolName(OS, SymbolPimpl);
178178 }
179179
1818 #include
1919
2020 namespace llvm {
21 using std::error_code;
2221 const std::error_category &instrprof_category();
2322
2423 enum class instrprof_error {
3736 counter_overflow
3837 };
3938
40 inline error_code make_error_code(instrprof_error E) {
41 return error_code(static_cast(E), instrprof_category());
39 inline std::error_code make_error_code(instrprof_error E) {
40 return std::error_code(static_cast(E), instrprof_category());
4241 }
4342
4443 } // end namespace llvm
5959 /// Base class and interface for reading profiling data of any known instrprof
6060 /// format. Provides an iterator over InstrProfRecords.
6161 class InstrProfReader {
62 error_code LastError;
62 std::error_code LastError;
63
6364 public:
6465 InstrProfReader() : LastError(instrprof_error::success) {}
6566 virtual ~InstrProfReader() {}
6667
6768 /// Read the header. Required before reading first record.
68 virtual error_code readHeader() = 0;
69 virtual std::error_code readHeader() = 0;
6970 /// Read a single record.
70 virtual error_code readNextRecord(InstrProfRecord &Record) = 0;
71 virtual std::error_code readNextRecord(InstrProfRecord &Record) = 0;
7172 /// Iterator over profile data.
7273 InstrProfIterator begin() { return InstrProfIterator(this); }
7374 InstrProfIterator end() { return InstrProfIterator(); }
7475
7576 protected:
76 /// Set the current error_code and return same.
77 error_code error(error_code EC) {
77 /// Set the current std::error_code and return same.
78 std::error_code error(std::error_code EC) {
7879 LastError = EC;
7980 return EC;
8081 }
8182
8283 /// Clear the current error code and return a successful one.
83 error_code success() { return error(instrprof_error::success); }
84 std::error_code success() { return error(instrprof_error::success); }
8485
8586 public:
8687 /// Return true if the reader has finished reading the profile data.
8889 /// Return true if the reader encountered an error reading profiling data.
8990 bool hasError() { return LastError && !isEOF(); }
9091 /// Get the current error code.
91 error_code getError() { return LastError; }
92 std::error_code getError() { return LastError; }
9293
9394 /// Factory method to create an appropriately typed reader for the given
9495 /// instrprof file.
95 static error_code create(std::string Path,
96 std::unique_ptr &Result);
96 static std::error_code create(std::string Path,
97 std::unique_ptr &Result);
9798 };
9899
99100 /// Reader for the simple text based instrprof format.
121122 : DataBuffer(std::move(DataBuffer_)), Line(*DataBuffer, '#') {}
122123
123124 /// Read the header.
124 error_code readHeader() override { return success(); }
125 std::error_code readHeader() override { return success(); }
125126 /// Read a single record.
126 error_code readNextRecord(InstrProfRecord &Record) override;
127 std::error_code readNextRecord(InstrProfRecord &Record) override;
127128 };
128129
129130 /// Reader for the raw instrprof binary format from runtime.
174175 : DataBuffer(std::move(DataBuffer)) { }
175176
176177 static bool hasFormat(const MemoryBuffer &DataBuffer);
177 error_code readHeader() override;
178 error_code readNextRecord(InstrProfRecord &Record) override;
178 std::error_code readHeader() override;
179 std::error_code readNextRecord(InstrProfRecord &Record) override;
179180
180181 private:
181 error_code readNextHeader(const char *CurrentPos);
182 error_code readHeader(const RawHeader &Header);
182 std::error_code readNextHeader(const char *CurrentPos);
183 std::error_code readHeader(const RawHeader &Header);
183184 template
184185 IntT swap(IntT Int) const {
185186 return ShouldSwapBytes ? sys::SwapByteOrder(Int) : Int;
280281 static bool hasFormat(const MemoryBuffer &DataBuffer);
281282
282283 /// Read the file header.
283 error_code readHeader() override;
284 std::error_code readHeader() override;
284285 /// Read a single record.
285 error_code readNextRecord(InstrProfRecord &Record) override;
286 std::error_code readNextRecord(InstrProfRecord &Record) override;
286287
287288 /// Fill Counts with the profile data for the given function name.
288 error_code getFunctionCounts(StringRef FuncName, uint64_t &FuncHash,
289 std::vector &Counts);
289 std::error_code getFunctionCounts(StringRef FuncName, uint64_t &FuncHash,
290 std::vector &Counts);
290291 /// Return the maximum of all known function counts.
291292 uint64_t getMaximumFunctionCount() { return MaxFunctionCount; }
292293
293294 /// Factory method to create an indexed reader.
294 static error_code create(std::string Path,
295 std::unique_ptr &Result);
295 static std::error_code
296 create(std::string Path, std::unique_ptr &Result);
296297 };
297298
298299 } // end namespace llvm
3737 /// Add function counts for the given function. If there are already counts
3838 /// for this function and the hash and number of counts match, each counter is
3939 /// summed.
40 error_code addFunctionCounts(StringRef FunctionName, uint64_t FunctionHash,
41 ArrayRef Counters);
40 std::error_code addFunctionCounts(StringRef FunctionName,
41 uint64_t FunctionHash,
42 ArrayRef Counters);
4243 /// Ensure that all data is written to disk.
4344 void write(raw_fd_ostream &OS);
4445 };
2222 #include
2323
2424 namespace llvm {
25 using std::error_code;
2625 template
2726 typename std::enable_if< std::is_constructible::value
2827 , typename std::remove_reference::type>::type &&
10099 void *>::type = 0)
101100 : HasError(true) {
102101 using std::make_error_code;
103 new (getErrorStorage()) error_code(make_error_code(ErrorCode));
102 new (getErrorStorage()) std::error_code(make_error_code(ErrorCode));
104103 }
105104
106105 ErrorOr(std::error_code EC) : HasError(true) {
107 new (getErrorStorage()) error_code(EC);
106 new (getErrorStorage()) std::error_code(EC);
108107 }
109108
110109 ErrorOr(T Val) : HasError(false) {
164163 reference get() { return *getStorage(); }
165164 const_reference get() const { return const_cast >(this)->get(); }
166165
167 error_code getError() const {
168 return HasError ? *getErrorStorage() : error_code();
166 std::error_code getError() const {
167 return HasError ? *getErrorStorage() : std::error_code();
169168 }
170169
171170 pointer operator ->() {
186185 } else {
187186 // Get other's error.
188187 HasError = true;
189 new (getErrorStorage()) error_code(Other.getError());
188 new (getErrorStorage()) std::error_code(Other.getError());
190189 }
191190 }
192191
218217 } else {
219218 // Get other's error.
220219 HasError = true;
221 new (getErrorStorage()) error_code(Other.getError());
220 new (getErrorStorage()) std::error_code(Other.getError());
222221 }
223222 }
224223
249248 return reinterpret_cast(TStorage.buffer);
250249 }
251250
252 error_code *getErrorStorage() {
251 std::error_code *getErrorStorage() {
253252 assert(HasError && "Cannot get error when a value exists!");
254 return reinterpret_cast(ErrorStorage.buffer);
255 }
256
257 const error_code *getErrorStorage() const {
253 return reinterpret_cast(ErrorStorage.buffer);
254 }
255
256 const std::error_code *getErrorStorage() const {
258257 return const_cast *>(this)->getErrorStorage();
259258 }
260259
261260
262261 union {
263262 AlignedCharArrayUnion TStorage;
264 AlignedCharArrayUnion<error_code> ErrorStorage;
263 AlignedCharArrayUnion<std::error_code> ErrorStorage;
265264 };
266265 bool HasError : 1;
267266 };
271270 std::is_error_condition_enum::value,
272271 bool>::type
273272 operator==(ErrorOr &Err, E Code) {
274 return error_code(Err) == Code;
273 return std::error_code(Err) == Code;
275274 }
276275 } // end namespace llvm
277276
3636 /// Factory method to create an OutputBuffer object which manages a read/write
3737 /// buffer of the specified size. When committed, the buffer will be written
3838 /// to the file at the specified path.
39 static error_code create(StringRef FilePath, size_t Size,
40 std::unique_ptr &Result,
41 unsigned Flags = 0);
39 static std::error_code create(StringRef FilePath, size_t Size,
40 std::unique_ptr &Result,
41 unsigned Flags = 0);
4242
4343 /// Returns a pointer to the start of the buffer.
4444 uint8_t *getBufferStart() {
6565 /// is called, the file is deleted in the destructor. The optional parameter
6666 /// is used if it turns out you want the file size to be smaller than
6767 /// initially requested.
68 error_code commit(int64_t NewSmallerSize = -1);
68 std::error_code commit(int64_t NewSmallerSize = -1);
6969
7070 /// If this object was previously committed, the destructor just deletes
7171 /// this object. If this object was not committed, the destructor
4545 #endif
4646
4747 namespace llvm {
48 using std::error_code;
4948 namespace sys {
5049 namespace fs {
5150
274273 /// @param path A path that is modified to be an absolute path.
275274 /// @returns errc::success if \a path has been made absolute, otherwise a
276275 /// platform specific error_code.
277 error_code make_absolute(SmallVectorImpl &path);
276 std::error_code make_absolute(SmallVectorImpl &path);
278277
279278 /// @brief Normalize path separators in \a Path
280279 ///
282281 /// This is particularly useful when cross-compiling Windows on Linux, but is
283282 /// safe to invoke on Windows, which accepts both characters as a path
284283 /// separator.
285 error_code normalize_separators(SmallVectorImpl &Path);
284 std::error_code normalize_separators(SmallVectorImpl &Path);
286285
287286 /// @brief Create all the non-existent directories in path.
288287 ///
290289 /// @returns errc::success if is_directory(path), otherwise a platform
291290 /// specific error_code. If IgnoreExisting is false, also returns
292291 /// error if the directory already existed.
293 error_code create_directories(const Twine &path, bool IgnoreExisting = true);
292 std::error_code create_directories(const Twine &path,
293 bool IgnoreExisting = true);
294294
295295 /// @brief Create the directory in path.
296296 ///
298298 /// @returns errc::success if is_directory(path), otherwise a platform
299299 /// specific error_code. If IgnoreExisting is false, also returns
300300 /// error if the directory already existed.
301 error_code create_directory(const Twine &path, bool IgnoreExisting = true);
301 std::error_code create_directory(const Twine &path, bool IgnoreExisting = true);
302302
303303 /// @brief Create a link from \a from to \a to.
304304 ///
311311 /// @param from The path to hard link from. This is created.
312312 /// @returns errc::success if the link was created, otherwise a platform
313313 /// specific error_code.
314 error_code create_link(const Twine &to, const Twine &from);
314 std::error_code create_link(const Twine &to, const Twine &from);
315315
316316 /// @brief Get the current path.
317317 ///
318318 /// @param result Holds the current path on return.
319319 /// @returns errc::success if the current path has been stored in result,
320320 /// otherwise a platform specific error_code.
321 error_code current_path(SmallVectorImpl &result);
321 std::error_code current_path(SmallVectorImpl &result);
322322
323323 /// @brief Remove path. Equivalent to POSIX remove().
324324 ///
326326 /// @returns errc::success if path has been removed or didn't exist, otherwise a
327327 /// platform specific error code. If IgnoreNonExisting is false, also
328328 /// returns error if the file didn't exist.
329 error_code remove(const Twine &path, bool IgnoreNonExisting = true);
329 std::error_code remove(const Twine &path, bool IgnoreNonExisting = true);
330330
331331 /// @brief Rename \a from to \a to. Files are renamed as if by POSIX rename().
332332 ///
333333 /// @param from The path to rename from.
334334 /// @param to The path to rename to. This is created.
335 error_code rename(const Twine &from, const Twine &to);
335 std::error_code rename(const Twine &from, const Twine &to);
336336
337337 /// @brief Resize path to size. File is resized as if by POSIX truncate().
338338 ///
340340 /// @param size Size to resize to.
341341 /// @returns errc::success if \a path has been resized to \a size, otherwise a
342342 /// platform specific error_code.
343 error_code resize_file(const Twine &path, uint64_t size);
343 std::error_code resize_file(const Twine &path, uint64_t size);
344344
345345 /// @}
346346 /// @name Physical Observers
360360 /// it does not. Undefined otherwise.
361361 /// @returns errc::success if result has been successfully set, otherwise a
362362 /// platform specific error_code.
363 error_code exists(const Twine &path, bool &result);
363 std::error_code exists(const Twine &path, bool &result);
364364
365365 /// @brief Simpler version of exists for clients that don't need to
366366 /// differentiate between an error and false.
402402 /// inode (or equivalent).
403403 /// @returns errc::success if result has been successfully set, otherwise a
404404 /// platform specific error_code.
405 error_code equivalent(const Twine &A, const Twine &B, bool &result);
405 std::error_code equivalent(const Twine &A, const Twine &B, bool &result);
406406
407407 /// @brief Simpler version of equivalent for clients that don't need to
408408 /// differentiate between an error and false.
424424 /// Undefined otherwise.
425425 /// @returns errc::success if result has been successfully set, otherwise a
426426 /// platform specific error_code.
427 error_code is_directory(const Twine &path, bool &result);
427 std::error_code is_directory(const Twine &path, bool &result);
428428
429429 /// @brief Simpler version of is_directory for clients that don't need to
430430 /// differentiate between an error and false.
446446 /// Undefined otherwise.
447447 /// @returns errc::success if result has been successfully set, otherwise a
448448 /// platform specific error_code.
449 error_code is_regular_file(const Twine &path, bool &result);
449 std::error_code is_regular_file(const Twine &path, bool &result);
450450
451451 /// @brief Simpler version of is_regular_file for clients that don't need to
452452 /// differentiate between an error and false.
472472 /// file, or a symlink, false if it does not. Undefined otherwise.
473473 /// @returns errc::success if result has been successfully set, otherwise a
474474 /// platform specific error_code.
475 error_code is_other(const Twine &path, bool &result);
475 std::error_code is_other(const Twine &path, bool &result);
476476
477477 /// @brief Get file status as if by POSIX stat().
478478 ///
480480 /// @param result Set to the file status.
481481 /// @returns errc::success if result has been successfully set, otherwise a
482482 /// platform specific error_code.
483 error_code status(const Twine &path, file_status &result);
483 std::error_code status(const Twine &path, file_status &result);
484484
485485 /// @brief A version for when a file descriptor is already available.
486 error_code status(int FD, file_status &Result);
486 std::error_code status(int FD, file_status &Result);
487487
488488 /// @brief Get file size.
489489 ///
491491 /// @param Result Set to the size of the file in \a Path.
492492 /// @returns errc::success if result has been successfully set, otherwise a
493493 /// platform specific error_code.
494 inline error_code file_size(const Twine &Path, uint64_t &Result) {
494 inline std::error_code file_size(const Twine &Path, uint64_t &Result) {
495495 file_status Status;
496 error_code EC = status(Path, Status);
496 std::error_code EC = status(Path, Status);
497497 if (EC)
498498 return EC;
499499 Result = Status.getSize();
500 return error_code();
500 return std::error_code();
501501 }
502502
503503 /// @brief Set the file modification and access time.
505505 /// @returns errc::success if the file times were successfully set, otherwise a
506506 /// platform specific error_code or errc::not_supported on platforms
507507 /// where the functionality isn't available.
508 error_code setLastModificationAndAccessTime(int FD, TimeValue Time);
508 std::error_code setLastModificationAndAccessTime(int FD, TimeValue Time);
509509
510510 /// @brief Is status available?
511511 ///
519519 /// @param result Set to true if status() != status_error.
520520 /// @returns errc::success if result has been successfully set, otherwise a
521521 /// platform specific error_code.
522 error_code status_known(const Twine &path, bool &result);
522 std::error_code status_known(const Twine &path, bool &result);
523523
524524 /// @brief Create a uniquely named file.
525525 ///
542542 /// @param ResultPath Set to the opened file's absolute path.
543543 /// @returns errc::success if Result{FD,Path} have been successfully set,
544544 /// otherwise a platform specific error_code.
545 error_code createUniqueFile(const Twine &Model, int &ResultFD,
546 SmallVectorImpl &ResultPath,
547 unsigned Mode = all_read | all_write);
545 std::error_code createUniqueFile(const Twine &Model, int &ResultFD,
546 SmallVectorImpl &ResultPath,
547 unsigned Mode = all_read | all_write);
548548
549549 /// @brief Simpler version for clients that don't want an open file.
550 error_code createUniqueFile(const Twine &Model,
551 SmallVectorImpl &ResultPath);
550 std::error_code createUniqueFile(const Twine &Model,
551 SmallVectorImpl &ResultPath);
552552
553553 /// @brief Create a file in the system temporary directory.
554554 ///
558558 ///
559559 /// This should be used for things like a temporary .s that is removed after
560560 /// running the assembler.
561 error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix,
562 int &ResultFD,
563 SmallVectorImpl &ResultPath);
561 std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix,
562 int &ResultFD,
563 SmallVectorImpl &ResultPath);
564564
565565 /// @brief Simpler version for clients that don't want an open file.
566 error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix,
567 SmallVectorImpl &ResultPath);
568
569 error_code createUniqueDirectory(const Twine &Prefix,
570 SmallVectorImpl &ResultPath);
566 std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix,
567 SmallVectorImpl &ResultPath);
568
569 std::error_code createUniqueDirectory(const Twine &Prefix,
570 SmallVectorImpl &ResultPath);
571571
572572 enum OpenFlags : unsigned {
573573 F_None = 0,
598598 return A;
599599 }
600600
601 error_code openFileForWrite(const Twine &Name, int &ResultFD, OpenFlags Flags,
602 unsigned Mode = 0666);
603
604 error_code openFileForRead(const Twine &Name, int &ResultFD);
601 std::error_code openFileForWrite(const Twine &Name, int &ResultFD,
602 OpenFlags Flags, unsigned Mode = 0666);
603
604 std::error_code openFileForRead(const Twine &Name, int &ResultFD);
605605
606606 /// @brief Identify the type of a binary file based on how magical it is.
607607 file_magic identify_magic(StringRef magic);
612612 /// @param result Set to the type of file, or file_magic::unknown.
613613 /// @returns errc::success if result has been successfully set, otherwise a
614614 /// platform specific error_code.
615 error_code identify_magic(const Twine &path, file_magic &result);
616
617 error_code getUniqueID(const Twine Path, UniqueID &Result);
615 std::error_code identify_magic(const Twine &path, file_magic &result);
616
617 std::error_code getUniqueID(const Twine Path, UniqueID &Result);
618618
619619 /// This class represents a memory mapped file. It is based on
620620 /// boost::iostreams::mapped_file.
641641 void *FileMappingHandle;
642642 #endif
643643
644 error_code init(int FD, bool CloseFD, uint64_t Offset);
644 std::error_code init(int FD, bool CloseFD, uint64_t Offset);
645645
646646 public:
647647 typedef char char_type;
663663 /// mapped_file_region::alignment().
664664 /// \param ec This is set to errc::success if the map was constructed
665665 /// successfully. Otherwise it is set to a platform dependent error.
666 mapped_file_region(const Twine &path,
667 mapmode mode,
668 uint64_t length,
669 uint64_t offset,
670 error_code &ec);
666 mapped_file_region(const Twine &path, mapmode mode, uint64_t length,
667 uint64_t offset, std::error_code &ec);
671668
672669 /// \param fd An open file descriptor to map. mapped_file_region takes
673670 /// ownership if closefd is true. It must have been opended in the correct
674671 /// mode.
675 mapped_file_region(int fd,
676 bool closefd,
677 mapmode mode,
678 uint64_t length,
679 uint64_t offset,
680 error_code &ec);
672 mapped_file_region(int fd, bool closefd, mapmode mode, uint64_t length,
673 uint64_t offset, std::error_code &ec);
681674
682675 ~mapped_file_region();
683676
724717 void replace_filename(const Twine &filename, file_status st = file_status());
725718
726719 const std::string &path() const { return Path; }
727 error_code status(file_status &result) const;
720 std::error_code status(file_status &result) const;
728721
729722 bool operator==(const directory_entry& rhs) const { return Path == rhs.Path; }
730723 bool operator!=(const directory_entry& rhs) const { return !(*this == rhs); }
737730 namespace detail {
738731 struct DirIterState;
739732
740 error_code directory_iterator_construct(DirIterState&, StringRef);
741 error_code directory_iterator_increment(DirIterState&);
742 error_code directory_iterator_destruct(DirIterState&);
733 std::error_code directory_iterator_construct(DirIterState &, StringRef);
734 std::error_code directory_iterator_increment(DirIterState &);
735 std::error_code directory_iterator_destruct(DirIterState &);
743736
744737 /// DirIterState - Keeps state for the directory_iterator. It is reference
745738 /// counted in order to preserve InputIterator semantics on copy.
763756 IntrusiveRefCntPtr State;
764757
765758 public:
766 explicit directory_iterator(const Twine &path, error_code &ec) {
759 explicit directory_iterator(const Twine &path, std::error_code &ec) {
767760 State = new detail::DirIterState;
768761 SmallString<128> path_storage;
769762 ec = detail::directory_iterator_construct(*State,
770763 path.toStringRef(path_storage));
771764 }
772765
773 explicit directory_iterator(const directory_entry &de, error_code &ec) {
766 explicit directory_iterator(const directory_entry &de, std::error_code &ec) {
774767 State = new detail::DirIterState;
775768 ec = detail::directory_iterator_construct(*State, de.path());
776769 }
779772 directory_iterator() : State(nullptr) {}
780773
781774 // No operator++ because we need error_code.
782 directory_iterator &increment(error_code &ec) {
775 directory_iterator &increment(std::error_code &ec) {
783776 ec = directory_iterator_increment(*State);
784777 return *this;
785778 }
825818
826819 public:
827820 recursive_directory_iterator() {}
828 explicit recursive_directory_iterator(const Twine &path, error_code &ec)
829 : State(new detail::RecDirIterState) {
821 explicit recursive_directory_iterator(const Twine &path, std::error_code &ec)
822 : State(new detail::RecDirIterState) {
830823 State->Stack.push(directory_iterator(path, ec));
831824 if (State->Stack.top() == directory_iterator())
832825 State.reset();
833826 }
834827 // No operator++ because we need error_code.
835 recursive_directory_iterator &increment(error_code &ec) {
828 recursive_directory_iterator &increment(std::error_code &ec) {
836829 const directory_iterator end_itr;
837830
838831 if (State->HasNoPushRequest)
881874 assert(State->Level > 0 && "Cannot pop an iterator with level < 1");
882875
883876 const directory_iterator end_itr;
884 error_code ec;
877 std::error_code ec;
885878 do {
886879 if (ec)
887880 report_fatal_error("Error incrementing directory iterator.");
1515 #include // for std::pair
1616
1717 namespace llvm {
18 using std::error_code;
1918 /// \brief Class that manages the creation of a lock file to aid
2019 /// implicit coordination between different processes.
2120 ///
5554 SmallString<128> UniqueLockFileName;
5655
5756 Optional > Owner;
58 Optional<error_code> Error;
57 Optional<std::error_code> Error;
5958
6059 LockFileManager(const LockFileManager &) LLVM_DELETED_FUNCTION;
6160 LockFileManager &operator=(const LockFileManager &) LLVM_DELETED_FUNCTION;
1818 #include
1919
2020 namespace llvm {
21 using std::error_code;
2221 namespace sys {
2322
2423 /// This class encapsulates the notion of a memory block which has an address
7776 static MemoryBlock allocateMappedMemory(size_t NumBytes,
7877 const MemoryBlock *const NearBlock,
7978 unsigned Flags,
80 error_code &EC);
79 std::error_code &EC);
8180
8281 /// This method releases a block of memory that was allocated with the
8382 /// allocateMappedMemory method. It should not be used to release any
8887 /// describing the failure if an error occurred.
8988 ///
9089 /// @brief Release mapped memory.
91 static error_code releaseMappedMemory(MemoryBlock &Block);
90 static std::error_code releaseMappedMemory(MemoryBlock &Block);
9291
9392 /// This method sets the protection flags for a block of memory to the
9493 /// state specified by /p Flags. The behavior is not specified if the
105104 /// describing the failure if an error occurred.
106105 ///
107106 /// @brief Set memory protection state.
108 static error_code protectMappedMemory(const MemoryBlock &Block,
109 unsigned Flags);
107 static std::error_code protectMappedMemory(const MemoryBlock &Block,
108 unsigned Flags);
110109
111110 /// This method allocates a block of Read/Write/Execute memory that is
112111 /// suitable for executing dynamically generated code (e.g. JIT). An
2222 #include
2323
2424 namespace llvm {
25 using std::error_code;
2625 /// MemoryBuffer - This interface provides simple read-only access to a block
2726 /// of memory, and provides simple methods for reading files and standard input
2827 /// into a memory buffer. In addition to basic access to the characters in the
6867 /// \param IsVolatileSize Set to true to indicate that the file size may be
6968 /// changing, e.g. when libclang tries to parse while the user is
7069 /// editing/updating the file.
71 static error_code getFile(Twine Filename,
72 std::unique_ptr &Result,
73 int64_t FileSize = -1,
74 bool RequiresNullTerminator = true,
75 bool IsVolatileSize = false);
70 static std::error_code getFile(Twine Filename,
71 std::unique_ptr &Result,
72 int64_t FileSize = -1,
73 bool RequiresNullTerminator = true,
74 bool IsVolatileSize = false);
7675
7776 /// Given an already-open file descriptor, map some slice of it into a
7877 /// MemoryBuffer. The slice is specified by an \p Offset and \p MapSize.
8180 /// \param IsVolatileSize Set to true to indicate that the file size may be
8281 /// changing, e.g. when libclang tries to parse while the user is
8382 /// editing/updating the file.
84 static error_code getOpenFileSlice(int FD, const char *Filename,
85 std::unique_ptr &Result,
86 uint64_t MapSize, int64_t Offset,
87 bool IsVolatileSize = false);
83 static std::error_code getOpenFileSlice(int FD, const char *Filename,
84 std::unique_ptr &Result,
85 uint64_t MapSize, int64_t Offset,
86 bool IsVolatileSize = false);
8887
8988 /// Given an already-open file descriptor, read the file and return a
9089 /// MemoryBuffer.
9291 /// \param IsVolatileSize Set to true to indicate that the file size may be
9392 /// changing, e.g. when libclang tries to parse while the user is
9493 /// editing/updating the file.
95 static error_code getOpenFile(int FD, const char *Filename,
96 std::unique_ptr &Result,
97 uint64_t FileSize,
98 bool RequiresNullTerminator = true,
99 bool IsVolatileSize = false);
94 static std::error_code getOpenFile(int FD, const char *Filename,
95 std::unique_ptr &Result,
96 uint64_t FileSize,
97 bool RequiresNullTerminator = true,
98 bool IsVolatileSize = false);
10099
101100 /// getMemBuffer - Open the specified memory range as a MemoryBuffer. Note
102101 /// that InputData must be null terminated if RequiresNullTerminator is true.
125124
126125 /// getSTDIN - Read all of stdin into a file buffer, and return it.
127126 /// If an error occurs, this returns null and sets ec.
128 static error_code getSTDIN(std::unique_ptr &Result);
129
127 static std::error_code getSTDIN(std::unique_ptr &Result);
130128
131129 /// getFileOrSTDIN - Open the specified file as a MemoryBuffer, or open stdin
132130 /// if the Filename is "-". If an error occurs, this returns null and sets
133131 /// ec.
134 static error_code getFileOrSTDIN(StringRef Filename,
135 std::unique_ptr &Result,
136 int64_t FileSize = -1);
132 static std::error_code getFileOrSTDIN(StringRef Filename,
133 std::unique_ptr &Result,
134 int64_t FileSize = -1);
137135
138136 //===--------------------------------------------------------------------===//
139137 // Provided for performance analysis.
173173 /// This function returns a SmallVector containing the arguments passed from
174174 /// the operating system to the program. This function expects to be handed
175175 /// the vector passed in from main.
176 static error_code
176 static std::error_code
177177 GetArgumentVector(SmallVectorImpl &Args,
178178 ArrayRef ArgsFromMain,
179179 SpecificBumpPtrAllocator &ArgAllocator);
1818 #include
1919
2020 namespace llvm {
21 using std::error_code;
2221 namespace sys {
2322
2423 /// This is the OS-specific separator for PATH like environment variables:
6665 // These functions change the specified standard stream (stdin or stdout) to
6766 // binary mode. They return errc::success if the specified stream
6867 // was changed. Otherwise a platform dependent error is returned.
69 error_code ChangeStdinToBinary();
70 error_code ChangeStdoutToBinary();
68 std::error_code ChangeStdinToBinary();
69 std::error_code ChangeStdoutToBinary();
7170
7271 /// This function executes the program using the arguments provided. The
7372 /// invoked program will inherit the stdin, stdout, and stderr file
1919 #include
2020 #include
2121 using namespace llvm;
22 using std::error_code;
2223
2324 Module *llvm::ParseAssembly(MemoryBuffer *F,
2425 Module *M,
1515 #include
1616
1717 using namespace llvm;
18 using std::error_code;
1819
1920 /* Builds a module from the bitcode in the specified memory buffer, returning a
2021 reference to the module via the OutModule parameter. Returns 0 on success.
2525 #include
2626
2727 namespace llvm {
28 using std::error_code;
2829 class MemoryBuffer;
2930 class LLVMContext;
3031
2020 using namespace llvm;
2121 using namespace dwarf;
2222 using namespace object;
23 using std::error_code;
2324
2425 #define DEBUG_TYPE "dwarf"
2526
1818 #include "llvm/IR/Module.h"
1919 #include
2020 using namespace llvm;
21 using std::error_code;
2122
2223 namespace {
2324
7070 //
7171 // FIXME: Initialize the Near member for each memory group to avoid
7272 // interleaving.
73 error_code ec;
73 std::error_code ec;
7474 sys::MemoryBlock MB = sys::Memory::allocateMappedMemory(RequiredSize,
7575 &MemGroup.Near,
7676 sys::Memory::MF_READ |
104104 bool SectionMemoryManager::finalizeMemory(std::string *ErrMsg)
105105 {
106106 // FIXME: Should in-progress permissions be reverted if an error occurs?
107 error_code ec;
107 std::error_code ec;
108108
109109 // Don't allow free memory blocks to be used after setting protection flags.
110110 CodeMem.FreeMem.clear();
142142 return false;
143143 }
144144
145 error_code SectionMemoryManager::applyMemoryGroupPermissions(MemoryGroup &MemGroup,
146 unsigned Permissions) {
145 std::error_code
146 SectionMemoryManager::applyMemoryGroupPermissions(MemoryGroup &MemGroup,
147 unsigned Permissions) {
147148
148149 for (int i = 0, e = MemGroup.AllocatedMem.size(); i != e; ++i) {
149 error_code ec;
150 ec = sys::Memory::protectMappedMemory(MemGroup.AllocatedMem[i],
151 Permissions);
152 if (ec) {
153 return ec;
154 }
150 std::error_code ec;
151 ec =
152 sys::Memory::protectMappedMemory(MemGroup.AllocatedMem[i], Permissions);
153 if (ec) {
154 return ec;
155 }
155156 }
156157
157 return error_code();
158 return std::error_code();
158159 }
159160
160161 void SectionMemoryManager::invalidateInstructionCache() {
1919 using namespace llvm;
2020
2121 namespace llvm {
22 using std::error_code;
2223
2324 namespace {
2425 // Helper for extensive error checking in debug builds.
4040 #include
4141
4242 using namespace llvm;
43 using std::error_code;
4344
4445 #define DEBUG_TYPE "ir"
4546
2121 #include
2222 #include
2323 using namespace llvm;
24 using std::error_code;
2425
2526 //===----------------------------------------------------------------------===//
2627 // GCOVFile implementation.
2727 #include
2828 #include
2929 using namespace llvm;
30 using std::error_code;
3031
3132 //===----------------------------------------------------------------------===//
3233 // Methods to implement the globals and functions lists.
2020 #include
2121
2222 using namespace llvm;
23 using std::error_code;
2324
2425 namespace llvm {
2526 extern bool TimePassesIsEnabled;
5252 #include "llvm/Transforms/ObjCARC.h"
5353 #include
5454 using namespace llvm;
55 using std::error_code;
5556
5657 const char* LTOCodeGenerator::getVersionString() {
5758 #ifdef LLVM_VERSION_INFO
4242 #include "llvm/Transforms/Utils/GlobalStatus.h"
4343 #include
4444 using namespace llvm;
45 using std::error_code;
4546
4647 LTOModule::LTOModule(llvm::Module *m, llvm::TargetMachine *t)
4748 : _module(m), _target(t),
2727 #include
2828
2929 using namespace llvm;
30 using std::error_code;
3031
3132 MCContext::MCContext(const MCAsmInfo *mai, const MCRegisterInfo *mri,
3233 const MCObjectFileInfo *mofi, const SourceMgr *mgr,
2424 #include
2525
2626 namespace llvm {
27 using std::error_code;
2728
2829 namespace {
2930
1919
2020 using namespace llvm;
2121 using namespace object;
22 using std::error_code;
2223
2324 static const char *const Magic = "!\n";
2425
8080
8181 ErrorOr object::createBinary(StringRef Path) {
8282 std::unique_ptr File;
83 if (error_code EC = MemoryBuffer::getFileOrSTDIN(Path, File))
83 if (std::error_code EC = MemoryBuffer::getFileOrSTDIN(Path, File))
8484 return EC;
8585 return createBinary(File.release());
8686 }
2323
2424 using namespace llvm;
2525 using namespace object;
26 using std::error_code;
2627
2728 using support::ulittle8_t;
2829 using support::ulittle16_t;
1414 #include "llvm/Support/MathExtras.h"
1515
1616 namespace llvm {
17 using std::error_code;
1718 using namespace object;
1819
1920 ErrorOr ObjectFile::createELFObjectFile(MemoryBuffer *Obj,
1818 #include "llvm/Support/raw_ostream.h"
1919 using namespace llvm;
2020 using namespace object;
21 using std::error_code;
2122
2223 IRObjectFile::IRObjectFile(MemoryBuffer *Object, error_code &EC,
2324 LLVMContext &Context, bool BufferOwned)
2727 using namespace object;
2828
2929 namespace llvm {
30 using std::error_code;
31
3032 namespace object {
3133
3234 struct nlist_base {
315317 uint32_t Val = O->getPlainRelocationSymbolNum(RE);
316318
317319 for (const SymbolRef &Symbol : O->symbols()) {
318 error_code ec;
320 std::error_code ec;
319321 uint64_t Addr;
320322 StringRef Name;
321323
332334 // If we couldn't find a symbol that this relocation refers to, try
333335 // to find a section beginning instead.
334336 for (const SectionRef &Section : O->sections()) {
335 error_code ec;
337 std::error_code ec;
336338 uint64_t Addr;
337339 StringRef Name;
338340
426428 }
427429
428430 MachOObjectFile::MachOObjectFile(MemoryBuffer *Object, bool IsLittleEndian,
429 bool Is64bits, error_code &EC,
431 bool Is64bits, std::error_code &EC,
430432 bool BufferOwned)
431433 : ObjectFile(getMachOType(IsLittleEndian, Is64bits), Object, BufferOwned),
432434 SymtabLoadCmd(nullptr), DysymtabLoadCmd(nullptr),
474476 Symb.p += SymbolTableEntrySize;
475477 }
476478
477 error_code MachOObjectFile::getSymbolName(DataRefImpl Symb,
478 StringRef &Res) const {
479 std::error_code MachOObjectFile::getSymbolName(DataRefImpl Symb,
480 StringRef &Res) const {
479481 StringRef StringTable = getStringTableData();
480482 nlist_base Entry = getSymbolTableEntryBase(this, Symb);
481483 const char *Start = &StringTable.data()[Entry.n_strx];
485487
486488 // getIndirectName() returns the name of the alias'ed symbol who's string table
487489 // index is in the n_value field.
488 error_code MachOObjectFile::getIndirectName(DataRefImpl Symb,
489 StringRef &Res) const {
490 std::error_code MachOObjectFile::getIndirectName(DataRefImpl Symb,
491 StringRef &Res) const {
490492 StringRef StringTable = getStringTableData();
491493 uint64_t NValue;
492494 if (is64Bit()) {
507509 return object_error::success;
508510 }
509511
510 error_code MachOObjectFile::getSymbolAddress(DataRefImpl Symb,
511 uint64_t &Res) const {
512 std::error_code MachOObjectFile::getSymbolAddress(DataRefImpl Symb,
513 uint64_t &Res) const {
512514 if (is64Bit()) {
513515 MachO::nlist_64 Entry = getSymbol64TableEntry(Symb);
514516 if ((Entry.n_type & MachO::N_TYPE) == MachO::N_UNDF &&
527529 return object_error::success;
528530 }
529531
530 error_code MachOObjectFile::getSymbolAlignment(DataRefImpl DRI,
531 uint32_t &Result) const {
532 std::error_code MachOObjectFile::getSymbolAlignment(DataRefImpl DRI,
533 uint32_t &Result) const {
532534 uint32_t flags = getSymbolFlags(DRI);
533535 if (flags & SymbolRef::SF_Common) {
534536 nlist_base Entry = getSymbolTableEntryBase(this, DRI);
539541 return object_error::success;
540542 }
541543
542 error_code MachOObjectFile::getSymbolSize(DataRefImpl DRI,
543 uint64_t &Result) const {
544 std::error_code MachOObjectFile::getSymbolSize(DataRefImpl DRI,
545 uint64_t &Result) const {
544546 uint64_t BeginOffset;
545547 uint64_t EndOffset = 0;
546548 uint8_t SectionIndex;
588590 return object_error::success;
589591 }
590592
591 error_code MachOObjectFile::getSymbolType(DataRefImpl Symb,
592 SymbolRef::Type &Res) const {
593 std::error_code MachOObjectFile::getSymbolType(DataRefImpl Symb,
594 SymbolRef::Type &Res) const {
593595 nlist_base Entry = getSymbolTableEntryBase(this, Symb);
594596 uint8_t n_type = Entry.n_type;
595597
648650 return Result;
649651 }
650652
651 error_code
652 MachOObjectFile::getSymbolSection(DataRefImpl Symb,
653 section_iterator &Res) const {
653 std::error_code MachOObjectFile::getSymbolSection(DataRefImpl Symb,
654 section_iterator &Res) const {
654655 nlist_base Entry = getSymbolTableEntryBase(this, Symb);
655656 uint8_t index = Entry.n_sect;
656657
669670 Sec.d.a++;
670671 }
671672
672 error_code
673 MachOObjectFile::getSectionName(DataRefImpl Sec, StringRef &Result) const {
673 std::error_code MachOObjectFile::getSectionName(DataRefImpl Sec,
674 StringRef &Result) const {
674675 ArrayRef Raw = getSectionRawName(Sec);
675676 Result = parseSegmentOrSectionName(Raw.data());
676677 return object_error::success;
677678 }
678679
679 error_code
680 MachOObjectFile::getSectionAddress(DataRefImpl Sec, uint64_t &Res) const {
680 std::error_code MachOObjectFile::getSectionAddress(DataRefImpl Sec,
681 uint64_t &Res) const {
681682 if (is64Bit()) {
682683 MachO::section_64 Sect = getSection64(Sec);
683684 Res = Sect.addr;
688689 return object_error::success;
689690 }
690691
691 error_code
692 MachOObjectFile::getSectionSize(DataRefImpl Sec, uint64_t &Res) const {
692 std::error_code MachOObjectFile::getSectionSize(DataRefImpl Sec,
693 uint64_t &Res) const {
693694 if (is64Bit()) {
694695 MachO::section_64 Sect = getSection64(Sec);
695696 Res = Sect.size;
701702 return object_error::success;
702703 }
703704
704 error_code
705 MachOObjectFile::getSectionContents(DataRefImpl Sec, StringRef &Res) const {
705 std::error_code MachOObjectFile::getSectionContents(DataRefImpl Sec,
706 StringRef &Res) const {
706707 uint32_t Offset;
707708 uint64_t Size;
708709
720721 return object_error::success;
721722 }
722723
723 error_code
724 MachOObjectFile::getSectionAlignment(DataRefImpl Sec, uint64_t &Res) const {
724 std::error_code MachOObjectFile::getSectionAlignment(DataRefImpl Sec,
725 uint64_t &Res) const {
725726 uint32_t Align;
726727 if (is64Bit()) {
727728 MachO::section_64 Sect = getSection64(Sec);
735736 return object_error::success;
736737 }
737738
738 error_code
739 MachOObjectFile::isSectionText(DataRefImpl Sec, bool &Res) const {
739 std::error_code MachOObjectFile::isSectionText(DataRefImpl Sec,
740 bool &Res) const {
740741 uint32_t Flags = getSectionFlags(this, Sec);
741742 Res = Flags & MachO::S_ATTR_PURE_INSTRUCTIONS;
742743 return object_error::success;
743744 }
744745
745 error_code MachOObjectFile::isSectionData(DataRefImpl Sec, bool &Result) const {
746 std::error_code MachOObjectFile::isSectionData(DataRefImpl Sec,
747 bool &Result) const {
746748 uint32_t Flags = getSectionFlags(this, Sec);
747749 unsigned SectionType = Flags & MachO::SECTION_TYPE;
748750 Result = !(Flags & MachO::S_ATTR_PURE_INSTRUCTIONS) &&
751753 return object_error::success;
752754 }
753755
754 error_code MachOObjectFile::isSectionBSS(DataRefImpl Sec, bool &Result) const {
756 std::error_code MachOObjectFile::isSectionBSS(DataRefImpl Sec,
757 bool &Result) const {
755758 uint32_t Flags = getSectionFlags(this, Sec);
756759 unsigned SectionType = Flags & MachO::SECTION_TYPE;
757760 Result = !(Flags & MachO::S_ATTR_PURE_INSTRUCTIONS) &&
760763 return object_error::success;
761764 }
762765
763 error_code
766 std::error_code
764767 MachOObjectFile::isSectionRequiredForExecution(DataRefImpl Sec,
765768 bool &Result) const {
766769 // FIXME: Unimplemented.
768771 return object_error::success;
769772 }
770773
771 error_code MachOObjectFile::isSectionVirtual(DataRefImpl Sec,
772 bool &Result) const {
774 std::error_code MachOObjectFile::isSectionVirtual(DataRefImpl Sec,
775 bool &Result) const {
773776 // FIXME: Unimplemented.
774777 Result = false;
775778 return object_error::success;
776779 }
777780
778 error_code
779 MachOObjectFile::isSectionZeroInit(DataRefImpl Sec, bool &Res) const {
781 std::error_code MachOObjectFile::isSectionZeroInit(DataRefImpl Sec,
782 bool &Res) const {
780783 uint32_t Flags = getSectionFlags(this, Sec);
781784 unsigned SectionType = Flags & MachO::SECTION_TYPE;
782785 Res = SectionType == MachO::S_ZEROFILL ||
784787 return object_error::success;
785788 }
786789
787 error_code MachOObjectFile::isSectionReadOnlyData(DataRefImpl Sec,
788 bool &Result) const {
790 std::error_code MachOObjectFile::isSectionReadOnlyData(DataRefImpl Sec,
791 bool &Result) const {
789792 // Consider using the code from isSectionText to look for __const sections.
790793 // Alternately, emit S_ATTR_PURE_INSTRUCTIONS and/or S_ATTR_SOME_INSTRUCTIONS
791794 // to use section attributes to distinguish code from data.
795798 return object_error::success;
796799 }
797800
798 error_code
799 MachOObjectFile::sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb,
800 bool &Result) const {
801 std::error_code MachOObjectFile::sectionContainsSymbol(DataRefImpl Sec,
802 DataRefImpl Symb,
803 bool &Result) const {
801804 SymbolRef::Type ST;
802805 this->getSymbolType(Symb, ST);
803806 if (ST == SymbolRef::ST_Unknown) {
845848 ++Rel.d.b;
846849 }
847850
848 error_code
849 MachOObjectFile::getRelocationAddress(DataRefImpl Rel, uint64_t &Res) const {
851 std::error_code MachOObjectFile::getRelocationAddress(DataRefImpl Rel,
852 uint64_t &Res) const {
850853 uint64_t Offset;
851854 getRelocationOffset(Rel, Offset);
852855
858861 return object_error::success;
859862 }
860863
861 error_code MachOObjectFile::getRelocationOffset(DataRefImpl Rel,
862 uint64_t &Res) const {
864 std::error_code MachOObjectFile::getRelocationOffset(DataRefImpl Rel,
865 uint64_t &Res) const {
863866 assert(getHeader().filetype == MachO::MH_OBJECT &&
864867 "Only implemented for MH_OBJECT");
865868 MachO::any_relocation_info RE = getRelocation(Rel);
885888 return symbol_iterator(SymbolRef(Sym, this));
886889 }
887890
888 error_code MachOObjectFile::getRelocationType(DataRefImpl Rel,
889 uint64_t &Res) const {
891 std::error_code MachOObjectFile::getRelocationType(DataRefImpl Rel,
892 uint64_t &Res) const {
890893 MachO::any_relocation_info RE = getRelocation(Rel);
891894 Res = getAnyRelocationType(RE);
892895 return object_error::success;
893896 }
894897
895 error_code
898 std::error_code
896899 MachOObjectFile::getRelocationTypeName(DataRefImpl Rel,
897900 SmallVectorImpl &Result) const {
898901 StringRef res;
10051008 return object_error::success;
10061009 }
10071010
1008 error_code
1011 std::error_code
10091012 MachOObjectFile::getRelocationValueString(DataRefImpl Rel,
10101013 SmallVectorImpl &Result) const {
10111014 MachO::any_relocation_info RE = getRelocation(Rel);
11811184 return object_error::success;
11821185 }
11831186
1184 error_code
1185 MachOObjectFile::getRelocationHidden(DataRefImpl Rel, bool &Result) const {
1187 std::error_code MachOObjectFile::getRelocationHidden(DataRefImpl Rel,
1188 bool &Result) const {
11861189 unsigned Arch = getArch();
11871190 uint64_t Type;
11881191 getRelocationType(Rel, Type);
12091212 return object_error::success;
12101213 }
12111214
1212 error_code MachOObjectFile::getLibraryNext(DataRefImpl LibData,
1213 LibraryRef &Res) const {
1215 std::error_code MachOObjectFile::getLibraryNext(DataRefImpl LibData,
1216 LibraryRef &Res) const {
12141217 report_fatal_error("Needed libraries unimplemented in MachOObjectFile");
12151218 }
12161219
1217 error_code MachOObjectFile::getLibraryPath(DataRefImpl LibData,
1218 StringRef &Res) const {
1220 std::error_code MachOObjectFile::getLibraryPath(DataRefImpl LibData,
1221 StringRef &Res) const {
12191222 report_fatal_error("Needed libraries unimplemented in MachOObjectFile");
12201223 }
12211224
13661369 // normal two-level namespace default (that is MH_TWOLEVEL in the header).
13671370 // It is passed the index (0 - based) of the library as translated from
13681371 // GET_LIBRARY_ORDINAL (1 - based).
1369 error_code MachOObjectFile::getLibraryShortNameByIndex(unsigned Index,
1370 StringRef &Res) {
1372 std::error_code MachOObjectFile::getLibraryShortNameByIndex(unsigned Index,
1373 StringRef &Res) {
13711374 if (Index >= Libraries.size())
13721375 return object_error::parse_failed;
13731376
18171820 ErrorOr ObjectFile::createMachOObjectFile(MemoryBuffer *Buffer,
18181821 bool BufferOwned) {
18191822 StringRef Magic = Buffer->getBuffer().slice(0, 4);
1820 error_code EC;
1823 std::error_code EC;
18211824 std::unique_ptr Ret;
18221825 if (Magic == "\xFE\xED\xFA\xCE")
18231826 Ret.reset(new MachOObjectFile(Buffer, false, false, EC, BufferOwned));
2020
2121 using namespace llvm;
2222 using namespace object;
23 using std::error_code;
2324
2425 template
2526 static void SwapValue(T &Value) {
1717
1818 using namespace llvm;
1919 using namespace object;
20 using std::error_code;
2021
2122 inline ObjectFile *unwrap(LLVMObjectFileRef OF) {
2223 return reinterpret_cast(OF);
1919
2020 using namespace llvm;
2121 using namespace object;
22 using std::error_code;
2223
2324 void ObjectFile::anchor() { }
2425
1919 #include
2020
2121 using namespace llvm;
22 using std::error_code;
2223
2324 static error_code setupMemoryBuffer(std::string Path,
2425 std::unique_ptr &Buffer) {
6565 };
6666 }
6767
68 error_code InstrProfWriter::addFunctionCounts(StringRef FunctionName,
69 uint64_t FunctionHash,
70 ArrayRef Counters) {
68 std::error_code
69 InstrProfWriter::addFunctionCounts(StringRef FunctionName,
70 uint64_t FunctionHash,
71 ArrayRef Counters) {
7172 auto Where = FunctionData.find(FunctionName);
7273 if (Where == FunctionData.end()) {
7374 // If this is the first time we've seen this function, just add it.
2727 #include
2828 #endif
2929 using namespace llvm;
30 using std::error_code;
3031
3132 #define DEBUG_TYPE "Data-stream"
3233
1616 #include
1717
1818 using llvm::sys::fs::mapped_file_region;
19 using std::error_code;
1920
2021 namespace llvm {
2122 FileOutputBuffer::FileOutputBuffer(mapped_file_region * R,
2121 #include
2222 #include
2323 using namespace llvm;
24 using std::error_code;
2425
2526 static bool isSignedChar(char C) {
2627 return (C == '+' || C == '-');
6767 std::string llvm::createGraphFilename(const Twine &Name, int &FD) {
6868 FD = -1;
6969 SmallString<128> Filename;
70 error_code EC = sys::fs::createTemporaryFile(Name, "dot", FD, Filename);
70 std::error_code EC = sys::fs::createTemporaryFile(Name, "dot", FD, Filename);
7171 if (EC) {
7272 errs() << "Error: " << EC.message() << "\n";
7373 return "";
2121 #include
2222 #endif
2323 using namespace llvm;
24 using std::error_code;
2425
2526 /// \brief Attempt to read the lock file with the given name, if it exists.
2627 ///
3232 #include
3333 #endif
3434 using namespace llvm;
35 using std::error_code;
3536
3637 //===----------------------------------------------------------------------===//
3738 // MemoryBuffer implementation itself.
2727 #endif
2828
2929 using namespace llvm;
30 using std::error_code;
3031
3132 namespace {
3233 using llvm::StringRef;
3636 #else
3737 extern "C" void __clear_cache(void *, void*);
3838 #endif
39 using std::error_code;
3940
4041 namespace {
4142
4545
4646 using namespace llvm;
4747 using namespace sys;
48
48 using std::error_code;
4949
5050 process::id_type self_process::get_id() {
5151 return getpid();
4747 #endif
4848
4949 namespace llvm {
50 using std::error_code;
51
5052 using namespace sys;
5153
5254 ProcessInfo::ProcessInfo() : Pid(0), ReturnCode(0) {}
1818
1919 // The Windows.h header must be the last one included.
2020 #include "WindowsSupport.h"
21 using std::error_code;
2122
2223 namespace {
2324
4747
4848 using namespace llvm;
4949 using namespace sys;
50
50 using std::error_code;
5151
5252 process::id_type self_process::get_id() {
5353 return GetCurrentProcessId();
2323 //===----------------------------------------------------------------------===//
2424
2525 namespace llvm {
26 using std::error_code;
2627 using namespace sys;
2728
2829 ProcessInfo::ProcessInfo() : ProcessHandle(0), Pid(0), ReturnCode(0) {}
1717 #include
1818 using namespace llvm;
1919 using namespace yaml;
20 using std::error_code;
2021
2122 //===----------------------------------------------------------------------===//
2223 // IO
449449 return;
450450 }
451451
452 error_code EC = sys::fs::openFileForWrite(Filename, FD, Flags);
452 std::error_code EC = sys::fs::openFileForWrite(Filename, FD, Flags);
453453
454454 if (EC) {
455455 ErrorInfo = "Error opening output file '" + std::string(Filename) + "': " +
2626 #include
2727 #include
2828 using namespace llvm;
29 using std::error_code;
2930
3031 namespace {
3132 cl::opt
5050 #include
5151
5252 using namespace llvm;
53 using std::error_code;
5354
5455 #define DEBUG_TYPE "sample-profile"
5556
3535 #include "llvm/Pass.h"
3636 #include "llvm/Transforms/Utils/Local.h"
3737 using namespace llvm;
38 using std::error_code;
3839
3940 #define DEBUG_TYPE "simplifycfg"
4041
3030 #include
3131
3232 namespace llvm {
33 using std::error_code;
3334
3435 /// Represents a set of regular expressions. Regular expressions which are
3536 /// "literal" (i.e. no regex metacharacters) are stored in Strings, while all
2121 #include
2222
2323 using namespace llvm;
24 using std::error_code;
2425
2526 namespace {
2627 // OutputType - Allow the user to specify the way code should be run, to test
3232 #include "llvm/Transforms/Utils/CodeExtractor.h"
3333 #include
3434 using namespace llvm;
35 using std::error_code;
3536
3637 #define DEBUG_TYPE "bugpoint"
3738
2626 #include "llvm/Support/FileUtilities.h"
2727 #include "llvm/Transforms/Utils/Cloning.h"
2828 using namespace llvm;
29 using std::error_code;
2930
3031 namespace llvm {
3132 extern cl::opt OutputPrefix;
3434 #include
3535
3636 using namespace llvm;
37 using std::error_code;
3738
3839 #define DEBUG_TYPE "bugpoint"
3940
2121 #include
2222 #include
2323 using namespace llvm;
24 using std::error_code;
2425
2526 #define DEBUG_TYPE "toolrunner"
2627
4343 #endif
4444
4545 using namespace llvm;
46 using std::error_code;
4647
4748 namespace {
4849 ld_plugin_status discard_message(int level, const char *format, ...) {
1818 #include "llvm/Support/Format.h"
1919
2020 using namespace llvm;
21 using std::error_code;
2122
2223 #define DEBUG_TYPE "lli"
2324
6161 #endif
6262
6363 using namespace llvm;
64 using std::error_code;
6465
6566 #define DEBUG_TYPE "lli"
6667
3535 #endif
3636
3737 using namespace llvm;
38 using std::error_code;
3839
3940 // The name this program was invoked as.
4041 static StringRef ToolName;
4242 #include
4343 #include
4444 using namespace llvm;
45 using std::error_code;
4546
4647 static cl::opt
4748 InputFilename(cl::Positional, cl::desc(""), cl::init("-"));
2121 #include "llvm/Support/Signals.h"
2222 #include
2323 using namespace llvm;
24 using std::error_code;
2425
2526 static cl::opt SourceFile(cl::Positional, cl::Required,
2627 cl::desc("SOURCEFILE"));
3333 #include "llvm/Support/ToolOutputFile.h"
3434 #include
3535 using namespace llvm;
36 using std::error_code;
3637
3738 static cl::opt
3839 InputFilename(cl::Positional, cl::desc(""), cl::init("-"));
3232
3333 using namespace llvm;
3434 using namespace object;
35 using std::error_code;
3536
3637 static cl::list
3738 InputFilenames(cl::Positional, cl::desc(""),
3939 #include "llvm/Support/TargetSelect.h"
4040 #include "llvm/Support/ToolOutputFile.h"
4141 using namespace llvm;
42 using std::error_code;
4243
4344 static cl::opt
4445 InputFilename(cl::Positional, cl::desc(""), cl::init("-"));
2020 #include "llvm/Support/raw_ostream.h"
2121 #include
2222 using namespace llvm;
23 using std::error_code;
2324
2425 static cl::list
2526 InputFilenames(cl::Positional, cl::desc(""),
4444 #include
4545 using namespace llvm;
4646 using namespace object;
47 using std::error_code;
4748
4849 namespace {
4950 enum OutputFormatTy { bsd, sysv, posix, darwin };
6363
6464 using namespace llvm;
6565 using namespace object;
66 using std::error_code;
6667
6768 static cl::list
6869 InputFilenames(cl::Positional, cl::desc(""),cl::ZeroOrMore);
1515 #include "llvm/Support/StringRefMemoryObject.h"
1616
1717 namespace llvm {
18 using std::error_code;
1819
1920 namespace object {
2021 class COFFObjectFile;
2323 #include "llvm/Support/raw_ostream.h"
2424
2525 using namespace llvm;
26 using std::error_code;
2627
2728 static void exitWithError(const Twine &Message, StringRef Whence = "") {
2829 errs() << "error: ";
2121 #include "llvm/Support/type_traits.h"
2222
2323 namespace llvm {
24 using std::error_code;
2425 namespace ARM {
2526 namespace EHABI {
2627
1414 #include "llvm/Support/ErrorOr.h"
1515
1616 namespace llvm {
17 using std::error_code;
1718 namespace ARM {
1819 namespace WinEH {
1920 class RuntimeFunction;
1515 using namespace llvm;
1616 using namespace llvm::object;
1717 using namespace llvm::Win64EH;
18 using std::error_code;
1819
1920 static const EnumEntry UnwindFlags[] = {
2021 { "ExceptionHandler", UNW_ExceptionHandler },
1313 #include "llvm/Support/Win64EH.h"
1414
1515 namespace llvm {
16 using std::error_code;
1617 namespace object {
1718 class COFFObjectFile;
1819 class SymbolRef;
1313 #include
1414
1515 namespace llvm {
16 using std::error_code;
1617 namespace object {
1718 class RelocationRef;
1819 }