codemaker/source/cppumaker/cpputype.cxx |   21 ++++++++++++---------
 include/comphelper/errcode.hxx          |   26 ++++++++++++++------------
 2 files changed, 26 insertions(+), 21 deletions(-)

New commits:
commit 9c5f597fc80a8a910c1f898556ef2a3226dfe40c
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Oct 3 11:30:34 2023 +0200
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Thu Oct 12 20:59:45 2023 +0200

    use std::source_location instead of std::experimental::source_location
    
    https://en.cppreference.com/w/cpp/compiler_support says that this is
    supported in
    
      GCC >= 11
      CLANG >= 16
      Visual Studio >= VS 2019 16.10
    
    And our Visual Studio baseline is now 2019.
    
    We still need to make the ifdef conditional check clang, because
    __has_include will happily return true even if the current clang
    does not support the necessary builtins.
    
    Change-Id: I5f2743e204b8ed22d4651053f3ae579a4a192a45
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157515
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/codemaker/source/cppumaker/cpputype.cxx 
b/codemaker/source/cppumaker/cpputype.cxx
index 47b3d8f488a5..235e55017610 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -3013,13 +3013,16 @@ void ExceptionType::dumpHdlFile(
 {
     if (name_ == "com.sun.star.uno.Exception")
     {
-        // LIBO_INTERNAL_ONLY implies GCC >= 7, which we need for this
-        // libstdc++ header.
-        includes.addCustom("#if defined LIBO_INTERNAL_ONLY && (defined 
__GNUC__ || defined __clang__) && 
__has_include(<experimental/source_location>)");
-        includes.addCustom("#define LIBO_USE_SOURCE_LOCATION");
+        includes.addCustom("#if defined(LIBO_INTERNAL_ONLY)");
+        includes.addCustom("#if defined(__cpp_lib_source_location) && 
__cpp_lib_source_location >= 201907");
+        includes.addCustom("#include <source_location>");
+        includes.addCustom("#define LIBO_USE_SOURCE_LOCATION std");
+        includes.addCustom("#elif 
__has_include(<experimental/source_location>)");
+        includes.addCustom("#include <experimental/source_location>");
+        includes.addCustom("#define LIBO_USE_SOURCE_LOCATION 
std::experimental");
+        includes.addCustom("#endif");
         includes.addCustom("#endif");
         includes.addCustom("#if defined LIBO_USE_SOURCE_LOCATION");
-        includes.addCustom("#include <experimental/source_location>");
         includes.addCustom("#include <o3tl/runtimetooustring.hxx>");
         includes.addCustom("#endif");
     }
@@ -3059,7 +3062,7 @@ void ExceptionType::dumpHppFile(
     // default constructor
     out << "\ninline " << id_ << "::" << id_ << "(\n";
     out << "#if defined LIBO_USE_SOURCE_LOCATION\n";
-    out << "    std::experimental::source_location location\n";
+    out << "    LIBO_USE_SOURCE_LOCATION::source_location location\n";
     out << "#endif\n";
     out << "    )\n";
     inc();
@@ -3114,7 +3117,7 @@ void ExceptionType::dumpHppFile(
             bFirst = false;
         }
         out << "\n#if defined LIBO_USE_SOURCE_LOCATION\n";
-        out << "    " << (bFirst ? "" : ", ") << 
"std::experimental::source_location location\n";
+        out << "    " << (bFirst ? "" : ", ") << 
"LIBO_USE_SOURCE_LOCATION::source_location location\n";
         out << "#endif\n";
         out << ")\n";
         inc();
@@ -3375,7 +3378,7 @@ void ExceptionType::dumpDeclaration(FileStream & out)
     // default constructor
     out << indent() << "inline CPPU_GCC_DLLPRIVATE " << id_ << "(\n";
     out << "#if defined LIBO_USE_SOURCE_LOCATION\n";
-    out << "    std::experimental::source_location location = 
std::experimental::source_location::current()\n";
+    out << "    LIBO_USE_SOURCE_LOCATION::source_location location = 
LIBO_USE_SOURCE_LOCATION::source_location::current()\n";
     out << "#endif\n\n";
     out << "    );\n";
 
@@ -3393,7 +3396,7 @@ void ExceptionType::dumpDeclaration(FileStream & out)
             bFirst = false;
         }
         out << "\n#if defined LIBO_USE_SOURCE_LOCATION\n";
-        out << ", std::experimental::source_location location = 
std::experimental::source_location::current()\n";
+        out << ", LIBO_USE_SOURCE_LOCATION::source_location location = 
LIBO_USE_SOURCE_LOCATION::source_location::current()\n";
         out << "#endif\n";
         out << "    );\n\n";
     }
diff --git a/include/comphelper/errcode.hxx b/include/comphelper/errcode.hxx
index 3d3773fadf50..567400f101f8 100644
--- a/include/comphelper/errcode.hxx
+++ b/include/comphelper/errcode.hxx
@@ -24,12 +24,14 @@
 #include <o3tl/typed_flags_set.hxx>
 #include <optional>
 
-#if (defined DBG_UTIL) && ((defined __GNUC__ && !defined __clang__) || 
(defined __clang__ && __clang_major__ >= 9)) && 
__has_include(<experimental/source_location>)
-#define LIBO_ERRMSG_USE_SOURCE_LOCATION
-#endif
-
-#ifdef LIBO_ERRMSG_USE_SOURCE_LOCATION
+#if defined(DBG_UTIL)
+#if defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907
+#include <source_location>
+#define LIBO_ERRMSG_USE_SOURCE_LOCATION std
+#elif __has_include(<experimental/source_location>)
 #include <experimental/source_location>
+#define LIBO_ERRMSG_USE_SOURCE_LOCATION std::experimental
+#endif
 #endif
 
 /*
@@ -183,15 +185,15 @@ class SAL_WARN_UNUSED ErrCodeMsg
 public:
     ErrCodeMsg() : mnCode(0), mnDialogMask(DialogMask::NONE) {}
 #ifdef LIBO_ERRMSG_USE_SOURCE_LOCATION
-    ErrCodeMsg(ErrCode code, const OUString& arg, 
std::experimental::source_location loc = 
std::experimental::source_location::current())
+    ErrCodeMsg(ErrCode code, const OUString& arg, 
LIBO_ERRMSG_USE_SOURCE_LOCATION::source_location loc = 
LIBO_ERRMSG_USE_SOURCE_LOCATION::source_location::current())
         : mnCode(code), maArg1(arg),  mnDialogMask(DialogMask::NONE), 
moLoc(loc) {}
-    ErrCodeMsg(ErrCode code, const OUString& arg1, const OUString& arg2, 
std::experimental::source_location loc = 
std::experimental::source_location::current())
+    ErrCodeMsg(ErrCode code, const OUString& arg1, const OUString& arg2, 
LIBO_ERRMSG_USE_SOURCE_LOCATION::source_location loc = 
LIBO_ERRMSG_USE_SOURCE_LOCATION::source_location::current())
         : mnCode(code), maArg1(arg1), maArg2(arg2), 
mnDialogMask(DialogMask::NONE), moLoc(loc) {}
-    ErrCodeMsg(ErrCode code, std::experimental::source_location loc = 
std::experimental::source_location::current())
+    ErrCodeMsg(ErrCode code, LIBO_ERRMSG_USE_SOURCE_LOCATION::source_location 
loc = LIBO_ERRMSG_USE_SOURCE_LOCATION::source_location::current())
         : mnCode(code), mnDialogMask(DialogMask::NONE), moLoc(loc) {}
-    ErrCodeMsg(ErrCode code, const OUString& arg, DialogMask mask, 
std::experimental::source_location loc = 
std::experimental::source_location::current())
+    ErrCodeMsg(ErrCode code, const OUString& arg, DialogMask mask, 
LIBO_ERRMSG_USE_SOURCE_LOCATION::source_location loc = 
LIBO_ERRMSG_USE_SOURCE_LOCATION::source_location::current())
         : mnCode(code), maArg1(arg), mnDialogMask(mask), moLoc(loc) {}
-    ErrCodeMsg(ErrCode code, const OUString& arg1, const OUString& arg2, 
DialogMask mask, std::experimental::source_location loc = 
std::experimental::source_location::current())
+    ErrCodeMsg(ErrCode code, const OUString& arg1, const OUString& arg2, 
DialogMask mask, LIBO_ERRMSG_USE_SOURCE_LOCATION::source_location loc = 
LIBO_ERRMSG_USE_SOURCE_LOCATION::source_location::current())
         : mnCode(code), maArg1(arg1), maArg2(arg2), mnDialogMask(mask), 
moLoc(loc) {}
 #else
     ErrCodeMsg(ErrCode code, const OUString& arg)
@@ -212,7 +214,7 @@ public:
     DialogMask GetDialogMask() const { return mnDialogMask; }
 
 #ifdef LIBO_ERRMSG_USE_SOURCE_LOCATION
-    const std::optional<std::experimental::source_location> & 
GetSourceLocation() const { return moLoc; }
+    const std::optional<LIBO_ERRMSG_USE_SOURCE_LOCATION::source_location> & 
GetSourceLocation() const { return moLoc; }
 #endif
 
     /** convert to ERRCODE_NONE if it's a warning, else return the error */
@@ -233,7 +235,7 @@ private:
     OUString maArg2;
     DialogMask mnDialogMask;
 #ifdef LIBO_ERRMSG_USE_SOURCE_LOCATION
-    std::optional<std::experimental::source_location> moLoc;
+    std::optional<LIBO_ERRMSG_USE_SOURCE_LOCATION::source_location> moLoc;
 #endif
 };
 

Reply via email to