Home | History | Annotate | Download | only in llvm-pdbdump
      1 //===- BuiltinDumper.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 "BuiltinDumper.h"
     11 #include "LinePrinter.h"
     12 #include "llvm-pdbdump.h"
     13 
     14 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
     15 
     16 using namespace llvm;
     17 using namespace llvm::pdb;
     18 
     19 BuiltinDumper::BuiltinDumper(LinePrinter &P)
     20     : PDBSymDumper(false), Printer(P) {}
     21 
     22 void BuiltinDumper::start(const PDBSymbolTypeBuiltin &Symbol) {
     23   WithColor(Printer, PDB_ColorItem::Type).get() << getTypeName(Symbol);
     24 }
     25 
     26 StringRef BuiltinDumper::getTypeName(const PDBSymbolTypeBuiltin &Symbol) {
     27   PDB_BuiltinType Type = Symbol.getBuiltinType();
     28   switch (Type) {
     29   case PDB_BuiltinType::Float:
     30     if (Symbol.getLength() == 4)
     31       return "float";
     32     return "double";
     33   case PDB_BuiltinType::UInt:
     34     switch (Symbol.getLength()) {
     35     case 8:
     36       return "unsigned __int64";
     37     case 4:
     38       return "unsigned int";
     39     case 2:
     40       return "unsigned short";
     41     case 1:
     42       return "unsigned char";
     43     default:
     44       return "unsigned";
     45     }
     46   case PDB_BuiltinType::Int:
     47     switch (Symbol.getLength()) {
     48     case 8:
     49       return "__int64";
     50     case 4:
     51       return "int";
     52     case 2:
     53       return "short";
     54     case 1:
     55       return "char";
     56     default:
     57       return "int";
     58     }
     59   case PDB_BuiltinType::Char:
     60     return "char";
     61   case PDB_BuiltinType::WCharT:
     62     return "wchar_t";
     63   case PDB_BuiltinType::Void:
     64     return "void";
     65   case PDB_BuiltinType::Long:
     66     return "long";
     67   case PDB_BuiltinType::ULong:
     68     return "unsigned long";
     69   case PDB_BuiltinType::Bool:
     70     return "bool";
     71   case PDB_BuiltinType::Currency:
     72     return "CURRENCY";
     73   case PDB_BuiltinType::Date:
     74     return "DATE";
     75   case PDB_BuiltinType::Variant:
     76     return "VARIANT";
     77   case PDB_BuiltinType::Complex:
     78     return "complex";
     79   case PDB_BuiltinType::Bitfield:
     80     return "bitfield";
     81   case PDB_BuiltinType::BSTR:
     82     return "BSTR";
     83   case PDB_BuiltinType::HResult:
     84     return "HRESULT";
     85   case PDB_BuiltinType::BCD:
     86     return "HRESULT";
     87   default:
     88     return "void";
     89   }
     90 }
     91