LCOV - code coverage report
Current view: top level - lib/DebugInfo/PDB - PDBSymbolFunc.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 4 40 10.0 %
Date: 2017-09-14 15:23:50 Functions: 1 12 8.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- PDBSymbolFunc.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/PDBSymbolFunc.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/PDBSymbolData.h"
      17             : #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
      18             : #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
      19             : #include "llvm/DebugInfo/PDB/PDBTypes.h"
      20             : 
      21             : #include <unordered_set>
      22             : #include <utility>
      23             : #include <vector>
      24             : 
      25             : using namespace llvm;
      26             : using namespace llvm::pdb;
      27             : 
      28             : namespace {
      29           0 : class FunctionArgEnumerator : public IPDBEnumChildren<PDBSymbolData> {
      30             : public:
      31             :   typedef ConcreteSymbolEnumerator<PDBSymbolData> ArgEnumeratorType;
      32             : 
      33           0 :   FunctionArgEnumerator(const IPDBSession &PDBSession,
      34             :                         const PDBSymbolFunc &PDBFunc)
      35           0 :       : Session(PDBSession), Func(PDBFunc) {
      36             :     // Arguments can appear multiple times if they have live range
      37             :     // information, so we only take the first occurrence.
      38           0 :     std::unordered_set<std::string> SeenNames;
      39           0 :     auto DataChildren = Func.findAllChildren<PDBSymbolData>();
      40           0 :     while (auto Child = DataChildren->getNext()) {
      41           0 :       if (Child->getDataKind() == PDB_DataKind::Param) {
      42           0 :         std::string Name = Child->getName();
      43           0 :         if (SeenNames.find(Name) != SeenNames.end())
      44           0 :           continue;
      45           0 :         Args.push_back(std::move(Child));
      46           0 :         SeenNames.insert(Name);
      47             :       }
      48             :     }
      49           0 :     reset();
      50           0 :   }
      51             : 
      52           0 :   uint32_t getChildCount() const override { return Args.size(); }
      53             : 
      54             :   std::unique_ptr<PDBSymbolData>
      55           0 :   getChildAtIndex(uint32_t Index) const override {
      56           0 :     if (Index >= Args.size())
      57             :       return nullptr;
      58             : 
      59           0 :     return Session.getConcreteSymbolById<PDBSymbolData>(
      60           0 :         Args[Index]->getSymIndexId());
      61             :   }
      62             : 
      63           0 :   std::unique_ptr<PDBSymbolData> getNext() override {
      64           0 :     if (CurIter == Args.end())
      65             :       return nullptr;
      66           0 :     const auto &Result = **CurIter;
      67           0 :     ++CurIter;
      68           0 :     return Session.getConcreteSymbolById<PDBSymbolData>(Result.getSymIndexId());
      69             :   }
      70             : 
      71           0 :   void reset() override { CurIter = Args.empty() ? Args.end() : Args.begin(); }
      72             : 
      73           0 :   FunctionArgEnumerator *clone() const override {
      74           0 :     return new FunctionArgEnumerator(Session, Func);
      75             :   }
      76             : 
      77             : private:
      78             :   typedef std::vector<std::unique_ptr<PDBSymbolData>> ArgListType;
      79             :   const IPDBSession &Session;
      80             :   const PDBSymbolFunc &Func;
      81             :   ArgListType Args;
      82             :   ArgListType::const_iterator CurIter;
      83             : };
      84             : }
      85             : 
      86           1 : PDBSymbolFunc::PDBSymbolFunc(const IPDBSession &PDBSession,
      87           1 :                              std::unique_ptr<IPDBRawSymbol> Symbol)
      88           3 :     : PDBSymbol(PDBSession, std::move(Symbol)) {
      89             :   assert(RawSymbol->getSymTag() == PDB_SymType::Function);
      90           1 : }
      91             : 
      92             : std::unique_ptr<IPDBEnumChildren<PDBSymbolData>>
      93           0 : PDBSymbolFunc::getArguments() const {
      94           0 :   return llvm::make_unique<FunctionArgEnumerator>(Session, *this);
      95             : }
      96             : 
      97           0 : void PDBSymbolFunc::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); }
      98             : 
      99           0 : bool PDBSymbolFunc::isDestructor() const {
     100           0 :   std::string Name = getName();
     101           0 :   if (Name.empty())
     102             :     return false;
     103           0 :   if (Name[0] == '~')
     104             :     return true;
     105           0 :   if (Name == "__vecDelDtor")
     106             :     return true;
     107           0 :   return false;
     108             : }

Generated by: LCOV version 1.13