Skip to content
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

<format>: compile time checks #2221

Merged
merged 25 commits into from
Dec 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ed3b1e2
modify build files to use interna compiler
barcharcraz Aug 20, 2021
7d1b096
tests now pass.
barcharcraz Aug 24, 2021
3fb9091
_Format_checker
barcharcraz Sep 11, 2021
f3963d6
_Format_checker needs arguments
barcharcraz Sep 14, 2021
5a3f046
implement format_checker using format traits
barcharcraz Sep 16, 2021
fce24f8
make more required functions constexpr
barcharcraz Sep 21, 2021
ecc6c69
compile time format checking works
barcharcraz Sep 27, 2021
8a692e6
Comment wording change
barcharcraz Sep 27, 2021
028557b
fix formatting error, and fix spurious test failure
barcharcraz Sep 27, 2021
7b36556
Apply some of miscco's suggestions from code review
barcharcraz Sep 28, 2021
fec2238
fix formatting.
barcharcraz Sep 28, 2021
cde2a8e
correct chrono tests and make chrono parse functions constexpr
barcharcraz Oct 1, 2021
b03e4d0
apply "easy" review comments.
barcharcraz Nov 17, 2021
4b63831
Add type checking to _Specs_checker
barcharcraz Nov 18, 2021
1116bb6
remove internal checks for type validity in the writer functions.
barcharcraz Nov 18, 2021
036e707
constexpr before explicit
barcharcraz Nov 18, 2021
0f4a952
update the required stuff in yvals_core.h
barcharcraz Nov 18, 2021
ea100be
skip newly failing tests in libcxx for the version macro change
barcharcraz Nov 18, 2021
f8bc41b
Simple code review feedback.
StephanTLavavej Nov 20, 2021
f6d17b7
address code review comments (tests broken, need to figure what to do…
barcharcraz Nov 23, 2021
473dd60
fix the test failures caused by checking on formatted_size/format_to_n.
barcharcraz Dec 2, 2021
a51bdce
Merge branch 'compile_time_checks_wip' into compile_time_checks
barcharcraz Dec 2, 2021
bb3fc35
'c' is no longer a semi-integer presentation type
barcharcraz Dec 3, 2021
c21e711
ensure _Compile_time_parse_format_specs only runs at compile-time via…
barcharcraz Dec 4, 2021
cc15ff7
Work around VSO-1451773.
StephanTLavavej Dec 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 38 additions & 38 deletions stl/inc/chrono
Original file line number Diff line number Diff line change
Expand Up @@ -5829,11 +5829,11 @@ namespace chrono {
struct _Chrono_formatter {
_Chrono_formatter() = default;

explicit _Chrono_formatter(const basic_string_view<_CharT> _Time_zone_abbreviation_)
constexpr explicit _Chrono_formatter(const basic_string_view<_CharT> _Time_zone_abbreviation_)
: _Time_zone_abbreviation{_Time_zone_abbreviation_} {}

template <class _Ty>
_NODISCARD auto _Parse(basic_format_parse_context<_CharT>& _Parse_ctx) {
_NODISCARD constexpr auto _Parse(basic_format_parse_context<_CharT>& _Parse_ctx) {
_Chrono_specs_setter<_CharT, basic_format_parse_context<_CharT>> _Callback{_Specs, _Parse_ctx};
const auto _It =
_Parse_chrono_format_specs(_Parse_ctx._Unchecked_begin(), _Parse_ctx._Unchecked_end(), _Callback);
Expand Down Expand Up @@ -5867,39 +5867,39 @@ namespace chrono {
return _Res_iter;
}

static void _Check_modifier(const char _Type, const char _Modifier) {
if (_Modifier == '\0') {
return;
}
enum _Allowed_bit : uint8_t { _E_mod = 1, _O_mod = 2, _EO_mod = _E_mod | _O_mod };

enum _Allowed_bit : uint8_t { _E_mod = 1, _O_mod = 2, _EO_mod = _E_mod | _O_mod };
struct _Table_entry {
char _Type;
_Allowed_bit _Allowed;
};

struct _Table_entry {
char _Type;
_Allowed_bit _Allowed;
};
static constexpr _Table_entry _Table[] = {
{'c', _E_mod},
{'C', _E_mod},
{'d', _O_mod},
{'e', _O_mod},
{'H', _O_mod},
{'I', _O_mod},
{'m', _O_mod},
{'M', _O_mod},
{'S', _O_mod},
{'u', _O_mod},
{'U', _O_mod},
{'V', _O_mod},
{'w', _O_mod},
{'W', _O_mod},
{'x', _E_mod},
{'X', _E_mod},
{'y', _EO_mod},
{'Y', _E_mod},
{'z', _EO_mod},
};

static constexpr _Table_entry _Table[] = {
{'c', _E_mod},
{'C', _E_mod},
{'d', _O_mod},
{'e', _O_mod},
{'H', _O_mod},
{'I', _O_mod},
{'m', _O_mod},
{'M', _O_mod},
{'S', _O_mod},
{'u', _O_mod},
{'U', _O_mod},
{'V', _O_mod},
{'w', _O_mod},
{'W', _O_mod},
{'x', _E_mod},
{'X', _E_mod},
{'y', _EO_mod},
{'Y', _E_mod},
{'z', _EO_mod},
};
static constexpr void _Check_modifier(const char _Type, const char _Modifier) {
if (_Modifier == '\0') {
return;
}

const _Allowed_bit _Mod = _Modifier == 'E' ? _E_mod : _O_mod;

Expand Down Expand Up @@ -6329,7 +6329,7 @@ namespace chrono {

template <class _Ty, class _CharT>
struct _Fill_tm_formatter {
auto parse(basic_format_parse_context<_CharT>& _Parse_ctx) {
constexpr auto parse(basic_format_parse_context<_CharT>& _Parse_ctx) {
return _Impl.template _Parse<_Ty>(_Parse_ctx);
}

Expand Down Expand Up @@ -6420,7 +6420,7 @@ struct formatter<_CHRONO local_info, _CharT> //

template <class _Duration, class _CharT>
struct formatter<_CHRONO sys_time<_Duration>, _CharT> {
auto parse(basic_format_parse_context<_CharT>& _Parse_ctx) {
constexpr auto parse(basic_format_parse_context<_CharT>& _Parse_ctx) {
return _Impl.template _Parse<_CHRONO sys_time<_Duration>>(_Parse_ctx);
}

Expand All @@ -6435,7 +6435,7 @@ private:

template <class _Duration, class _CharT>
struct formatter<_CHRONO utc_time<_Duration>, _CharT> {
auto parse(basic_format_parse_context<_CharT>& _Parse_ctx) {
constexpr auto parse(basic_format_parse_context<_CharT>& _Parse_ctx) {
return _Impl.template _Parse<_CHRONO utc_time<_Duration>>(_Parse_ctx);
}

Expand All @@ -6451,7 +6451,7 @@ private:

template <class _Duration, class _CharT>
struct formatter<_CHRONO tai_time<_Duration>, _CharT> {
auto parse(basic_format_parse_context<_CharT>& _Parse_ctx) {
constexpr auto parse(basic_format_parse_context<_CharT>& _Parse_ctx) {
return _Impl.template _Parse<_CHRONO tai_time<_Duration>>(_Parse_ctx);
}

Expand All @@ -6470,7 +6470,7 @@ private:

template <class _Duration, class _CharT>
struct formatter<_CHRONO gps_time<_Duration>, _CharT> {
auto parse(basic_format_parse_context<_CharT>& _Parse_ctx) {
constexpr auto parse(basic_format_parse_context<_CharT>& _Parse_ctx) {
return _Impl.template _Parse<_CHRONO gps_time<_Duration>>(_Parse_ctx);
}

Expand All @@ -6489,7 +6489,7 @@ private:

template <class _Duration, class _CharT>
struct formatter<_CHRONO file_time<_Duration>, _CharT> {
auto parse(basic_format_parse_context<_CharT>& _Parse_ctx) {
constexpr auto parse(basic_format_parse_context<_CharT>& _Parse_ctx) {
return _Impl.template _Parse<_CHRONO file_time<_Duration>>(_Parse_ctx);
}

Expand Down
Loading