From ee704e06b16c3e176a71f980aef714d598031345 Mon Sep 17 00:00:00 2001 From: Daniel Marshall Date: Fri, 28 Oct 2022 08:44:47 +0100 Subject: [PATCH 01/11] Update source_location to use __builtin_FUNCSIG --- stl/inc/source_location | 4 ++ .../tests/P1208R6_source_location/header.h | 4 ++ .../tests/P1208R6_source_location/test.cpp | 60 ++++++++++++++++--- 3 files changed, 59 insertions(+), 9 deletions(-) diff --git a/stl/inc/source_location b/stl/inc/source_location index 411313a20c..3b58c12509 100644 --- a/stl/inc/source_location +++ b/stl/inc/source_location @@ -25,7 +25,11 @@ _STD_BEGIN _EXPORT_STD struct source_location { _NODISCARD static consteval source_location current(const uint_least32_t _Line_ = __builtin_LINE(), const uint_least32_t _Column_ = __builtin_COLUMN(), const char* const _File_ = __builtin_FILE(), +#ifdef __clang__ const char* const _Function_ = __builtin_FUNCTION()) noexcept { +#else + const char* const _Function_ = __builtin_FUNCSIG()) noexcept { +#endif source_location _Result{}; _Result._Line = _Line_; _Result._Column = _Column_; diff --git a/tests/std/tests/P1208R6_source_location/header.h b/tests/std/tests/P1208R6_source_location/header.h index a16d321ee6..1d7ef57182 100644 --- a/tests/std/tests/P1208R6_source_location/header.h +++ b/tests/std/tests/P1208R6_source_location/header.h @@ -11,6 +11,10 @@ constexpr void header_test() { const auto x = source_location::current(); assert(x.line() == __LINE__ - 1); assert(x.column() == 37); +#ifdef __clang__ assert(x.function_name() == "header_test"sv); +#else + assert(x.function_name() == "void __cdecl header_test(void)"sv); +#endif assert(string_view{x.file_name()}.ends_with("header.h"sv)); } diff --git a/tests/std/tests/P1208R6_source_location/test.cpp b/tests/std/tests/P1208R6_source_location/test.cpp index 23bae2090a..bd174ded20 100644 --- a/tests/std/tests/P1208R6_source_location/test.cpp +++ b/tests/std/tests/P1208R6_source_location/test.cpp @@ -50,7 +50,11 @@ constexpr void local_test() { const auto x = source_location::current(); assert(x.line() == __LINE__ - 1); assert(x.column() == 37); +#ifdef __clang__ // TRANSITION ??? assert(x.function_name() == "local_test"sv); +#else + assert(x.function_name() == "void __cdecl local_test(void)"sv); +#endif assert(string_view{x.file_name()}.ends_with(test_cpp)); } @@ -58,7 +62,11 @@ constexpr void argument_test( const unsigned int line, const unsigned int column, const source_location x = source_location::current()) { assert(x.line() == line); assert(x.column() == column); +#ifdef __clang__ assert(x.function_name() == "test"sv); +#else + assert(x.function_name() == "bool __cdecl test(void)"sv); +#endif assert(string_view{x.file_name()}.ends_with(test_cpp)); } @@ -67,9 +75,13 @@ constexpr void sloc_constructor_test() { assert(x.loc.line() == __LINE__ - 1); assert(x.loc.column() == 13); if (is_constant_evaluated()) { - assert(x.loc.function_name() == "main"sv); // TRANSITION, VSO-1285783 + assert(x.loc.function_name() == "int __cdecl main(void)"sv); // TRANSITION, VSO-1285783 } else { +#ifdef __clang__ assert(x.loc.function_name() == "sloc_constructor_test"sv); +#else + assert(x.loc.function_name() == "void __cdecl sloc_constructor_test(void)"sv); +#endif } assert(string_view{x.loc.file_name()}.ends_with(test_cpp)); } @@ -78,7 +90,11 @@ constexpr void different_constructor_test() { const s x{1}; assert(x.loc.line() == s_int_line); assert(x.loc.column() == 5); +#ifdef __clang__ assert(x.loc.function_name() == "s"sv); +#else + assert(x.loc.function_name() == "__cdecl s::s(int)"sv); +#endif assert(string_view{x.loc.file_name()}.ends_with(test_cpp)); } @@ -87,26 +103,44 @@ constexpr void sub_member_test() { assert(s.x.loc.line() == __LINE__ - 1); assert(s.x.loc.column() == 14); if (is_constant_evaluated()) { - assert(s.x.loc.function_name() == "main"sv); // TRANSITION, VSO-1285783 + assert(s.x.loc.function_name() == "int __cdecl main(void)"sv); // TRANSITION, VSO-1285783 } else { +#ifdef __clang__ assert(s.x.loc.function_name() == "sub_member_test"sv); +#else + assert(s.x.loc.function_name() == "void __cdecl sub_member_test(void)"sv); +#endif } assert(string_view{s.x.loc.file_name()}.ends_with(test_cpp)); const s2 s_i{1}; assert(s_i.x.loc.line() == s2_int_line); assert(s_i.x.loc.column() == 5); +#ifdef __clang__ assert(s_i.x.loc.function_name() == "s2"sv); +#else + assert(s_i.x.loc.function_name() == "__cdecl s2::s2(int)"sv); +#endif assert(string_view{s_i.x.loc.file_name()}.ends_with(test_cpp)); } constexpr void lambda_test() { - const auto l = [loc = source_location::current()] { return loc; }; - const auto x = l(); - assert(x.line() == __LINE__ - 2); - assert(x.column() == 51); - assert(x.function_name() == "lambda_test"sv); - assert(string_view{x.file_name()}.ends_with(test_cpp)); + const auto x1 = [loc = source_location::current()] { return loc; }(); + const auto x2 = [] { return source_location::current(); }(); + assert(x1.line() == __LINE__ - 2); + assert(x2.line() == __LINE__ - 2); + assert(x1.column() == 52); + assert(x2.column() == 50); +#ifdef __clang__ + assert(x1.function_name() == "lambda_test"sv); + assert(x2.function_name() == "lambda_test"sv); +#else + assert(x1.function_name() == "void __cdecl lambda_test(void)"sv); + assert(string_view{x2.function_name()}.starts_with("struct std::source_location __cdecl lambda_test:: @@ -118,13 +152,21 @@ constexpr void function_template_test() { const auto x1 = function_template(); assert(x1.line() == __LINE__ - 5); assert(x1.column() == 29); +#ifdef __clang__ assert(x1.function_name() == "function_template"sv); +#else + assert(x1.function_name() == "struct std::source_location __cdecl function_template(void)"sv); +#endif assert(string_view{x1.file_name()}.ends_with(test_cpp)); const auto x2 = function_template(); assert(x1.line() == x2.line()); assert(x1.column() == x2.column()); - assert(string_view{x1.function_name()} == string_view{x2.function_name()}); +#ifdef __clang__ + assert(x2.function_name() == "function_template"sv); +#else + assert(x2.function_name() == "struct std::source_location __cdecl function_template(void)"sv); +#endif assert(string_view{x1.file_name()} == string_view{x2.file_name()}); } From 2ef2cbaf688477bc79854e1b6a2282f3de83491e Mon Sep 17 00:00:00 2001 From: Daniel Marshall Date: Sat, 12 Nov 2022 09:46:41 +0000 Subject: [PATCH 02/11] `x2.function_name()` should be `operator()`. TRANSITION Also TRANSITION (might be too much TRANSITION) --- stl/inc/source_location | 6 +-- .../tests/P1208R6_source_location/header.h | 6 +-- .../tests/P1208R6_source_location/test.cpp | 54 +++++++++---------- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/stl/inc/source_location b/stl/inc/source_location index 3b58c12509..eca4d5af4e 100644 --- a/stl/inc/source_location +++ b/stl/inc/source_location @@ -25,11 +25,11 @@ _STD_BEGIN _EXPORT_STD struct source_location { _NODISCARD static consteval source_location current(const uint_least32_t _Line_ = __builtin_LINE(), const uint_least32_t _Column_ = __builtin_COLUMN(), const char* const _File_ = __builtin_FILE(), -#ifdef __clang__ +#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 const char* const _Function_ = __builtin_FUNCTION()) noexcept { -#else +#else // ^^^ workaround no workaround vvv const char* const _Function_ = __builtin_FUNCSIG()) noexcept { -#endif +#endif // TRANSITION, DevCom-10199227 and LLVM-58951 source_location _Result{}; _Result._Line = _Line_; _Result._Column = _Column_; diff --git a/tests/std/tests/P1208R6_source_location/header.h b/tests/std/tests/P1208R6_source_location/header.h index 1d7ef57182..9572f7b43a 100644 --- a/tests/std/tests/P1208R6_source_location/header.h +++ b/tests/std/tests/P1208R6_source_location/header.h @@ -11,10 +11,10 @@ constexpr void header_test() { const auto x = source_location::current(); assert(x.line() == __LINE__ - 1); assert(x.column() == 37); -#ifdef __clang__ +#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x.function_name() == "header_test"sv); -#else +#else // ^^^ workaround no workaround vvv assert(x.function_name() == "void __cdecl header_test(void)"sv); -#endif +#endif // TRANSITION, DevCom-10199227 and LLVM-58951 assert(string_view{x.file_name()}.ends_with("header.h"sv)); } diff --git a/tests/std/tests/P1208R6_source_location/test.cpp b/tests/std/tests/P1208R6_source_location/test.cpp index bd174ded20..341da78edb 100644 --- a/tests/std/tests/P1208R6_source_location/test.cpp +++ b/tests/std/tests/P1208R6_source_location/test.cpp @@ -50,11 +50,11 @@ constexpr void local_test() { const auto x = source_location::current(); assert(x.line() == __LINE__ - 1); assert(x.column() == 37); -#ifdef __clang__ // TRANSITION ??? +#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x.function_name() == "local_test"sv); -#else +#else // ^^^ workaround // workaround vvv assert(x.function_name() == "void __cdecl local_test(void)"sv); -#endif +#endif // TRANSITION, DevCom-10199227 and LLVM-58951 assert(string_view{x.file_name()}.ends_with(test_cpp)); } @@ -62,11 +62,11 @@ constexpr void argument_test( const unsigned int line, const unsigned int column, const source_location x = source_location::current()) { assert(x.line() == line); assert(x.column() == column); -#ifdef __clang__ +#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x.function_name() == "test"sv); -#else +#else // ^^^ workaround // workaround vvv assert(x.function_name() == "bool __cdecl test(void)"sv); -#endif +#endif // TRANSITION, DevCom-10199227 and LLVM-58951 assert(string_view{x.file_name()}.ends_with(test_cpp)); } @@ -77,11 +77,11 @@ constexpr void sloc_constructor_test() { if (is_constant_evaluated()) { assert(x.loc.function_name() == "int __cdecl main(void)"sv); // TRANSITION, VSO-1285783 } else { -#ifdef __clang__ +#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x.loc.function_name() == "sloc_constructor_test"sv); -#else +#else // ^^^ workaround // workaround vvv assert(x.loc.function_name() == "void __cdecl sloc_constructor_test(void)"sv); -#endif +#endif // TRANSITION, DevCom-10199227 and LLVM-58951 } assert(string_view{x.loc.file_name()}.ends_with(test_cpp)); } @@ -90,11 +90,11 @@ constexpr void different_constructor_test() { const s x{1}; assert(x.loc.line() == s_int_line); assert(x.loc.column() == 5); -#ifdef __clang__ +#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x.loc.function_name() == "s"sv); -#else +#else // ^^^ workaround // workaround vvv assert(x.loc.function_name() == "__cdecl s::s(int)"sv); -#endif +#endif // TRANSITION, DevCom-10199227 and LLVM-58951 assert(string_view{x.loc.file_name()}.ends_with(test_cpp)); } @@ -105,22 +105,22 @@ constexpr void sub_member_test() { if (is_constant_evaluated()) { assert(s.x.loc.function_name() == "int __cdecl main(void)"sv); // TRANSITION, VSO-1285783 } else { -#ifdef __clang__ +#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 assert(s.x.loc.function_name() == "sub_member_test"sv); -#else +#else // ^^^ workaround // workaround vvv assert(s.x.loc.function_name() == "void __cdecl sub_member_test(void)"sv); -#endif +#endif // TRANSITION, DevCom-10199227 and LLVM-58951 } assert(string_view{s.x.loc.file_name()}.ends_with(test_cpp)); const s2 s_i{1}; assert(s_i.x.loc.line() == s2_int_line); assert(s_i.x.loc.column() == 5); -#ifdef __clang__ +#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 assert(s_i.x.loc.function_name() == "s2"sv); #else assert(s_i.x.loc.function_name() == "__cdecl s2::s2(int)"sv); -#endif +#endif // TRANSITION, DevCom-10199227 and LLVM-58951 assert(string_view{s_i.x.loc.file_name()}.ends_with(test_cpp)); } @@ -131,14 +131,14 @@ constexpr void lambda_test() { assert(x2.line() == __LINE__ - 2); assert(x1.column() == 52); assert(x2.column() == 50); -#ifdef __clang__ +#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x1.function_name() == "lambda_test"sv); - assert(x2.function_name() == "lambda_test"sv); -#else + assert(x2.function_name() == "operator()"sv); +#else // ^^^ workaround // workaround vvv assert(x1.function_name() == "void __cdecl lambda_test(void)"sv); assert(string_view{x2.function_name()}.starts_with("struct std::source_location __cdecl lambda_test::(); assert(x1.line() == __LINE__ - 5); assert(x1.column() == 29); -#ifdef __clang__ +#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x1.function_name() == "function_template"sv); -#else +#else // ^^^ workaround // workaround vvv assert(x1.function_name() == "struct std::source_location __cdecl function_template(void)"sv); -#endif +#endif // TRANSITION, DevCom-10199227 and LLVM-58951 assert(string_view{x1.file_name()}.ends_with(test_cpp)); const auto x2 = function_template(); assert(x1.line() == x2.line()); assert(x1.column() == x2.column()); -#ifdef __clang__ +#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x2.function_name() == "function_template"sv); -#else +#else // ^^^ workaround // workaround vvv assert(x2.function_name() == "struct std::source_location __cdecl function_template(void)"sv); -#endif +#endif // TRANSITION, DevCom-10199227 and LLVM-58951 assert(string_view{x1.file_name()} == string_view{x2.file_name()}); } From 3bbb96113900dcc0a74db40ec7090b7b33888287 Mon Sep 17 00:00:00 2001 From: Daniel Marshall Date: Sat, 12 Nov 2022 10:14:19 +0000 Subject: [PATCH 03/11] Fix test and restore a comment --- tests/std/include/test_header_units_and_modules.hpp | 4 ++++ tests/std/tests/P1208R6_source_location/test.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/std/include/test_header_units_and_modules.hpp b/tests/std/include/test_header_units_and_modules.hpp index 411bdb36f3..826183f98d 100644 --- a/tests/std/include/test_header_units_and_modules.hpp +++ b/tests/std/include/test_header_units_and_modules.hpp @@ -652,7 +652,11 @@ constexpr bool impl_test_source_location() { const auto sl = source_location::current(); assert(sl.line() == __LINE__ - 1); assert(sl.column() == 1); +#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 assert(sl.function_name() == "impl_test_source_location"sv); +#else // ^^^ workaround // no workaround vvv + assert(sl.function_name() == "bool __cdecl impl_test_source_location(void)"sv); +#endif // TRANSITION, DevCom-10199227 and LLVM-58951 assert(string_view{sl.file_name()}.ends_with("test_header_units_and_modules.hpp"sv)); return true; } diff --git a/tests/std/tests/P1208R6_source_location/test.cpp b/tests/std/tests/P1208R6_source_location/test.cpp index 485194dc18..291c6bedbf 100644 --- a/tests/std/tests/P1208R6_source_location/test.cpp +++ b/tests/std/tests/P1208R6_source_location/test.cpp @@ -131,7 +131,7 @@ constexpr void lambda_test() { assert(x2.line() == __LINE__ - 2); #ifndef _M_CEE // TRANSITION, VSO-1665663 assert(x1.column() == 52); -#endif +#endif // M_CEE assert(x2.column() == 50); #ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x1.function_name() == "lambda_test"sv); From cd86e869d0a2b6c9980df90e26d16e2537a5ede1 Mon Sep 17 00:00:00 2001 From: Daniel Marshall Date: Sat, 12 Nov 2022 11:18:57 +0000 Subject: [PATCH 04/11] Also guard EDG. --- stl/inc/source_location | 2 +- .../include/test_header_units_and_modules.hpp | 2 +- .../std/tests/P1208R6_source_location/header.h | 2 +- .../std/tests/P1208R6_source_location/test.cpp | 18 +++++++++--------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/stl/inc/source_location b/stl/inc/source_location index eca4d5af4e..633027cd00 100644 --- a/stl/inc/source_location +++ b/stl/inc/source_location @@ -25,7 +25,7 @@ _STD_BEGIN _EXPORT_STD struct source_location { _NODISCARD static consteval source_location current(const uint_least32_t _Line_ = __builtin_LINE(), const uint_least32_t _Column_ = __builtin_COLUMN(), const char* const _File_ = __builtin_FILE(), -#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 +#if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 const char* const _Function_ = __builtin_FUNCTION()) noexcept { #else // ^^^ workaround no workaround vvv const char* const _Function_ = __builtin_FUNCSIG()) noexcept { diff --git a/tests/std/include/test_header_units_and_modules.hpp b/tests/std/include/test_header_units_and_modules.hpp index 826183f98d..1c3ea86a9c 100644 --- a/tests/std/include/test_header_units_and_modules.hpp +++ b/tests/std/include/test_header_units_and_modules.hpp @@ -652,7 +652,7 @@ constexpr bool impl_test_source_location() { const auto sl = source_location::current(); assert(sl.line() == __LINE__ - 1); assert(sl.column() == 1); -#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 +#if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(sl.function_name() == "impl_test_source_location"sv); #else // ^^^ workaround // no workaround vvv assert(sl.function_name() == "bool __cdecl impl_test_source_location(void)"sv); diff --git a/tests/std/tests/P1208R6_source_location/header.h b/tests/std/tests/P1208R6_source_location/header.h index 9572f7b43a..630fad3084 100644 --- a/tests/std/tests/P1208R6_source_location/header.h +++ b/tests/std/tests/P1208R6_source_location/header.h @@ -11,7 +11,7 @@ constexpr void header_test() { const auto x = source_location::current(); assert(x.line() == __LINE__ - 1); assert(x.column() == 37); -#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 +#if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x.function_name() == "header_test"sv); #else // ^^^ workaround no workaround vvv assert(x.function_name() == "void __cdecl header_test(void)"sv); diff --git a/tests/std/tests/P1208R6_source_location/test.cpp b/tests/std/tests/P1208R6_source_location/test.cpp index 291c6bedbf..64b928b906 100644 --- a/tests/std/tests/P1208R6_source_location/test.cpp +++ b/tests/std/tests/P1208R6_source_location/test.cpp @@ -50,7 +50,7 @@ constexpr void local_test() { const auto x = source_location::current(); assert(x.line() == __LINE__ - 1); assert(x.column() == 37); -#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 +#if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x.function_name() == "local_test"sv); #else // ^^^ workaround // workaround vvv assert(x.function_name() == "void __cdecl local_test(void)"sv); @@ -62,7 +62,7 @@ constexpr void argument_test( const unsigned int line, const unsigned int column, const source_location x = source_location::current()) { assert(x.line() == line); assert(x.column() == column); -#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 +#if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x.function_name() == "test"sv); #else // ^^^ workaround // workaround vvv assert(x.function_name() == "bool __cdecl test(void)"sv); @@ -77,7 +77,7 @@ constexpr void sloc_constructor_test() { if (is_constant_evaluated()) { assert(x.loc.function_name() == "int __cdecl main(void)"sv); // TRANSITION, VSO-1285783 } else { -#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 +#if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x.loc.function_name() == "sloc_constructor_test"sv); #else // ^^^ workaround // workaround vvv assert(x.loc.function_name() == "void __cdecl sloc_constructor_test(void)"sv); @@ -90,7 +90,7 @@ constexpr void different_constructor_test() { const s x{1}; assert(x.loc.line() == s_int_line); assert(x.loc.column() == 5); -#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 +#if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x.loc.function_name() == "s"sv); #else // ^^^ workaround // workaround vvv assert(x.loc.function_name() == "__cdecl s::s(int)"sv); @@ -105,7 +105,7 @@ constexpr void sub_member_test() { if (is_constant_evaluated()) { assert(s.x.loc.function_name() == "int __cdecl main(void)"sv); // TRANSITION, VSO-1285783 } else { -#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 +#if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(s.x.loc.function_name() == "sub_member_test"sv); #else // ^^^ workaround // workaround vvv assert(s.x.loc.function_name() == "void __cdecl sub_member_test(void)"sv); @@ -116,7 +116,7 @@ constexpr void sub_member_test() { const s2 s_i{1}; assert(s_i.x.loc.line() == s2_int_line); assert(s_i.x.loc.column() == 5); -#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 +#if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(s_i.x.loc.function_name() == "s2"sv); #else assert(s_i.x.loc.function_name() == "__cdecl s2::s2(int)"sv); @@ -133,7 +133,7 @@ constexpr void lambda_test() { assert(x1.column() == 52); #endif // M_CEE assert(x2.column() == 50); -#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 +#if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x1.function_name() == "lambda_test"sv); assert(x2.function_name() == "operator()"sv); #else // ^^^ workaround // workaround vvv @@ -154,7 +154,7 @@ constexpr void function_template_test() { const auto x1 = function_template(); assert(x1.line() == __LINE__ - 5); assert(x1.column() == 29); -#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 +#if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x1.function_name() == "function_template"sv); #else // ^^^ workaround // workaround vvv assert(x1.function_name() == "struct std::source_location __cdecl function_template(void)"sv); @@ -164,7 +164,7 @@ constexpr void function_template_test() { const auto x2 = function_template(); assert(x1.line() == x2.line()); assert(x1.column() == x2.column()); -#ifdef __clang__ // TRANSITION, DevCom-10199227 and LLVM-58951 +#if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x2.function_name() == "function_template"sv); #else // ^^^ workaround // workaround vvv assert(x2.function_name() == "struct std::source_location __cdecl function_template(void)"sv); From e19c343d16711c5b3379d1f595d34d73cfe4b425 Mon Sep 17 00:00:00 2001 From: Daniel Marshall Date: Sat, 12 Nov 2022 12:22:19 +0000 Subject: [PATCH 05/11] Fix test for x86 --- tests/std/tests/P1208R6_source_location/test.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/std/tests/P1208R6_source_location/test.cpp b/tests/std/tests/P1208R6_source_location/test.cpp index 64b928b906..c780ab06d2 100644 --- a/tests/std/tests/P1208R6_source_location/test.cpp +++ b/tests/std/tests/P1208R6_source_location/test.cpp @@ -92,7 +92,9 @@ constexpr void different_constructor_test() { assert(x.loc.column() == 5); #if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x.loc.function_name() == "s"sv); -#else // ^^^ workaround // workaround vvv +#elif defined(_M_IX86) // ^^^ workaround // workaround vvv + assert(x.loc.function_name() == "__thiscall s::s(int)"sv); +#else // _M_IX86 assert(x.loc.function_name() == "__cdecl s::s(int)"sv); #endif // TRANSITION, DevCom-10199227 and LLVM-58951 assert(string_view{x.loc.file_name()}.ends_with(test_cpp)); @@ -118,7 +120,9 @@ constexpr void sub_member_test() { assert(s_i.x.loc.column() == 5); #if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(s_i.x.loc.function_name() == "s2"sv); -#else +#elif defined(_M_IX86) // ^^^ workaround // workaround vvv + assert(s_i.x.loc.function_name() == "__thiscall s2::s2(int)"sv); +#else // _M_IX86 assert(s_i.x.loc.function_name() == "__cdecl s2::s2(int)"sv); #endif // TRANSITION, DevCom-10199227 and LLVM-58951 assert(string_view{s_i.x.loc.file_name()}.ends_with(test_cpp)); @@ -136,7 +140,11 @@ constexpr void lambda_test() { #if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x1.function_name() == "lambda_test"sv); assert(x2.function_name() == "operator()"sv); -#else // ^^^ workaround // workaround vvv +#elif defined(_M_IX86) // ^^^ workaround // workaround vvv + assert(x1.function_name() == "void __cdecl lambda_test(void)"sv); + assert(string_view{x2.function_name()}.starts_with("struct std::source_location __thiscall lambda_test:: Date: Sat, 12 Nov 2022 12:29:31 +0000 Subject: [PATCH 06/11] formatting --- tests/std/tests/P1208R6_source_location/test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/std/tests/P1208R6_source_location/test.cpp b/tests/std/tests/P1208R6_source_location/test.cpp index c780ab06d2..8e085248fb 100644 --- a/tests/std/tests/P1208R6_source_location/test.cpp +++ b/tests/std/tests/P1208R6_source_location/test.cpp @@ -142,7 +142,8 @@ constexpr void lambda_test() { assert(x2.function_name() == "operator()"sv); #elif defined(_M_IX86) // ^^^ workaround // workaround vvv assert(x1.function_name() == "void __cdecl lambda_test(void)"sv); - assert(string_view{x2.function_name()}.starts_with("struct std::source_location __thiscall lambda_test:: Date: Sat, 12 Nov 2022 13:11:20 +0000 Subject: [PATCH 07/11] [skip ci] fixup comments Co-Authored-By: Igor Zhukov --- stl/inc/source_location | 2 +- .../include/test_header_units_and_modules.hpp | 2 +- .../std/tests/P1208R6_source_location/header.h | 2 +- .../std/tests/P1208R6_source_location/test.cpp | 18 +++++++++--------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/stl/inc/source_location b/stl/inc/source_location index 633027cd00..2f6e8749e5 100644 --- a/stl/inc/source_location +++ b/stl/inc/source_location @@ -27,7 +27,7 @@ _EXPORT_STD struct source_location { const uint_least32_t _Column_ = __builtin_COLUMN(), const char* const _File_ = __builtin_FILE(), #if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 const char* const _Function_ = __builtin_FUNCTION()) noexcept { -#else // ^^^ workaround no workaround vvv +#else // ^^^ workaround / no workaround vvv const char* const _Function_ = __builtin_FUNCSIG()) noexcept { #endif // TRANSITION, DevCom-10199227 and LLVM-58951 source_location _Result{}; diff --git a/tests/std/include/test_header_units_and_modules.hpp b/tests/std/include/test_header_units_and_modules.hpp index 1c3ea86a9c..4c7414bda9 100644 --- a/tests/std/include/test_header_units_and_modules.hpp +++ b/tests/std/include/test_header_units_and_modules.hpp @@ -654,7 +654,7 @@ constexpr bool impl_test_source_location() { assert(sl.column() == 1); #if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(sl.function_name() == "impl_test_source_location"sv); -#else // ^^^ workaround // no workaround vvv +#else // ^^^ workaround / no workaround vvv assert(sl.function_name() == "bool __cdecl impl_test_source_location(void)"sv); #endif // TRANSITION, DevCom-10199227 and LLVM-58951 assert(string_view{sl.file_name()}.ends_with("test_header_units_and_modules.hpp"sv)); diff --git a/tests/std/tests/P1208R6_source_location/header.h b/tests/std/tests/P1208R6_source_location/header.h index 630fad3084..fd06b41a19 100644 --- a/tests/std/tests/P1208R6_source_location/header.h +++ b/tests/std/tests/P1208R6_source_location/header.h @@ -13,7 +13,7 @@ constexpr void header_test() { assert(x.column() == 37); #if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x.function_name() == "header_test"sv); -#else // ^^^ workaround no workaround vvv +#else // ^^^ workaround / no workaround vvv assert(x.function_name() == "void __cdecl header_test(void)"sv); #endif // TRANSITION, DevCom-10199227 and LLVM-58951 assert(string_view{x.file_name()}.ends_with("header.h"sv)); diff --git a/tests/std/tests/P1208R6_source_location/test.cpp b/tests/std/tests/P1208R6_source_location/test.cpp index 8e085248fb..8bd431a3c1 100644 --- a/tests/std/tests/P1208R6_source_location/test.cpp +++ b/tests/std/tests/P1208R6_source_location/test.cpp @@ -52,7 +52,7 @@ constexpr void local_test() { assert(x.column() == 37); #if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x.function_name() == "local_test"sv); -#else // ^^^ workaround // workaround vvv +#else // ^^^ workaround / no workaround vvv assert(x.function_name() == "void __cdecl local_test(void)"sv); #endif // TRANSITION, DevCom-10199227 and LLVM-58951 assert(string_view{x.file_name()}.ends_with(test_cpp)); @@ -64,7 +64,7 @@ constexpr void argument_test( assert(x.column() == column); #if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x.function_name() == "test"sv); -#else // ^^^ workaround // workaround vvv +#else // ^^^ workaround / no workaround vvv assert(x.function_name() == "bool __cdecl test(void)"sv); #endif // TRANSITION, DevCom-10199227 and LLVM-58951 assert(string_view{x.file_name()}.ends_with(test_cpp)); @@ -79,7 +79,7 @@ constexpr void sloc_constructor_test() { } else { #if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x.loc.function_name() == "sloc_constructor_test"sv); -#else // ^^^ workaround // workaround vvv +#else // ^^^ workaround / no workaround vvv assert(x.loc.function_name() == "void __cdecl sloc_constructor_test(void)"sv); #endif // TRANSITION, DevCom-10199227 and LLVM-58951 } @@ -92,7 +92,7 @@ constexpr void different_constructor_test() { assert(x.loc.column() == 5); #if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x.loc.function_name() == "s"sv); -#elif defined(_M_IX86) // ^^^ workaround // workaround vvv +#elif defined(_M_IX86) // ^^^ workaround / no workaround vvv assert(x.loc.function_name() == "__thiscall s::s(int)"sv); #else // _M_IX86 assert(x.loc.function_name() == "__cdecl s::s(int)"sv); @@ -109,7 +109,7 @@ constexpr void sub_member_test() { } else { #if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(s.x.loc.function_name() == "sub_member_test"sv); -#else // ^^^ workaround // workaround vvv +#else // ^^^ workaround / no workaround vvv assert(s.x.loc.function_name() == "void __cdecl sub_member_test(void)"sv); #endif // TRANSITION, DevCom-10199227 and LLVM-58951 } @@ -120,7 +120,7 @@ constexpr void sub_member_test() { assert(s_i.x.loc.column() == 5); #if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(s_i.x.loc.function_name() == "s2"sv); -#elif defined(_M_IX86) // ^^^ workaround // workaround vvv +#elif defined(_M_IX86) // ^^^ workaround / no workaround vvv assert(s_i.x.loc.function_name() == "__thiscall s2::s2(int)"sv); #else // _M_IX86 assert(s_i.x.loc.function_name() == "__cdecl s2::s2(int)"sv); @@ -140,7 +140,7 @@ constexpr void lambda_test() { #if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x1.function_name() == "lambda_test"sv); assert(x2.function_name() == "operator()"sv); -#elif defined(_M_IX86) // ^^^ workaround // workaround vvv +#elif defined(_M_IX86) // ^^^ workaround / no workaround vvv assert(x1.function_name() == "void __cdecl lambda_test(void)"sv); assert( string_view{x2.function_name()}.starts_with("struct std::source_location __thiscall lambda_test::(void)"sv); #endif // TRANSITION, DevCom-10199227 and LLVM-58951 assert(string_view{x1.file_name()}.ends_with(test_cpp)); @@ -175,7 +175,7 @@ constexpr void function_template_test() { assert(x1.column() == x2.column()); #if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x2.function_name() == "function_template"sv); -#else // ^^^ workaround // workaround vvv +#else // ^^^ workaround / no workaround vvv assert(x2.function_name() == "struct std::source_location __cdecl function_template(void)"sv); #endif // TRANSITION, DevCom-10199227 and LLVM-58951 assert(string_view{x1.file_name()} == string_view{x2.file_name()}); From ba9f3ebc3478e260ffef7e81516ece91f15eab3a Mon Sep 17 00:00:00 2001 From: Daniel Marshall Date: Tue, 15 Nov 2022 12:15:31 +0000 Subject: [PATCH 08/11] Move paren Co-Authored-By: nicole mazzuca <83086508+strega-nil-ms@users.noreply.github.com> --- stl/inc/source_location | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stl/inc/source_location b/stl/inc/source_location index 2f6e8749e5..5bd56d4eae 100644 --- a/stl/inc/source_location +++ b/stl/inc/source_location @@ -26,10 +26,11 @@ _EXPORT_STD struct source_location { _NODISCARD static consteval source_location current(const uint_least32_t _Line_ = __builtin_LINE(), const uint_least32_t _Column_ = __builtin_COLUMN(), const char* const _File_ = __builtin_FILE(), #if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 - const char* const _Function_ = __builtin_FUNCTION()) noexcept { + const char* const _Function_ = __builtin_FUNCTION() #else // ^^^ workaround / no workaround vvv - const char* const _Function_ = __builtin_FUNCSIG()) noexcept { + const char* const _Function_ = __builtin_FUNCSIG() #endif // TRANSITION, DevCom-10199227 and LLVM-58951 + ) noexcept { source_location _Result{}; _Result._Line = _Line_; _Result._Column = _Column_; From df154bb0988e1e9d0a751d3ea6909cb7ef14d8c1 Mon Sep 17 00:00:00 2001 From: Daniel Marshall Date: Tue, 29 Nov 2022 17:55:43 +0000 Subject: [PATCH 09/11] Update comments --- tests/std/tests/P1208R6_source_location/test.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/std/tests/P1208R6_source_location/test.cpp b/tests/std/tests/P1208R6_source_location/test.cpp index 8bd431a3c1..2f7c924ffb 100644 --- a/tests/std/tests/P1208R6_source_location/test.cpp +++ b/tests/std/tests/P1208R6_source_location/test.cpp @@ -94,7 +94,7 @@ constexpr void different_constructor_test() { assert(x.loc.function_name() == "s"sv); #elif defined(_M_IX86) // ^^^ workaround / no workaround vvv assert(x.loc.function_name() == "__thiscall s::s(int)"sv); -#else // _M_IX86 +#else // ^^^ _M_IX86 / !_M_IX86 vvv assert(x.loc.function_name() == "__cdecl s::s(int)"sv); #endif // TRANSITION, DevCom-10199227 and LLVM-58951 assert(string_view{x.loc.file_name()}.ends_with(test_cpp)); @@ -122,7 +122,7 @@ constexpr void sub_member_test() { assert(s_i.x.loc.function_name() == "s2"sv); #elif defined(_M_IX86) // ^^^ workaround / no workaround vvv assert(s_i.x.loc.function_name() == "__thiscall s2::s2(int)"sv); -#else // _M_IX86 +#else // ^^^ _M_IX86 / !_M_IX86 vvv assert(s_i.x.loc.function_name() == "__cdecl s2::s2(int)"sv); #endif // TRANSITION, DevCom-10199227 and LLVM-58951 assert(string_view{s_i.x.loc.file_name()}.ends_with(test_cpp)); @@ -135,7 +135,7 @@ constexpr void lambda_test() { assert(x2.line() == __LINE__ - 2); #ifndef _M_CEE // TRANSITION, VSO-1665663 assert(x1.column() == 52); -#endif // M_CEE +#endif // !M_CEE assert(x2.column() == 50); #if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x1.function_name() == "lambda_test"sv); @@ -145,7 +145,7 @@ constexpr void lambda_test() { assert( string_view{x2.function_name()}.starts_with("struct std::source_location __thiscall lambda_test:: Date: Tue, 29 Nov 2022 17:38:53 -0800 Subject: [PATCH 10/11] Fix comment. --- tests/std/tests/P1208R6_source_location/test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/std/tests/P1208R6_source_location/test.cpp b/tests/std/tests/P1208R6_source_location/test.cpp index 2f7c924ffb..465e682cc9 100644 --- a/tests/std/tests/P1208R6_source_location/test.cpp +++ b/tests/std/tests/P1208R6_source_location/test.cpp @@ -135,7 +135,7 @@ constexpr void lambda_test() { assert(x2.line() == __LINE__ - 2); #ifndef _M_CEE // TRANSITION, VSO-1665663 assert(x1.column() == 52); -#endif // !M_CEE +#endif // !_M_CEE assert(x2.column() == 50); #if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951 assert(x1.function_name() == "lambda_test"sv); From 9aaab872554784c7e612931f4300882ce356c593 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 29 Nov 2022 17:41:49 -0800 Subject: [PATCH 11/11] Restore separate lambda definitions and calls. --- tests/std/tests/P1208R6_source_location/test.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/std/tests/P1208R6_source_location/test.cpp b/tests/std/tests/P1208R6_source_location/test.cpp index 465e682cc9..57eb3210ed 100644 --- a/tests/std/tests/P1208R6_source_location/test.cpp +++ b/tests/std/tests/P1208R6_source_location/test.cpp @@ -129,10 +129,12 @@ constexpr void sub_member_test() { } constexpr void lambda_test() { - const auto x1 = [loc = source_location::current()] { return loc; }(); - const auto x2 = [] { return source_location::current(); }(); - assert(x1.line() == __LINE__ - 2); - assert(x2.line() == __LINE__ - 2); + const auto l1 = [loc = source_location::current()] { return loc; }; + const auto l2 = [] { return source_location::current(); }; + const auto x1 = l1(); + const auto x2 = l2(); + assert(x1.line() == __LINE__ - 4); + assert(x2.line() == __LINE__ - 4); #ifndef _M_CEE // TRANSITION, VSO-1665663 assert(x1.column() == 52); #endif // !_M_CEE