LCOV - code coverage report
Current view: top level - lib/DebugInfo/PDB - PDBSymbolTypeFunctionSig.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 4 37 10.8 %
Date: 2018-02-23 15:42:53 Functions: 1 12 8.3 %
Legend: Lines: hit not hit

          Line data    Source code
       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 "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
      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/PDBSymDumper.h"
      16             : #include "llvm/DebugInfo/PDB/PDBSymbol.h"
      17             : #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
      18             : #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h"
      19             : 
      20             : #include <utility>
      21             : 
      22             : using namespace llvm;
      23             : using namespace llvm::pdb;
      24             : 
      25             : namespace {
      26           0 : class FunctionArgEnumerator : public IPDBEnumSymbols {
      27             : public:
      28             :   typedef ConcreteSymbolEnumerator<PDBSymbolTypeFunctionArg> ArgEnumeratorType;
      29             : 
      30             :   FunctionArgEnumerator(const IPDBSession &PDBSession,
      31             :                         const PDBSymbolTypeFunctionSig &Sig)
      32           0 :       : Session(PDBSession),
      33           0 :         Enumerator(Sig.findAllChildren<PDBSymbolTypeFunctionArg>()) {}
      34             : 
      35             :   FunctionArgEnumerator(const IPDBSession &PDBSession,
      36             :                         std::unique_ptr<ArgEnumeratorType> ArgEnumerator)
      37           0 :       : Session(PDBSession), Enumerator(std::move(ArgEnumerator)) {}
      38             : 
      39           0 :   uint32_t getChildCount() const override {
      40           0 :     return Enumerator->getChildCount();
      41             :   }
      42             : 
      43           0 :   std::unique_ptr<PDBSymbol> getChildAtIndex(uint32_t Index) const override {
      44           0 :     auto FunctionArgSymbol = Enumerator->getChildAtIndex(Index);
      45           0 :     if (!FunctionArgSymbol)
      46             :       return nullptr;
      47           0 :     return Session.getSymbolById(FunctionArgSymbol->getTypeId());
      48             :   }
      49             : 
      50           0 :   std::unique_ptr<PDBSymbol> getNext() override {
      51           0 :     auto FunctionArgSymbol = Enumerator->getNext();
      52           0 :     if (!FunctionArgSymbol)
      53             :       return nullptr;
      54           0 :     return Session.getSymbolById(FunctionArgSymbol->getTypeId());
      55             :   }
      56             : 
      57           0 :   void reset() override { Enumerator->reset(); }
      58             : 
      59           0 :   MyType *clone() const override {
      60           0 :     std::unique_ptr<ArgEnumeratorType> Clone(Enumerator->clone());
      61           0 :     return new FunctionArgEnumerator(Session, std::move(Clone));
      62             :   }
      63             : 
      64             : private:
      65             :   const IPDBSession &Session;
      66             :   std::unique_ptr<ArgEnumeratorType> Enumerator;
      67             : };
      68             : }
      69             : 
      70           1 : PDBSymbolTypeFunctionSig::PDBSymbolTypeFunctionSig(
      71           1 :     const IPDBSession &PDBSession, std::unique_ptr<IPDBRawSymbol> Symbol)
      72           3 :     : PDBSymbol(PDBSession, std::move(Symbol)) {
      73             :   assert(RawSymbol->getSymTag() == PDB_SymType::FunctionSig);
      74           1 : }
      75             : 
      76             : std::unique_ptr<IPDBEnumSymbols>
      77           0 : PDBSymbolTypeFunctionSig::getArguments() const {
      78           0 :   return llvm::make_unique<FunctionArgEnumerator>(Session, *this);
      79             : }
      80             : 
      81           0 : void PDBSymbolTypeFunctionSig::dump(PDBSymDumper &Dumper) const {
      82           0 :   Dumper.dump(*this);
      83           0 : }
      84             : 
      85           0 : void PDBSymbolTypeFunctionSig::dumpRight(PDBSymDumper &Dumper) const {
      86           0 :   Dumper.dumpRight(*this);
      87           0 : }
      88             : 
      89           0 : bool PDBSymbolTypeFunctionSig::isCVarArgs() const {
      90           0 :   auto SigArguments = getArguments();
      91           0 :   if (!SigArguments)
      92             :     return false;
      93           0 :   uint32_t NumArgs = SigArguments->getChildCount();
      94           0 :   if (NumArgs == 0)
      95             :     return false;
      96           0 :   auto Last = SigArguments->getChildAtIndex(NumArgs - 1);
      97             :   if (auto Builtin = llvm::dyn_cast_or_null<PDBSymbolTypeBuiltin>(Last.get())) {
      98           0 :     if (Builtin->getBuiltinType() == PDB_BuiltinType::None)
      99             :       return true;
     100             :   }
     101             : 
     102             :   // Note that for a variadic template signature, this method always returns
     103             :   // false since the parameters of the template are specialized.
     104             :   return false;
     105             : }

Generated by: LCOV version 1.13