Re-sort #include lines using my handy dandy ./utils/sort_includes.py
[oota-llvm.git] / lib / DebugInfo / PDB / PDBSymbolTypeFunctionSig.cpp
1 //===- PDBSymbolTypeFunctionSig.cpp - --------------------------*- 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/ConcreteSymbolEnumerator.h"
11 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
12 #include "llvm/DebugInfo/PDB/IPDBSession.h"
13 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
14 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h"
15 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
16 #include <utility>
17
18 using namespace llvm;
19
20 PDBSymbolTypeFunctionSig::PDBSymbolTypeFunctionSig(
21     const IPDBSession &PDBSession, std::unique_ptr<IPDBRawSymbol> Symbol)
22     : PDBSymbol(PDBSession, std::move(Symbol)) {}
23
24 void PDBSymbolTypeFunctionSig::dump(raw_ostream &OS, int Indent,
25                                     PDB_DumpLevel Level) const {
26   OS << stream_indent(Indent);
27
28   uint32_t ReturnTypeId = getTypeId();
29   if (auto ReturnType = Session.getSymbolById(ReturnTypeId)) {
30     ReturnType->dump(OS, 0, PDB_DumpLevel::Compact);
31     OS << " ";
32   }
33   // TODO: We need a way to detect if this is a pointer to function so that we
34   // can print the * between the return type and the argument list.  The only
35   // way to do this is to pass the parent into this function, but that will
36   // require a larger interface change.
37   OS << getCallingConvention() << " ";
38   uint32_t ClassId = getClassParentId();
39   if (ClassId != 0) {
40     if (auto ClassParent = Session.getSymbolById(ClassId)) {
41       OS << "(";
42       ClassParent->dump(OS, 0, PDB_DumpLevel::Compact);
43       OS << "::*)";
44     }
45   }
46   OS.flush();
47   OS << "(";
48   if (auto ChildEnum = findAllChildren<PDBSymbolTypeFunctionArg>()) {
49     uint32_t Index = 0;
50     while (auto Arg = ChildEnum->getNext()) {
51       Arg->dump(OS, 0, PDB_DumpLevel::Compact);
52       if (++Index < ChildEnum->getChildCount())
53         OS << ", ";
54     }
55   }
56   OS << ")";
57 }