xref: /llvm-project/llvm/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp (revision eb4c8608115c1c9af0fc8cb5b1e9f2bc960014ef)
1ad6d60a4SAdrian McCarthy //===- NativeCompilandSymbol.cpp - Native impl for compilands ---*- C++ -*-===//
265d26888SAdrian McCarthy //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
665d26888SAdrian McCarthy //
765d26888SAdrian McCarthy //===----------------------------------------------------------------------===//
865d26888SAdrian McCarthy 
965d26888SAdrian McCarthy #include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h"
10c41ce835SZachary Turner #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
1165d26888SAdrian McCarthy 
1265d26888SAdrian McCarthy namespace llvm {
1365d26888SAdrian McCarthy namespace pdb {
1465d26888SAdrian McCarthy 
NativeCompilandSymbol(NativeSession & Session,SymIndexId SymbolId,DbiModuleDescriptor MI)1565d26888SAdrian McCarthy NativeCompilandSymbol::NativeCompilandSymbol(NativeSession &Session,
168d090fc5SAdrian McCarthy                                              SymIndexId SymbolId,
171eb9a029SZachary Turner                                              DbiModuleDescriptor MI)
187999b4faSZachary Turner     : NativeRawSymbol(Session, PDB_SymType::Compiland, SymbolId), Module(MI) {}
1965d26888SAdrian McCarthy 
getSymTag() const2065d26888SAdrian McCarthy PDB_SymType NativeCompilandSymbol::getSymTag() const {
2165d26888SAdrian McCarthy   return PDB_SymType::Compiland;
2265d26888SAdrian McCarthy }
2365d26888SAdrian McCarthy 
dump(raw_ostream & OS,int Indent,PdbSymbolIdField ShowIdFields,PdbSymbolIdField RecurseIdFields) const24c41ce835SZachary Turner void NativeCompilandSymbol::dump(raw_ostream &OS, int Indent,
25c41ce835SZachary Turner                                  PdbSymbolIdField ShowIdFields,
26c41ce835SZachary Turner                                  PdbSymbolIdField RecurseIdFields) const {
27c41ce835SZachary Turner   NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
28da4b63abSZachary Turner 
29c41ce835SZachary Turner   dumpSymbolIdField(OS, "lexicalParentId", 0, Indent, Session,
30c41ce835SZachary Turner                     PdbSymbolIdField::LexicalParent, ShowIdFields,
31c41ce835SZachary Turner                     RecurseIdFields);
32da4b63abSZachary Turner   dumpSymbolField(OS, "libraryName", getLibraryName(), Indent);
33da4b63abSZachary Turner   dumpSymbolField(OS, "name", getName(), Indent);
34da4b63abSZachary Turner   dumpSymbolField(OS, "editAndContinueEnabled", isEditAndContinueEnabled(),
35da4b63abSZachary Turner                   Indent);
36da4b63abSZachary Turner }
37da4b63abSZachary Turner 
isEditAndContinueEnabled() const3865d26888SAdrian McCarthy bool NativeCompilandSymbol::isEditAndContinueEnabled() const {
391eb9a029SZachary Turner   return Module.hasECInfo();
4065d26888SAdrian McCarthy }
4165d26888SAdrian McCarthy 
getLexicalParentId() const42cae73458SZachary Turner SymIndexId NativeCompilandSymbol::getLexicalParentId() const { return 0; }
4365d26888SAdrian McCarthy 
44ad6d60a4SAdrian McCarthy // The usage of getObjFileName for getLibraryName and getModuleName for getName
45ad6d60a4SAdrian McCarthy // may seem backwards, but it is consistent with DIA, which is what this API
46ad6d60a4SAdrian McCarthy // was modeled after.  We may rename these methods later to try to eliminate
47ad6d60a4SAdrian McCarthy // this potential confusion.
4865d26888SAdrian McCarthy 
getLibraryName() const4965d26888SAdrian McCarthy std::string NativeCompilandSymbol::getLibraryName() const {
50*adcd0268SBenjamin Kramer   return std::string(Module.getObjFileName());
5165d26888SAdrian McCarthy }
5265d26888SAdrian McCarthy 
getName() const5365d26888SAdrian McCarthy std::string NativeCompilandSymbol::getName() const {
54*adcd0268SBenjamin Kramer   return std::string(Module.getModuleName());
5565d26888SAdrian McCarthy }
5665d26888SAdrian McCarthy 
5765d26888SAdrian McCarthy } // namespace pdb
5865d26888SAdrian McCarthy } // namespace llvm
59