blob: 7856da3854ebeb033ca0da73991887642bf6de71 [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//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h"
11
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 Turnerda4b63a2018-09-07 23:21:33 +000026void NativeCompilandSymbol::dump(raw_ostream &OS, int Indent) const {
27 NativeRawSymbol::dump(OS, Indent);
28
29 dumpSymbolField(OS, "baseType", static_cast<uint32_t>(getBuiltinType()),
30 Indent);
31 dumpSymbolField(OS, "lexicalParentId", 0, Indent);
32 dumpSymbolField(OS, "libraryName", getLibraryName(), Indent);
33 dumpSymbolField(OS, "name", getName(), Indent);
34 dumpSymbolField(OS, "editAndContinueEnabled", isEditAndContinueEnabled(),
35 Indent);
36}
37
Adrian McCarthy31bcb6f2017-06-22 18:43:18 +000038std::unique_ptr<NativeRawSymbol> NativeCompilandSymbol::clone() const {
Adrian McCarthy4aedc812017-06-22 18:57:51 +000039 return llvm::make_unique<NativeCompilandSymbol>(Session, SymbolId, Module);
Adrian McCarthy31bcb6f2017-06-22 18:43:18 +000040}
41
Adrian McCarthy65d26882017-03-15 20:17:58 +000042bool NativeCompilandSymbol::isEditAndContinueEnabled() const {
Zachary Turner1eb9a022017-05-04 23:53:29 +000043 return Module.hasECInfo();
Adrian McCarthy65d26882017-03-15 20:17:58 +000044}
45
46uint32_t NativeCompilandSymbol::getLexicalParentId() const { return 0; }
47
Adrian McCarthyad6d60a2017-03-15 20:29:06 +000048// The usage of getObjFileName for getLibraryName and getModuleName for getName
49// may seem backwards, but it is consistent with DIA, which is what this API
50// was modeled after. We may rename these methods later to try to eliminate
51// this potential confusion.
Adrian McCarthy65d26882017-03-15 20:17:58 +000052
53std::string NativeCompilandSymbol::getLibraryName() const {
Zachary Turner1eb9a022017-05-04 23:53:29 +000054 return Module.getObjFileName();
Adrian McCarthy65d26882017-03-15 20:17:58 +000055}
56
57std::string NativeCompilandSymbol::getName() const {
Zachary Turner1eb9a022017-05-04 23:53:29 +000058 return Module.getModuleName();
Adrian McCarthy65d26882017-03-15 20:17:58 +000059}
60
61} // namespace pdb
62} // namespace llvm