Merging r259798, r259835:
[oota-llvm.git] / tools / llvm-pdbdump / VariableDumper.cpp
index d520fd10099df4cc61fccdb7a8c64171c6260943..e5665b5fcafa4a42f1c8ad9087a027724dd1248e 100644 (file)
@@ -17,6 +17,7 @@
 #include "llvm/DebugInfo/PDB/PDBSymbolData.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeArray.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
@@ -31,34 +32,52 @@ VariableDumper::VariableDumper(LinePrinter &P)
     : PDBSymDumper(true), Printer(P) {}
 
 void VariableDumper::start(const PDBSymbolData &Var) {
+  if (Var.isCompilerGenerated() && opts::ExcludeCompilerGenerated)
+    return;
   if (Printer.IsSymbolExcluded(Var.getName()))
     return;
 
-  Printer.NewLine();
-  Printer << "data ";
-
   auto VarType = Var.getType();
 
   switch (auto LocType = Var.getLocationType()) {
   case PDB_LocType::Static:
+    Printer.NewLine();
+    Printer << "data [";
     WithColor(Printer, PDB_ColorItem::Address).get()
-        << "[" << format_hex(Var.getRelativeVirtualAddress(), 10) << "] ";
+        << format_hex(Var.getVirtualAddress(), 10);
+    Printer << "] ";
     WithColor(Printer, PDB_ColorItem::Keyword).get() << "static ";
     dumpSymbolTypeAndName(*VarType, Var.getName());
     break;
   case PDB_LocType::Constant:
+    if (isa<PDBSymbolTypeEnum>(*VarType))
+      break;
+    Printer.NewLine();
+    Printer << "data ";
     WithColor(Printer, PDB_ColorItem::Keyword).get() << "const ";
     dumpSymbolTypeAndName(*VarType, Var.getName());
-    Printer << "[";
+    Printer << " = ";
     WithColor(Printer, PDB_ColorItem::LiteralValue).get() << Var.getValue();
-    Printer << "]";
     break;
   case PDB_LocType::ThisRel:
+    Printer.NewLine();
+    Printer << "data ";
+    WithColor(Printer, PDB_ColorItem::Offset).get()
+        << "+" << format_hex(Var.getOffset(), 4) << " ";
+    dumpSymbolTypeAndName(*VarType, Var.getName());
+    break;
+  case PDB_LocType::BitField:
+    Printer.NewLine();
+    Printer << "data ";
     WithColor(Printer, PDB_ColorItem::Offset).get()
         << "+" << format_hex(Var.getOffset(), 4) << " ";
     dumpSymbolTypeAndName(*VarType, Var.getName());
+    Printer << " : ";
+    WithColor(Printer, PDB_ColorItem::LiteralValue).get() << Var.getLength();
     break;
   default:
+    Printer.NewLine();
+    Printer << "data ";
     Printer << "unknown(" << LocType << ") ";
     WithColor(Printer, PDB_ColorItem::Identifier).get() << Var.getName();
     break;