cppgc: Adds docs to SourceLocation

Bug: chromium:1056170
Change-Id: I89d0fbe6b73bf1b8765bb532fff58b1960fed09a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2235537
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68236}
This commit is contained in:
Michael Lippautz 2020-06-08 19:45:47 +02:00 committed by Commit Bot
parent c9d7b23658
commit a3c0bc572a

View File

@ -23,10 +23,16 @@
namespace cppgc { namespace cppgc {
// Encapsulates source location information. Mimics C++20's /**
// std::source_location. * Encapsulates source location information. Mimics C++20's
* std::source_location.
*/
class V8_EXPORT SourceLocation final { class V8_EXPORT SourceLocation final {
public: public:
/**
* Construct source location information corresponding to the location of the
* call site.
*/
#if CPPGC_SUPPORTS_SOURCE_LOCATION #if CPPGC_SUPPORTS_SOURCE_LOCATION
static constexpr SourceLocation Current( static constexpr SourceLocation Current(
const char* function = __builtin_FUNCTION(), const char* function = __builtin_FUNCTION(),
@ -37,12 +43,38 @@ class V8_EXPORT SourceLocation final {
static constexpr SourceLocation Current() { return SourceLocation(); } static constexpr SourceLocation Current() { return SourceLocation(); }
#endif // CPPGC_SUPPORTS_SOURCE_LOCATION #endif // CPPGC_SUPPORTS_SOURCE_LOCATION
/**
* Constructs unspecified source location information.
*/
constexpr SourceLocation() = default; constexpr SourceLocation() = default;
/**
* Returns the name of the function associated with the position represented
* by this object, if any.
*
* \returns the function name as cstring.
*/
constexpr const char* Function() const { return function_; } constexpr const char* Function() const { return function_; }
/**
* Returns the name of the current source file represented by this object.
*
* \returns the file name as cstring.
*/
constexpr const char* FileName() const { return file_; } constexpr const char* FileName() const { return file_; }
/**
* Returns the line number represented by this object.
*
* \returns the line number.
*/
constexpr size_t Line() const { return line_; } constexpr size_t Line() const { return line_; }
/**
* Returns a human-readable string representing this object.
*
* \returns a human-readable string representing source location information.
*/
std::string ToString() const; std::string ToString() const;
private: private: