Implement value printing for std::source_location

This commit is contained in:
Devajith Valaparambil Sreeramaswamy 2023-12-12 10:25:26 +01:00 committed by jenkins
parent 2f99b68754
commit 254f3d57ad
2 changed files with 28 additions and 0 deletions

View File

@ -17,6 +17,12 @@
#include <cling/Interpreter/Visibility.h>
#include <memory>
#if __cplusplus >= 202002L
#include <version>
#endif
#ifdef __cpp_lib_source_location
#include <source_location>
#endif
#include <string>
#include <tuple>
#include <type_traits>
@ -141,6 +147,11 @@ namespace cling {
return toUTF8(reinterpret_cast<const char * const>(val), N, 1);
}
#ifdef __cpp_lib_source_location
CLING_LIB_EXPORT
std::string printValue(const std::source_location* location);
#endif
// cling::Value
CLING_LIB_EXPORT
std::string printValue(const Value *value);

View File

@ -40,6 +40,12 @@
#include "llvm/Support/Format.h"
#include <locale>
#if __cplusplus >= 202002L
#include <version>
#endif
#ifdef __cpp_lib_source_location
#include <source_location>
#endif
#include <string>
// GCC 4.x doesn't have the proper UTF-8 conversion routines. So use the
@ -575,6 +581,17 @@ namespace cling {
std::string printValue(const wchar_t *Val) {
return toUnicode(Val, 'L', 'x');
}
#ifdef __cpp_lib_source_location
CLING_LIB_EXPORT
std::string printValue(const std::source_location* location) {
cling::ostrstream strm;
strm << location->file_name() << ":" << location->line() << ":"
<< location->function_name();
return strm.str().str();
}
#endif
} // end namespace cling
namespace {