Re-sort #include lines using my handy dandy ./utils/sort_includes.py
[oota-llvm.git] / lib / DebugInfo / PDB / PDBSymbolCompiland.cpp
1 //===- PDBSymbolCompiland.cpp - compiland details --------*- C++ -*-===//
2 //
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/IPDBEnumChildren.h"
11 #include "llvm/DebugInfo/PDB/IPDBSession.h"
12 #include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
13 #include "llvm/DebugInfo/PDB/PDBExtras.h"
14 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
15 #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
16 #include "llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h"
17 #include "llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h"
18 #include "llvm/Support/Path.h"
19 #include "llvm/Support/raw_ostream.h"
20 #include <utility>
21 #include <vector>
22
23 using namespace llvm;
24
25 PDBSymbolCompiland::PDBSymbolCompiland(const IPDBSession &PDBSession,
26                                        std::unique_ptr<IPDBRawSymbol> Symbol)
27     : PDBSymbol(PDBSession, std::move(Symbol)) {}
28
29 void PDBSymbolCompiland::dump(raw_ostream &OS, int Indent,
30                               PDB_DumpLevel Level) const {
31   if (Level == PDB_DumpLevel::Detailed) {
32     std::string FullName = getName();
33     StringRef Name = llvm::sys::path::filename(StringRef(FullName.c_str()));
34
35     OS.indent(Indent);
36     OS << "Compiland: " << Name << "\n";
37
38     std::string Source = getSourceFileName();
39     std::string Library = getLibraryName();
40     if (!Source.empty())
41       OS << stream_indent(Indent + 2) << "Source: " << this->getSourceFileName()
42          << "\n";
43     if (!Library.empty())
44       OS << stream_indent(Indent + 2) << "Library: " << this->getLibraryName()
45          << "\n";
46
47     TagStats Stats;
48     auto ChildrenEnum = getChildStats(Stats);
49     OS << stream_indent(Indent + 2) << "Children: " << Stats << "\n";
50     if (Level >= PDB_DumpLevel::Detailed) {
51       while (auto Child = ChildrenEnum->getNext()) {
52         if (llvm::isa<PDBSymbolCompilandDetails>(*Child))
53           continue;
54         if (llvm::isa<PDBSymbolCompilandEnv>(*Child))
55           continue;
56         PDB_DumpLevel ChildLevel = (Level == PDB_DumpLevel::Detailed)
57                                        ? PDB_DumpLevel::Normal
58                                        : PDB_DumpLevel::Compact;
59         Child->dump(OS, Indent + 4, ChildLevel);
60         OS << "\n";
61       }
62     }
63
64     auto DetailsEnum(findAllChildren<PDBSymbolCompilandDetails>());
65     if (auto CD = DetailsEnum->getNext()) {
66       VersionInfo FE;
67       VersionInfo BE;
68       CD->getFrontEndVersion(FE);
69       CD->getBackEndVersion(BE);
70       OS << stream_indent(Indent + 2) << "Compiler: " << CD->getCompilerName()
71          << "\n";
72       OS << stream_indent(Indent + 2) << "Version: " << FE << ", " << BE
73          << "\n";
74
75       OS << stream_indent(Indent + 2) << "Lang: " << CD->getLanguage() << "\n";
76       OS << stream_indent(Indent + 2) << "Attributes: ";
77       if (CD->hasDebugInfo())
78         OS << "DebugInfo ";
79       if (CD->isDataAligned())
80         OS << "DataAligned ";
81       if (CD->isLTCG())
82         OS << "LTCG ";
83       if (CD->hasSecurityChecks())
84         OS << "SecurityChecks ";
85       if (CD->isHotpatchable())
86         OS << "HotPatchable";
87
88       auto Files(Session.getSourceFilesForCompiland(*this));
89       OS << "\n";
90       OS << stream_indent(Indent + 2) << Files->getChildCount()
91          << " source files";
92     }
93     uint32_t Count = DetailsEnum->getChildCount();
94     if (Count > 1) {
95       OS << "\n";
96       OS << stream_indent(Indent + 2) << "(" << Count - 1 << " more omitted)";
97     }
98   } else {
99     std::string FullName = getName();
100     OS << stream_indent(Indent) << "Compiland: " << FullName;
101   }
102 }