llvm-pdbdump: Add flags controlling the type of values to dump.
[oota-llvm.git] / lib / DebugInfo / PDB / PDBSymbolTypePointer.cpp
index 2fd4314e3e133e04e4c46d7fc28665a92a6b0908..3461928993adce9667fa4dbc00c936f1c25644cd 100644 (file)
@@ -1,5 +1,4 @@
-//===- PDBSymbolTypePointer.cpp - --------------------------------*- C++
-//-*-===//
+//===- PDBSymbolTypePointer.cpp -----------------------------------*- C++ -===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -8,11 +7,13 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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;
 
@@ -21,14 +22,25 @@ PDBSymbolTypePointer::PDBSymbolTypePointer(
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypePointer::dump(raw_ostream &OS, int Indent,
-                                PDB_DumpLevel Level) const {
+                                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))
-    PointeeType->dump(OS, 0, PDB_DumpLevel::Compact);
-  OS << ((isReference()) ? "&" : "*");
+  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()) ? "&" : "*");
+    }
+  }
 }