1317017Sdim//===- NativeCompilandSymbol.cpp - Native impl for compilands ---*- C++ -*-===//
2317017Sdim//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6317017Sdim//
7317017Sdim//===----------------------------------------------------------------------===//
8317017Sdim
9317017Sdim#include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h"
10344779Sdim#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
11317017Sdim
12320397Sdim#include "llvm/ADT/STLExtras.h"
13320397Sdim
14317017Sdimnamespace llvm {
15317017Sdimnamespace pdb {
16317017Sdim
17317017SdimNativeCompilandSymbol::NativeCompilandSymbol(NativeSession &Session,
18320970Sdim                                             SymIndexId SymbolId,
19317969Sdim                                             DbiModuleDescriptor MI)
20344779Sdim    : NativeRawSymbol(Session, PDB_SymType::Compiland, SymbolId), Module(MI) {}
21317017Sdim
22317017SdimPDB_SymType NativeCompilandSymbol::getSymTag() const {
23317017Sdim  return PDB_SymType::Compiland;
24317017Sdim}
25317017Sdim
26344779Sdimvoid NativeCompilandSymbol::dump(raw_ostream &OS, int Indent,
27344779Sdim                                 PdbSymbolIdField ShowIdFields,
28344779Sdim                                 PdbSymbolIdField RecurseIdFields) const {
29344779Sdim  NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
30344779Sdim
31344779Sdim  dumpSymbolIdField(OS, "lexicalParentId", 0, Indent, Session,
32344779Sdim                    PdbSymbolIdField::LexicalParent, ShowIdFields,
33344779Sdim                    RecurseIdFields);
34344779Sdim  dumpSymbolField(OS, "libraryName", getLibraryName(), Indent);
35344779Sdim  dumpSymbolField(OS, "name", getName(), Indent);
36344779Sdim  dumpSymbolField(OS, "editAndContinueEnabled", isEditAndContinueEnabled(),
37344779Sdim                  Indent);
38320397Sdim}
39320397Sdim
40317017Sdimbool NativeCompilandSymbol::isEditAndContinueEnabled() const {
41317969Sdim  return Module.hasECInfo();
42317017Sdim}
43317017Sdim
44344779SdimSymIndexId NativeCompilandSymbol::getLexicalParentId() const { return 0; }
45317017Sdim
46317017Sdim// The usage of getObjFileName for getLibraryName and getModuleName for getName
47317017Sdim// may seem backwards, but it is consistent with DIA, which is what this API
48317017Sdim// was modeled after.  We may rename these methods later to try to eliminate
49317017Sdim// this potential confusion.
50317017Sdim
51317017Sdimstd::string NativeCompilandSymbol::getLibraryName() const {
52317969Sdim  return Module.getObjFileName();
53317017Sdim}
54317017Sdim
55317017Sdimstd::string NativeCompilandSymbol::getName() const {
56317969Sdim  return Module.getModuleName();
57317017Sdim}
58317017Sdim
59317017Sdim} // namespace pdb
60317017Sdim} // namespace llvm
61