-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e9e1d2
commit 262846a
Showing
4 changed files
with
107 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// | ||
// Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// Copyright (c) 2023 Krystian Stasiowski ([email protected]) | ||
// | ||
// Official repository: https://github.com/cppalliance/mrdox | ||
// | ||
|
||
#ifndef MRDOX_API_SUPPORT_SOURCE_LOCATION_HPP | ||
#define MRDOX_API_SUPPORT_SOURCE_LOCATION_HPP | ||
|
||
#include <version> | ||
|
||
#if __cpp_lib_source_location >= 201907L && \ | ||
__has_include(<source_location>) | ||
#include <source_location> | ||
|
||
namespace clang { | ||
namespace mrdox { | ||
|
||
using std::source_location; | ||
|
||
} // mrdox | ||
} // clang | ||
#else | ||
#include <cstdint> | ||
|
||
namespace clang { | ||
namespace mrdox { | ||
|
||
struct source_location | ||
{ | ||
static | ||
constexpr | ||
source_location | ||
current( | ||
const char* const file = __builtin_FILE(), | ||
const char* const function = __builtin_FUNCTION(), | ||
const std::uint_least32_t line = __builtin_LINE(), | ||
const std::uint_least32_t column = __builtin_COLUMN()) noexcept | ||
|
||
{ | ||
source_location result; | ||
result.file_ = file; | ||
result.function_ = function; | ||
result.line_ = line; | ||
result.column_ = column; | ||
return result; | ||
} | ||
|
||
constexpr | ||
const char* | ||
file_name() const noexcept | ||
{ | ||
return file_; | ||
} | ||
constexpr | ||
const char* | ||
function_name() const noexcept | ||
{ | ||
return function_; | ||
} | ||
|
||
constexpr | ||
std::uint_least32_t | ||
line() const noexcept | ||
{ | ||
return line_; | ||
} | ||
constexpr | ||
std::uint_least32_t | ||
column() const noexcept | ||
{ | ||
return column_; | ||
} | ||
|
||
private: | ||
const char* file_ = ""; | ||
const char* function_ = ""; | ||
std::uint_least32_t line_ = 0; | ||
std::uint_least32_t column_ = 0; | ||
}; | ||
|
||
} // mrdox | ||
} // clang | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters