blob: 7717f062eac11cfb15532eb4414e0d0bcf74cb52 [file] [log] [blame]
Adrian McCarthyad6d60a2017-03-15 20:29:06 +00001//===- NativeCompilandSymbol.cpp - Native impl for compilands ---*- C++ -*-===//
Adrian McCarthy65d26882017-03-15 20:17:58 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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 McCarthy65d26882017-03-15 20:17:58 +00006//
7//===----------------------------------------------------------------------===//
8
9#include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h"
Zachary Turnerc41ce832018-09-18 16:35:05 +000010#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
Adrian McCarthy65d26882017-03-15 20:17:58 +000011
Adrian McCarthy4aedc812017-06-22 18:57:51 +000012#include "llvm/ADT/STLExtras.h"
13
Adrian McCarthy65d26882017-03-15 20:17:58 +000014namespace llvm {
15namespace pdb {
16
17NativeCompilandSymbol::NativeCompilandSymbol(NativeSession &Session,
Adrian McCarthy8d090fc2017-07-12 19:38:11 +000018 SymIndexId SymbolId,
Zachary Turner1eb9a022017-05-04 23:53:29 +000019 DbiModuleDescriptor MI)
Zachary Turner7999b4f2018-09-05 23:30:38 +000020 : NativeRawSymbol(Session, PDB_SymType::Compiland, SymbolId), Module(MI) {}
Adrian McCarthy65d26882017-03-15 20:17:58 +000021
22PDB_SymType NativeCompilandSymbol::getSymTag() const {
23 return PDB_SymType::Compiland;
24}
25
Zachary Turnerc41ce832018-09-18 16:35:05 +000026void NativeCompilandSymbol::dump(raw_ostream &OS, int Indent,
27 PdbSymbolIdField ShowIdFields,
28 PdbSymbolIdField RecurseIdFields) const {
29 NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
Zachary Turnerda4b63a2018-09-07 23:21:33 +000030
Zachary Turnerc41ce832018-09-18 16:35:05 +000031 dumpSymbolIdField(OS, "lexicalParentId", 0, Indent, Session,
32 PdbSymbolIdField::LexicalParent, ShowIdFields,
33 RecurseIdFields);
Zachary Turnerda4b63a2018-09-07 23:21:33 +000034 dumpSymbolField(OS, "libraryName", getLibraryName(), Indent);
35 dumpSymbolField(OS, "name", getName(), Indent);
36 dumpSymbolField(OS, "editAndContinueEnabled", isEditAndContinueEnabled(),
37 Indent);
38}
39
Adrian McCarthy65d26882017-03-15 20:17:58 +000040bool NativeCompilandSymbol::isEditAndContinueEnabled() const {
Zachary Turner1eb9a022017-05-04 23:53:29 +000041 return Module.hasECInfo();
Adrian McCarthy65d26882017-03-15 20:17:58 +000042}
43
Zachary Turnercae734582018-09-10 21:30:59 +000044SymIndexId NativeCompilandSymbol::getLexicalParentId() const { return 0; }
Adrian McCarthy65d26882017-03-15 20:17:58 +000045
Adrian McCarthyad6d60a2017-03-15 20:29:06 +000046// 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 McCarthy65d26882017-03-15 20:17:58 +000050
51std::string NativeCompilandSymbol::getLibraryName() const {
Benjamin Krameradcd0262020-01-28 20:23:46 +010052 return std::string(Module.getObjFileName());
Adrian McCarthy65d26882017-03-15 20:17:58 +000053}
54
55std::string NativeCompilandSymbol::getName() const {
Benjamin Krameradcd0262020-01-28 20:23:46 +010056 return std::string(Module.getModuleName());
Adrian McCarthy65d26882017-03-15 20:17:58 +000057}
58
59} // namespace pdb
60} // namespace llvm