1 //===- NativeCompilandSymbol.cpp - Native impl for compilands ---*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h"
10 #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
11 
12 namespace llvm {
13 namespace pdb {
14 
NativeCompilandSymbol(NativeSession & Session,SymIndexId SymbolId,DbiModuleDescriptor MI)15 NativeCompilandSymbol::NativeCompilandSymbol(NativeSession &Session,
16                                              SymIndexId SymbolId,
17                                              DbiModuleDescriptor MI)
18     : NativeRawSymbol(Session, PDB_SymType::Compiland, SymbolId), Module(MI) {}
19 
getSymTag() const20 PDB_SymType NativeCompilandSymbol::getSymTag() const {
21   return PDB_SymType::Compiland;
22 }
23 
dump(raw_ostream & OS,int Indent,PdbSymbolIdField ShowIdFields,PdbSymbolIdField RecurseIdFields) const24 void NativeCompilandSymbol::dump(raw_ostream &OS, int Indent,
25                                  PdbSymbolIdField ShowIdFields,
26                                  PdbSymbolIdField RecurseIdFields) const {
27   NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
28 
29   dumpSymbolIdField(OS, "lexicalParentId", 0, Indent, Session,
30                     PdbSymbolIdField::LexicalParent, ShowIdFields,
31                     RecurseIdFields);
32   dumpSymbolField(OS, "libraryName", getLibraryName(), Indent);
33   dumpSymbolField(OS, "name", getName(), Indent);
34   dumpSymbolField(OS, "editAndContinueEnabled", isEditAndContinueEnabled(),
35                   Indent);
36 }
37 
isEditAndContinueEnabled() const38 bool NativeCompilandSymbol::isEditAndContinueEnabled() const {
39   return Module.hasECInfo();
40 }
41 
getLexicalParentId() const42 SymIndexId NativeCompilandSymbol::getLexicalParentId() const { return 0; }
43 
44 // The usage of getObjFileName for getLibraryName and getModuleName for getName
45 // may seem backwards, but it is consistent with DIA, which is what this API
46 // was modeled after.  We may rename these methods later to try to eliminate
47 // this potential confusion.
48 
getLibraryName() const49 std::string NativeCompilandSymbol::getLibraryName() const {
50   return std::string(Module.getObjFileName());
51 }
52 
getName() const53 std::string NativeCompilandSymbol::getName() const {
54   return std::string(Module.getModuleName());
55 }
56 
57 } // namespace pdb
58 } // namespace llvm
59