-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to suppress all clang-target-msvc test warning in CMAKE and other misc fixes #1151
Changes from 4 commits
c575d56
28588a9
abb3050
63d6445
c8cbf57
d75c98b
d7b83ff
073571a
eb420be
b17216a
e7e48c3
c079096
9d0de74
6593a07
bdc4929
28b559e
133af4a
39a140a
032ac28
8d8f7b1
473ccd0
ade161d
ff44d1a
03d7600
b6db4b8
9155a22
eaaa44c
02e472d
f1fd5ac
659567c
889f904
8b3227f
6d0343f
166b79d
3b4928a
e422dad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2491,18 +2491,27 @@ TEST(FormatTest, FmtStringInTemplate) { | |
|
||
#endif // FMT_USE_CONSTEXPR | ||
|
||
// C++20 feature test, since r346892 Clang considers char8_t a fundamental | ||
// type in this mode. If this is the case __cpp_char8_t will be defined. | ||
#ifndef __cpp_char8_t | ||
// A UTF-8 code unit type. | ||
#define CHAR8_T fmt::char8_t | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest replacing a macro with a using declaration. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. With c++11 using, it looks way way better now. Thank you. |
||
#else | ||
#define CHAR8_T char8_t | ||
#endif | ||
|
||
TEST(FormatTest, ConstructU8StringViewFromCString) { | ||
fmt::u8string_view s("ab"); | ||
EXPECT_EQ(s.size(), 2u); | ||
const fmt::char8_t* data = s.data(); | ||
const CHAR8_T* data = s.data(); | ||
EXPECT_EQ(data[0], 'a'); | ||
EXPECT_EQ(data[1], 'b'); | ||
} | ||
|
||
TEST(FormatTest, ConstructU8StringViewFromDataAndSize) { | ||
fmt::u8string_view s("foobar", 3); | ||
EXPECT_EQ(s.size(), 3u); | ||
const fmt::char8_t* data = s.data(); | ||
const CHAR8_T* data = s.data(); | ||
EXPECT_EQ(data[0], 'f'); | ||
EXPECT_EQ(data[1], 'o'); | ||
EXPECT_EQ(data[2], 'o'); | ||
|
@@ -2513,7 +2522,7 @@ TEST(FormatTest, U8StringViewLiteral) { | |
using namespace fmt::literals; | ||
fmt::u8string_view s = "ab"_u; | ||
EXPECT_EQ(s.size(), 2u); | ||
const fmt::char8_t* data = s.data(); | ||
const CHAR8_T* data = s.data(); | ||
EXPECT_EQ(data[0], 'a'); | ||
EXPECT_EQ(data[1], 'b'); | ||
EXPECT_EQ(format("{:*^5}"_u, "🤡"_u), "**🤡**"_u); | ||
|
@@ -2536,6 +2545,6 @@ TEST(FormatTest, CharTraitsIsNotAmbiguous) { | |
char_traits<char>::char_type c; | ||
#if __cplusplus >= 201103L | ||
std::string s; | ||
begin(s); | ||
auto lval = begin(s); | ||
#endif | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -461,6 +461,10 @@ struct LocaleMock { | |
# ifdef _MSC_VER | ||
# pragma warning(push) | ||
# pragma warning(disable : 4273) | ||
# ifdef __clang__ | ||
# pragma clang diagnostic push | ||
# pragma clang diagnostic ignored "-Winconsistent-dllimport" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you post the warnings? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
# endif | ||
|
||
_locale_t _create_locale(int category, const char* locale) { | ||
return LocaleMock::instance->newlocale(category, locale, 0); | ||
|
@@ -473,6 +477,9 @@ void _free_locale(_locale_t locale) { | |
double _strtod_l(const char* nptr, char** endptr, _locale_t locale) { | ||
return LocaleMock::instance->strtod_l(nptr, endptr, locale); | ||
} | ||
# ifdef __clang__ | ||
# pragma clang diagnostic pop | ||
# endif | ||
# pragma warning(pop) | ||
# endif | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exceptions are enabled by default on MSVC. Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would also force the library into a specific exception handling model, which would be undesirable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vitaut : My clang-target-msvc isn't defaulting /EHsc. Then I guess this should just trying to mirror /EHsc default in MSVC cl.exe. Perhaps...
if (MSVC)
should be changed into
if (MSVC AND CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
@eliaskosunen Would you be okay with narrowing to clang-target-msvc for mirroring the default /EHsc above?
Should there be FMT_MSVC_EH option that explicitly add custom /EHxx?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, perhaps we can have FMT_MSVC_EH like this :
What do you guys think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why TravisCI evaluates MSVC true in apple platform and linux clang platform.
So I try to workaround with
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that it's because my excessing endif, not MSVC weirdness. Fixed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what is the default in clang-target-msvc? Are exceptions disabled by default or enabled with a different setting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems exceptions are disabled by default. Well, you are right, after take a look at => user manual, I found that users can explicitly state the configurations through very generous means. However,
clang-cl.exe
alone basically does not enable exceptions by default.Nevertheless, if you think this compiler case wouldn't be worth for the added complexity, I will be fine with dropping these CMAKE changes for /EHsc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed conditional adding /EHsc from CMAKELists.txt in both root and test.