lg2: simplify source_location for clang-16
As of clang-16, `source_location` is fully supported, so we do not need
to use the `experimental::source_location` workarounds anymore.
Eliminate them and use `std::source_location` directly rather than the
`lg2::source_location` alias.
Tested: Compiled the repository with CXX=clang++.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Iba987ed9580d228781acac630681fda172a6cef7
diff --git a/lib/lg2_logger.cpp b/lib/lg2_logger.cpp
index a83dcb2..81f085d 100644
--- a/lib/lg2_logger.cpp
+++ b/lib/lg2_logger.cpp
@@ -10,19 +10,9 @@
#include <cstdarg>
#include <cstdio>
#include <iostream>
+#include <source_location>
#include <vector>
-// Clang doesn't currently support source_location, but in order to provide
-// support for compiling an application with Clang while lg2 was compiled with
-// GCC we need to provide compile support *both* source_location and
-// experimental::source_location.
-//
-// Note: The experimental::source_location code will turn into a no-op for
-// simplicity. This is simply to allow compilation.
-#if __has_builtin(__builtin_source_location)
-#include <experimental/source_location>
-#endif
-
namespace lg2::details
{
/** Convert unsigned to string using format flags. */
@@ -137,12 +127,12 @@
static constexpr size_t static_locs = pos_func + 1;
/** No-op output of a message. */
-static void noop_extra_output(level, const lg2::source_location&,
+static void noop_extra_output(level, const std::source_location&,
const std::string&)
{}
/** std::cerr output of a message. */
-static void cerr_extra_output(level l, const lg2::source_location& s,
+static void cerr_extra_output(level l, const std::source_location& s,
const std::string& m)
{
static const char* const defaultFormat = []() {
@@ -215,7 +205,7 @@
: noop_extra_output;
// Do_log implementation.
-void do_log(level l, const lg2::source_location& s, const char* m, ...)
+void do_log(level l, const std::source_location& s, const char* m, ...)
{
using namespace std::string_literals;
@@ -304,14 +294,4 @@
extra_output_method(l, s, message);
}
-// If std::source_location is supported, provide an additional
-// std::experimental::source_location implementation that does nothing so that
-// lg2 users can compile with Clang even if lg2 was compiled with GCC. This
-// is a no-op implementation that simply allows compile support since some
-// people like to compile with Clang for additional / stricter checks.
-#if __has_builtin(__builtin_source_location)
-void do_log(level, const std::experimental::source_location&, const char*, ...)
-{}
-#endif
-
} // namespace lg2::details