LCOV - code coverage report
Current view: top level - src - source_location.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 9 17 52.9 %
Date: 2026-06-25 07:23:43 Functions: 3 7 42.9 %

          Line data    Source code
       1             : // Copyright (c) 2023 The Dash Core developers
       2             : // Distributed under the MIT software license, see the accompanying
       3             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4             : // Originally from https://github.com/paweldac/source_location
       5             : 
       6             : #ifndef BITCOIN_SOURCE_LOCATION_H
       7             : #define BITCOIN_SOURCE_LOCATION_H
       8             : 
       9             : #pragma once
      10             : 
      11             : #include <cstdint>
      12             : 
      13             : namespace nostd {
      14             :     struct source_location {
      15             :     public:
      16             : #if defined(__clang__) and (__clang_major__ >= 9)
      17    21617078 :         static constexpr source_location current(const char* fileName = __builtin_FILE(),
      18             :         const char* functionName = __builtin_FUNCTION(),
      19             :         const uint_least32_t lineNumber = __builtin_LINE(),
      20             :         const uint_least32_t columnOffset = __builtin_COLUMN()) noexcept
      21             : #elif defined(__GNUC__) and (__GNUC__ > 4 or (__GNUC__ == 4 and __GNUC_MINOR__ >= 8))
      22             :         static constexpr source_location current(const char* fileName = __builtin_FILE(),
      23             :         const char* functionName = __builtin_FUNCTION(),
      24             :         const uint_least32_t lineNumber = __builtin_LINE(),
      25             :         const uint_least32_t columnOffset = 0) noexcept
      26             : #else
      27             :         static constexpr source_location current(const char* fileName = "unsupported",
      28             :                                                  const char* functionName = "unsupported",
      29             :                                                  const uint_least32_t lineNumber = 0,
      30             :                                                  const uint_least32_t columnOffset = 0) noexcept
      31             : #endif
      32             :         {
      33    21617078 :             return source_location(fileName, functionName, lineNumber, columnOffset);
      34             :         }
      35             : 
      36             :         source_location(const source_location&) = default;
      37             :         source_location(source_location&&) = default;
      38             : 
      39           0 :         constexpr const char* file_name() const noexcept
      40             :         {
      41           0 :             return fileName;
      42             :         }
      43             : 
      44           0 :         constexpr const char* function_name() const noexcept
      45             :         {
      46           0 :             return functionName;
      47             :         }
      48             : 
      49           0 :         constexpr uint_least32_t line() const noexcept
      50             :         {
      51           0 :             return lineNumber;
      52             :         }
      53             : 
      54           0 :         constexpr std::uint_least32_t column() const noexcept
      55             :         {
      56           0 :             return columnOffset;
      57             :         }
      58             : 
      59             :     private:
      60    43234137 :         constexpr source_location(const char* fileName, const char* functionName, const uint_least32_t lineNumber,
      61             :                                   const uint_least32_t columnOffset) noexcept
      62    21617067 :                 : fileName(fileName)
      63    21617067 :                 , functionName(functionName)
      64    21617067 :                 , lineNumber(lineNumber)
      65    21617067 :                 , columnOffset(columnOffset)
      66    21617070 :         {
      67    43234137 :         }
      68             : 
      69             :         const char* fileName;
      70             :         const char* functionName;
      71             :         const std::uint_least32_t lineNumber;
      72             :         const std::uint_least32_t columnOffset;
      73             :     };
      74             : } // namespace nostd
      75             : 
      76             : #endif // BITCOIN_SOURCE_LOCATION_H

Generated by: LCOV version 1.16