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