Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Support/BuryPointer.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- BuryPointer.cpp - Memory Manipulation/Leak ---------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include "llvm/Support/BuryPointer.h"
10
#include "llvm/Support/Compiler.h"
11
#include <atomic>
12
13
namespace llvm {
14
15
84.4k
void BuryPointer(const void *Ptr) {
16
84.4k
  // This function may be called only a small fixed amount of times per each
17
84.4k
  // invocation, otherwise we do actually have a leak which we want to report.
18
84.4k
  // If this function is called more than kGraveYardMaxSize times, the pointers
19
84.4k
  // will not be properly buried and a leak detector will report a leak, which
20
84.4k
  // is what we want in such case.
21
84.4k
  static const size_t kGraveYardMaxSize = 16;
22
84.4k
  LLVM_ATTRIBUTE_UNUSED static const void *GraveYard[kGraveYardMaxSize];
23
84.4k
  static std::atomic<unsigned> GraveYardSize;
24
84.4k
  unsigned Idx = GraveYardSize++;
25
84.4k
  if (Idx >= kGraveYardMaxSize)
26
0
    return;
27
84.4k
  GraveYard[Idx] = Ptr;
28
84.4k
}
29
30
}