LCOV - code coverage report
Current view: top level - lib/Support - SmallVector.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 12 12 100.0 %
Date: 2018-07-13 00:08:38 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             : // Check that no bytes are wasted.
      18             : static_assert(sizeof(SmallVector<void *, 1>) == sizeof(void *) * 4,
      19             :               "wasted space in SmallVector size 1; missing EBO?");
      20             : 
      21             : /// grow_pod - This is an implementation of the grow() method which only works
      22             : /// on POD-like datatypes and is out of line to reduce code duplication.
      23    78932903 : void SmallVectorBase::grow_pod(void *FirstEl, size_t MinSizeInBytes,
      24             :                                size_t TSize) {
      25    78932903 :   size_t CurSizeBytes = size_in_bytes();
      26   157865806 :   size_t NewCapacityInBytes = 2 * capacity_in_bytes() + TSize; // Always grow.
      27    78932903 :   if (NewCapacityInBytes < MinSizeInBytes)
      28             :     NewCapacityInBytes = MinSizeInBytes;
      29             : 
      30             :   void *NewElts;
      31    78932903 :   if (BeginX == FirstEl) {
      32    47500460 :     NewElts = safe_malloc(NewCapacityInBytes);
      33             : 
      34             :     // Copy the elements over.  No need to run dtors on PODs.
      35    47500459 :     memcpy(NewElts, this->BeginX, CurSizeBytes);
      36             :   } else {
      37             :     // If this wasn't grown from the inline copy, grow the allocated space.
      38    31432443 :     NewElts = safe_realloc(this->BeginX, NewCapacityInBytes);
      39             :   }
      40             : 
      41    78932904 :   this->EndX = (char*)NewElts+CurSizeBytes;
      42    78932904 :   this->BeginX = NewElts;
      43    78932904 :   this->CapacityX = (char*)this->BeginX + NewCapacityInBytes;
      44    78932904 : }

Generated by: LCOV version 1.13