Adrian McCarthy | ad6d60a | 2017-03-15 20:29:06 +0000 | [diff] [blame] | 1 | //===- NativeCompilandSymbol.cpp - Native impl for compilands ---*- C++ -*-===// |
Adrian McCarthy | 65d2688 | 2017-03-15 20:17:58 +0000 | [diff] [blame] | 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Adrian McCarthy | 65d2688 | 2017-03-15 20:17:58 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h" |
Zachary Turner | c41ce83 | 2018-09-18 16:35:05 +0000 | [diff] [blame] | 10 | #include "llvm/DebugInfo/PDB/Native/NativeSession.h" |
Adrian McCarthy | 65d2688 | 2017-03-15 20:17:58 +0000 | [diff] [blame] | 11 | |
Adrian McCarthy | 4aedc81 | 2017-06-22 18:57:51 +0000 | [diff] [blame] | 12 | #include "llvm/ADT/STLExtras.h" |
| 13 | |
Adrian McCarthy | 65d2688 | 2017-03-15 20:17:58 +0000 | [diff] [blame] | 14 | namespace llvm { |
| 15 | namespace pdb { |
| 16 | |
| 17 | NativeCompilandSymbol::NativeCompilandSymbol(NativeSession &Session, |
Adrian McCarthy | 8d090fc | 2017-07-12 19:38:11 +0000 | [diff] [blame] | 18 | SymIndexId SymbolId, |
Zachary Turner | 1eb9a02 | 2017-05-04 23:53:29 +0000 | [diff] [blame] | 19 | DbiModuleDescriptor MI) |
Zachary Turner | 7999b4f | 2018-09-05 23:30:38 +0000 | [diff] [blame] | 20 | : NativeRawSymbol(Session, PDB_SymType::Compiland, SymbolId), Module(MI) {} |
Adrian McCarthy | 65d2688 | 2017-03-15 20:17:58 +0000 | [diff] [blame] | 21 | |
| 22 | PDB_SymType NativeCompilandSymbol::getSymTag() const { |
| 23 | return PDB_SymType::Compiland; |
| 24 | } |
| 25 | |
Zachary Turner | c41ce83 | 2018-09-18 16:35:05 +0000 | [diff] [blame] | 26 | void NativeCompilandSymbol::dump(raw_ostream &OS, int Indent, |
| 27 | PdbSymbolIdField ShowIdFields, |
| 28 | PdbSymbolIdField RecurseIdFields) const { |
| 29 | NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields); |
Zachary Turner | da4b63a | 2018-09-07 23:21:33 +0000 | [diff] [blame] | 30 | |
Zachary Turner | c41ce83 | 2018-09-18 16:35:05 +0000 | [diff] [blame] | 31 | dumpSymbolIdField(OS, "lexicalParentId", 0, Indent, Session, |
| 32 | PdbSymbolIdField::LexicalParent, ShowIdFields, |
| 33 | RecurseIdFields); |
Zachary Turner | da4b63a | 2018-09-07 23:21:33 +0000 | [diff] [blame] | 34 | dumpSymbolField(OS, "libraryName", getLibraryName(), Indent); |
| 35 | dumpSymbolField(OS, "name", getName(), Indent); |
| 36 | dumpSymbolField(OS, "editAndContinueEnabled", isEditAndContinueEnabled(), |
| 37 | Indent); |
| 38 | } |
| 39 | |
Adrian McCarthy | 65d2688 | 2017-03-15 20:17:58 +0000 | [diff] [blame] | 40 | bool NativeCompilandSymbol::isEditAndContinueEnabled() const { |
Zachary Turner | 1eb9a02 | 2017-05-04 23:53:29 +0000 | [diff] [blame] | 41 | return Module.hasECInfo(); |
Adrian McCarthy | 65d2688 | 2017-03-15 20:17:58 +0000 | [diff] [blame] | 42 | } |
| 43 | |
Zachary Turner | cae73458 | 2018-09-10 21:30:59 +0000 | [diff] [blame] | 44 | SymIndexId NativeCompilandSymbol::getLexicalParentId() const { return 0; } |
Adrian McCarthy | 65d2688 | 2017-03-15 20:17:58 +0000 | [diff] [blame] | 45 | |
Adrian McCarthy | ad6d60a | 2017-03-15 20:29:06 +0000 | [diff] [blame] | 46 | // The usage of getObjFileName for getLibraryName and getModuleName for getName |
| 47 | // may seem backwards, but it is consistent with DIA, which is what this API |
| 48 | // was modeled after. We may rename these methods later to try to eliminate |
| 49 | // this potential confusion. |
Adrian McCarthy | 65d2688 | 2017-03-15 20:17:58 +0000 | [diff] [blame] | 50 | |
| 51 | std::string NativeCompilandSymbol::getLibraryName() const { |
Benjamin Kramer | adcd026 | 2020-01-28 20:23:46 +0100 | [diff] [blame] | 52 | return std::string(Module.getObjFileName()); |
Adrian McCarthy | 65d2688 | 2017-03-15 20:17:58 +0000 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | std::string NativeCompilandSymbol::getName() const { |
Benjamin Kramer | adcd026 | 2020-01-28 20:23:46 +0100 | [diff] [blame] | 56 | return std::string(Module.getModuleName()); |
Adrian McCarthy | 65d2688 | 2017-03-15 20:17:58 +0000 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | } // namespace pdb |
| 60 | } // namespace llvm |