LCOV - code coverage report
Current view: top level - lib/Support - SmallVector.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 15 17 88.2 %
Date: 2017-09-14 15:23:50 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- llvm/ADT/SmallVector.cpp - 'Normally small' vectors ----------------===//
       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             : // This file implements the SmallVector class.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #include "llvm/ADT/SmallVector.h"
      15             : using namespace llvm;
      16             : 
      17             : /// grow_pod - This is an implementation of the grow() method which only works
      18             : /// on POD-like datatypes and is out of line to reduce code duplication.
      19    71583872 : void SmallVectorBase::grow_pod(void *FirstEl, size_t MinSizeInBytes,
      20             :                                size_t TSize) {
      21   143167744 :   size_t CurSizeBytes = size_in_bytes();
      22   143167744 :   size_t NewCapacityInBytes = 2 * capacity_in_bytes() + TSize; // Always grow.
      23    71583872 :   if (NewCapacityInBytes < MinSizeInBytes)
      24     7913334 :     NewCapacityInBytes = MinSizeInBytes;
      25             : 
      26             :   void *NewElts;
      27    71583872 :   if (BeginX == FirstEl) {
      28    40824921 :     NewElts = malloc(NewCapacityInBytes);
      29    40824921 :     if (NewElts == nullptr)
      30           0 :       report_bad_alloc_error("Allocation of SmallVector element failed.");
      31             : 
      32             :     // Copy the elements over.  No need to run dtors on PODs.
      33    40824923 :     memcpy(NewElts, this->BeginX, CurSizeBytes);
      34             :   } else {
      35             :     // If this wasn't grown from the inline copy, grow the allocated space.
      36    30758951 :     NewElts = realloc(this->BeginX, NewCapacityInBytes);
      37    30758951 :     if (NewElts == nullptr)
      38           0 :       report_bad_alloc_error("Reallocation of SmallVector element failed.");
      39             :   }
      40             : 
      41    71583874 :   this->EndX = (char*)NewElts+CurSizeBytes;
      42    71583874 :   this->BeginX = NewElts;
      43    71583874 :   this->CapacityX = (char*)this->BeginX + NewCapacityInBytes;
      44    71583874 : }

Generated by: LCOV version 1.13