llvm-pdbdump: Add flags controlling the type of values to dump.
[oota-llvm.git] / lib / DebugInfo / PDB / PDBSymbolTypePointer.cpp
index d7a8a638c23bdddde0e1bc4d90ba87f0c488dc71..3461928993adce9667fa4dbc00c936f1c25644cd 100644 (file)
@@ -1,5 +1,4 @@
-//===- PDBSymbolTypePointer.cpp - --------------------------------*- C++
-//-*-===//
+//===- PDBSymbolTypePointer.cpp -----------------------------------*- C++ -===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -8,15 +7,40 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <utility>
+#include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
 
+#include "llvm/DebugInfo/PDB/IPDBSession.h"
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
-#include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
+
+#include <utility>
 
 using namespace llvm;
 
 PDBSymbolTypePointer::PDBSymbolTypePointer(
-    std::unique_ptr<IPDBRawSymbol> Symbol)
-    : PDBSymbol(std::move(Symbol)) {}
+    const IPDBSession &PDBSession, std::unique_ptr<IPDBRawSymbol> Symbol)
+    : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
-void PDBSymbolTypePointer::dump(llvm::raw_ostream &OS) const {}
+void PDBSymbolTypePointer::dump(raw_ostream &OS, int Indent,
+                                PDB_DumpLevel Level, PDB_DumpFlags Flags) const {
+  OS << stream_indent(Indent);
+  if (isConstType())
+    OS << "const ";
+  if (isVolatileType())
+    OS << "volatile ";
+  uint32_t PointeeId = getTypeId();
+  if (auto PointeeType = Session.getSymbolById(PointeeId)) {
+    // Function pointers get special treatment, since we need to print the * in
+    // the middle of the signature.
+    if (auto FuncSig = dyn_cast<PDBSymbolTypeFunctionSig>(PointeeType.get())) {
+      if (auto ReturnType = FuncSig->getReturnType())
+        ReturnType->dump(OS, 0, PDB_DumpLevel::Compact, PDB_DF_Children);
+      OS << " (" << FuncSig->getCallingConvention() << " ";
+      OS << ((isReference()) ? "&" : "*") << ")";
+      FuncSig->dumpArgList(OS);
+    } else {
+      PointeeType->dump(OS, 0, PDB_DumpLevel::Compact, PDB_DF_Children);
+      OS << ((isReference()) ? "&" : "*");
+    }
+  }
+}