LCOV - code coverage report
Current view: top level - lib/Support - Valgrind.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 4 4 100.0 %
Date: 2018-10-20 13:21:21 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- Valgrind.cpp - Implement Valgrind communication ---------*- 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             : //  Defines Valgrind communication methods, if HAVE_VALGRIND_VALGRIND_H is
      11             : //  defined.  If we have valgrind.h but valgrind isn't running, its macros are
      12             : //  no-ops.
      13             : //
      14             : //===----------------------------------------------------------------------===//
      15             : 
      16             : #include "llvm/Support/Valgrind.h"
      17             : #include "llvm/Config/config.h"
      18             : #include <cstddef>
      19             : 
      20             : #if HAVE_VALGRIND_VALGRIND_H
      21             : #include <valgrind/valgrind.h>
      22             : 
      23             : static bool InitNotUnderValgrind() {
      24             :   return !RUNNING_ON_VALGRIND;
      25             : }
      26             : 
      27             : // This bool is negated from what we'd expect because code may run before it
      28             : // gets initialized.  If that happens, it will appear to be 0 (false), and we
      29             : // want that to cause the rest of the code in this file to run the
      30             : // Valgrind-provided macros.
      31             : static const bool NotUnderValgrind = InitNotUnderValgrind();
      32             : 
      33             : bool llvm::sys::RunningOnValgrind() {
      34             :   if (NotUnderValgrind)
      35             :     return false;
      36             :   return RUNNING_ON_VALGRIND;
      37             : }
      38             : 
      39             : void llvm::sys::ValgrindDiscardTranslations(const void *Addr, size_t Len) {
      40             :   if (NotUnderValgrind)
      41             :     return;
      42             : 
      43             :   VALGRIND_DISCARD_TRANSLATIONS(Addr, Len);
      44             : }
      45             : 
      46             : #else  // !HAVE_VALGRIND_VALGRIND_H
      47             : 
      48          11 : bool llvm::sys::RunningOnValgrind() {
      49          11 :   return false;
      50             : }
      51             : 
      52         892 : void llvm::sys::ValgrindDiscardTranslations(const void *Addr, size_t Len) {
      53         892 : }
      54             : 
      55             : #endif  // !HAVE_VALGRIND_VALGRIND_H

Generated by: LCOV version 1.13