Skip to content

Commit 0fa4217

Browse files
committed
Cleanup and simplification of comment and #line emission logic
Another step preparing to separate decl/defn comment emission, but for now continue to emit all the comments on the definitions While we're at it, add a "no comment left behind" debug check
1 parent 3a87189 commit 0fa4217

File tree

72 files changed

+412
-368
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+412
-368
lines changed

regression-tests/test-results/mixed-allcpp1-hello.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@ auto main() -> int
1313
auto s = std::string{"world\n"};
1414
std::cout << "Hello " << s;
1515
}
16-

regression-tests/test-results/mixed-as-for-variant-20-types.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ struct X { operator int() const { return I; } };
55

66
#include "cpp2util.h"
77

8-
98
#line 4 "mixed-as-for-variant-20-types.cpp2"
109
[[nodiscard]] auto main() -> int;
1110

1211
//=== Cpp2 definitions ==========================================================
1312

14-
#line 3 "mixed-as-for-variant-20-types.cpp2"
1513

14+
#line 4 "mixed-as-for-variant-20-types.cpp2"
1615
[[nodiscard]] auto main() -> int{
1716

1817
std::variant<X<0>,X<1>,X<2>,X<3>,X<4>,X<5>,X<6>,X<7>,X<8>,X<9>,X<10>,X<11>,X<12>,X<13>,X<14>,X<15>,X<16>,X<17>,X<18>,X<19>> v {

regression-tests/test-results/mixed-bounds-check.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55

66
#include "cpp2util.h"
77

8-
98
#line 4 "mixed-bounds-check.cpp2"
109
[[nodiscard]] auto main() -> int;
1110

1211
//=== Cpp2 definitions ==========================================================
1312

14-
#line 3 "mixed-bounds-check.cpp2"
1513

14+
#line 4 "mixed-bounds-check.cpp2"
1615
[[nodiscard]] auto main() -> int{
1716
std::vector v {1, 2, 3, 4, 5, -999};
1817
CPP2_UFCS_0(pop_back, v);

regression-tests/test-results/mixed-bounds-safety-with-assert-2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
#include "cpp2util.h"
44

5-
65
#line 2 "mixed-bounds-safety-with-assert-2.cpp2"
76
[[nodiscard]] auto main() -> int;
7+
88
#line 10 "mixed-bounds-safety-with-assert-2.cpp2"
99
auto add_42_to_subrange(auto& rng, cpp2::in<int> start, cpp2::in<int> end) -> void;
1010
#line 23 "mixed-bounds-safety-with-assert-2.cpp2"
@@ -15,8 +15,8 @@ auto add_42_to_subrange(auto& rng, cpp2::in<int> start, cpp2::in<int> end) -> vo
1515

1616
//=== Cpp2 definitions ==========================================================
1717

18-
#line 1 "mixed-bounds-safety-with-assert-2.cpp2"
1918

19+
#line 2 "mixed-bounds-safety-with-assert-2.cpp2"
2020
[[nodiscard]] auto main() -> int{
2121
std::vector<int> v {1, 2, 3, 4, 5};
2222
add_42_to_subrange(v, 1, 3);

regression-tests/test-results/mixed-bounds-safety-with-assert.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
#include "cpp2util.h"
44

5-
65
#line 2 "mixed-bounds-safety-with-assert.cpp2"
76
[[nodiscard]] auto main() -> int;
7+
88
#line 7 "mixed-bounds-safety-with-assert.cpp2"
99
auto print_subrange(auto const& rng, cpp2::in<int> start, cpp2::in<int> end) -> void;
1010
#line 19 "mixed-bounds-safety-with-assert.cpp2"
@@ -15,8 +15,8 @@ auto print_subrange(auto const& rng, cpp2::in<int> start, cpp2::in<int> end) ->
1515

1616
//=== Cpp2 definitions ==========================================================
1717

18-
#line 1 "mixed-bounds-safety-with-assert.cpp2"
1918

19+
#line 2 "mixed-bounds-safety-with-assert.cpp2"
2020
[[nodiscard]] auto main() -> int{
2121
std::vector<int> v {1, 2, 3, 4, 5};
2222
print_subrange(std::move(v), 1, 13);

regression-tests/test-results/mixed-captures-in-expressions-and-postconditions.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@
66

77
#include "cpp2util.h"
88

9-
109
#line 5 "mixed-captures-in-expressions-and-postconditions.cpp2"
1110
[[nodiscard]] auto main() -> int;
12-
#line 17 "mixed-captures-in-expressions-and-postconditions.cpp2"
11+
1312
#line 19 "mixed-captures-in-expressions-and-postconditions.cpp2"
1413
auto insert_at(cpp2::in<int> where, cpp2::in<int> val) -> void;
1514

1615
//=== Cpp2 definitions ==========================================================
1716

18-
#line 4 "mixed-captures-in-expressions-and-postconditions.cpp2"
1917

18+
#line 5 "mixed-captures-in-expressions-and-postconditions.cpp2"
2019
[[nodiscard]] auto main() -> int{
2120
std::vector<std::string> vec {
2221
"hello", "2022"};
@@ -32,11 +31,11 @@ auto insert_at(cpp2::in<int> where, cpp2::in<int> val) -> void;
3231
std::vector<int> vec {};
3332

3433
auto insert_at(cpp2::in<int> where, cpp2::in<int> val) -> void
35-
{
34+
35+
#line 22 "mixed-captures-in-expressions-and-postconditions.cpp2"
36+
{
3637
cpp2::Default.expects(cpp2::cmp_less_eq(0,where) && cpp2::cmp_less_eq(where,CPP2_UFCS_0(ssize, vec)), "");
3738
auto post_21_5 = cpp2::finally_success([_0 = CPP2_UFCS_0(ssize, vec)]{cpp2::Default.expects(CPP2_UFCS_0(ssize, vec)==_0 + 1, "");} );
38-
#line 21 "mixed-captures-in-expressions-and-postconditions.cpp2"
39-
4039
#line 23 "mixed-captures-in-expressions-and-postconditions.cpp2"
4140
CPP2_UFCS(insert, vec, CPP2_UFCS_0(begin, vec) + where, val);
4241
}

regression-tests/test-results/mixed-fixed-type-aliases.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ namespace my {
99

1010
#include "cpp2util.h"
1111

12-
1312
#line 8 "mixed-fixed-type-aliases.cpp2"
1413
auto test(auto const& x) -> void;
14+
1515
#line 15 "mixed-fixed-type-aliases.cpp2"
1616
[[nodiscard]] auto main(int const argc_, char const* const* const argv_) -> int;
1717

1818
//=== Cpp2 definitions ==========================================================
1919

20-
#line 7 "mixed-fixed-type-aliases.cpp2"
2120

21+
#line 8 "mixed-fixed-type-aliases.cpp2"
2222
auto test(auto const& x) -> void{
2323
std::cout
2424
<< std::boolalpha

regression-tests/test-results/mixed-float-literals.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@ void literals_cpp1() {
5858

5959
#include "cpp2util.h"
6060

61-
6261
#line 57 "mixed-float-literals.cpp2"
6362
auto literals_cpp2() -> void;
63+
6464
#line 114 "mixed-float-literals.cpp2"
6565
[[nodiscard]] auto main() -> int;
6666

6767
//=== Cpp2 definitions ==========================================================
6868

69-
#line 56 "mixed-float-literals.cpp2"
7069

70+
#line 57 "mixed-float-literals.cpp2"
7171
auto literals_cpp2() -> void{
7272
// integers
7373
123;

regression-tests/test-results/mixed-forwarding.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,41 @@ struct X {
1212

1313
#include "cpp2util.h"
1414

15-
1615
#line 11 "mixed-forwarding.cpp2"
1716
auto copy_from(auto x) -> void;
18-
#line 13 "mixed-forwarding.cpp2"
17+
1918
auto use(auto const& x) -> void;
19+
2020
#line 16 "mixed-forwarding.cpp2"
2121
auto apply_implicit_forward(auto&& t) -> void;
22+
2223
#line 20 "mixed-forwarding.cpp2"
2324
auto apply_explicit_forward(auto&& t) -> void;
25+
2426
#line 25 "mixed-forwarding.cpp2"
2527
[[nodiscard]] auto main() -> int;
2628

2729
//=== Cpp2 definitions ==========================================================
2830

29-
#line 10 "mixed-forwarding.cpp2"
3031

32+
#line 11 "mixed-forwarding.cpp2"
3133
auto copy_from(auto x) -> void{}
3234

3335
auto use(auto const& x) -> void{}
3436

3537
// invoking each of these with an rvalue std::pair argument ...
3638
auto apply_implicit_forward(auto&& t) -> void
3739
requires std::is_same_v<CPP2_TYPEOF(t), std::pair<X,X>>
38-
#line 17 "mixed-forwarding.cpp2"
39-
{ copy_from(t.first); // copies
40+
#line 16 "mixed-forwarding.cpp2"
41+
{
42+
copy_from(t.first); // copies
4043
copy_from(CPP2_FORWARD(t).second);// moves
4144
}
4245
auto apply_explicit_forward(auto&& t) -> void
4346
requires std::is_same_v<CPP2_TYPEOF(t), std::pair<X,X>>
44-
#line 21 "mixed-forwarding.cpp2"
45-
{ copy_from( CPP2_FORWARD(t).first);// moves
47+
#line 20 "mixed-forwarding.cpp2"
48+
{
49+
copy_from( CPP2_FORWARD(t).first);// moves
4650
copy_from( CPP2_FORWARD(t).second);// moves
4751
}
4852

regression-tests/test-results/mixed-function-expression-and-std-for-each.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88

99
#include "cpp2util.h"
1010

11-
1211
#line 7 "mixed-function-expression-and-std-for-each.cpp2"
1312
[[nodiscard]] auto main() -> int;
1413

1514
//=== Cpp2 definitions ==========================================================
1615

17-
#line 6 "mixed-function-expression-and-std-for-each.cpp2"
1816

17+
#line 7 "mixed-function-expression-and-std-for-each.cpp2"
1918
[[nodiscard]] auto main() -> int{
2019
std::vector<std::string> vec {
2120
"hello", "2022"};

regression-tests/test-results/mixed-function-expression-and-std-ranges-for-each-with-capture.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99

1010
#include "cpp2util.h"
1111

12-
1312
#line 8 "mixed-function-expression-and-std-ranges-for-each-with-capture.cpp2"
1413
[[nodiscard]] auto main() -> int;
1514

1615
//=== Cpp2 definitions ==========================================================
1716

18-
#line 7 "mixed-function-expression-and-std-ranges-for-each-with-capture.cpp2"
1917

18+
#line 8 "mixed-function-expression-and-std-ranges-for-each-with-capture.cpp2"
2019
[[nodiscard]] auto main() -> int{
2120
std::vector<std::string> vec {
2221
"hello", "2022"};

regression-tests/test-results/mixed-function-expression-and-std-ranges-for-each.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99

1010
#include "cpp2util.h"
1111

12-
1312
#line 8 "mixed-function-expression-and-std-ranges-for-each.cpp2"
1413
[[nodiscard]] auto main() -> int;
1514

1615
//=== Cpp2 definitions ==========================================================
1716

18-
#line 7 "mixed-function-expression-and-std-ranges-for-each.cpp2"
1917

18+
#line 8 "mixed-function-expression-and-std-ranges-for-each.cpp2"
2019
[[nodiscard]] auto main() -> int{
2120
std::vector<std::string> vec {
2221
"hello", "2022"};

regression-tests/test-results/mixed-function-expression-with-pointer-capture.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99

1010
#include "cpp2util.h"
1111

12-
1312
#line 8 "mixed-function-expression-with-pointer-capture.cpp2"
1413
[[nodiscard]] auto main() -> int;
1514

1615
//=== Cpp2 definitions ==========================================================
1716

18-
#line 7 "mixed-function-expression-with-pointer-capture.cpp2"
1917

18+
#line 8 "mixed-function-expression-with-pointer-capture.cpp2"
2019
[[nodiscard]] auto main() -> int{
2120
std::vector<std::string> vec {
2221
"hello", "2023"};

regression-tests/test-results/mixed-function-expression-with-repeated-capture.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99

1010
#include "cpp2util.h"
1111

12-
1312
#line 8 "mixed-function-expression-with-repeated-capture.cpp2"
1413
[[nodiscard]] auto main() -> int;
1514

1615
//=== Cpp2 definitions ==========================================================
1716

18-
#line 7 "mixed-function-expression-with-repeated-capture.cpp2"
1917

18+
#line 8 "mixed-function-expression-with-repeated-capture.cpp2"
2019
[[nodiscard]] auto main() -> int{
2120
std::vector<std::string> vec {
2221
"hello", "2022"};

regression-tests/test-results/mixed-hello.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
#include "cpp2util.h"
88

9-
109
#line 5 "mixed-hello.cpp2"
1110
[[nodiscard]] auto name() -> std::string;
11+
1212
#line 11 "mixed-hello.cpp2"
1313
auto decorate(std::string& s) -> void;
1414
#line 14 "mixed-hello.cpp2"
@@ -20,8 +20,8 @@ auto main() -> int {
2020

2121
//=== Cpp2 definitions ==========================================================
2222

23-
#line 4 "mixed-hello.cpp2"
2423

24+
#line 5 "mixed-hello.cpp2"
2525
[[nodiscard]] auto name() -> std::string{
2626
std::string s {"world"};
2727
decorate(s);

regression-tests/test-results/mixed-initialization-safety-3-contract-violation.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66

77
#include "cpp2util.h"
88

9-
109
#line 5 "mixed-initialization-safety-3-contract-violation.cpp2"
1110
[[nodiscard]] auto main() -> int;
11+
1212
#line 16 "mixed-initialization-safety-3-contract-violation.cpp2"
1313
auto fill(
1414
cpp2::out<std::string> x,
1515
cpp2::in<std::string> value,
1616
cpp2::in<int> count
1717
) -> void;
18+
1819
#line 26 "mixed-initialization-safety-3-contract-violation.cpp2"
1920
auto print_decorated(auto const& x) -> void;
2021

@@ -27,8 +28,8 @@ bool flip_a_coin() {
2728

2829
//=== Cpp2 definitions ==========================================================
2930

30-
#line 4 "mixed-initialization-safety-3-contract-violation.cpp2"
3131

32+
#line 5 "mixed-initialization-safety-3-contract-violation.cpp2"
3233
[[nodiscard]] auto main() -> int{
3334
cpp2::deferred_init<std::string> x; // note: uninitialized!
3435

@@ -45,10 +46,10 @@ auto fill(
4546
cpp2::in<std::string> value,
4647
cpp2::in<int> count
4748
) -> void
48-
{
49-
cpp2::Default.expects(cpp2::cmp_greater_eq(CPP2_UFCS_0(ssize, value),count), "fill: value must contain at least count elements");
50-
#line 22 "mixed-initialization-safety-3-contract-violation.cpp2"
5149

50+
{
51+
cpp2::Default.expects(cpp2::cmp_greater_eq(CPP2_UFCS_0(ssize, value),count), "fill: value must contain at least count elements");
52+
#line 23 "mixed-initialization-safety-3-contract-violation.cpp2"
5253
x.construct(CPP2_UFCS(substr, value, 0, count));
5354
}
5455

regression-tests/test-results/mixed-initialization-safety-3.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,26 @@
66

77
#include "cpp2util.h"
88

9-
109
#line 5 "mixed-initialization-safety-3.cpp2"
1110
[[nodiscard]] auto main() -> int;
11+
1212
#line 16 "mixed-initialization-safety-3.cpp2"
1313
auto fill(
1414
cpp2::out<std::string> x,
1515
cpp2::in<std::string> value,
1616
cpp2::in<int> count
1717
) -> void;
18+
1819
#line 26 "mixed-initialization-safety-3.cpp2"
1920
auto print_decorated(auto const& x) -> void;
21+
2022
#line 30 "mixed-initialization-safety-3.cpp2"
2123
[[nodiscard]] auto flip_a_coin() -> bool;
2224

2325
//=== Cpp2 definitions ==========================================================
2426

25-
#line 4 "mixed-initialization-safety-3.cpp2"
2627

28+
#line 5 "mixed-initialization-safety-3.cpp2"
2729
[[nodiscard]] auto main() -> int{
2830
cpp2::deferred_init<std::string> x; // note: uninitialized!
2931

@@ -40,10 +42,10 @@ auto fill(
4042
cpp2::in<std::string> value,
4143
cpp2::in<int> count
4244
) -> void
43-
{
44-
cpp2::Default.expects(cpp2::cmp_greater_eq(CPP2_UFCS_0(ssize, value),count), "fill: value must contain at least count elements");
45-
#line 22 "mixed-initialization-safety-3.cpp2"
4645

46+
{
47+
cpp2::Default.expects(cpp2::cmp_greater_eq(CPP2_UFCS_0(ssize, value),count), "fill: value must contain at least count elements");
48+
#line 23 "mixed-initialization-safety-3.cpp2"
4749
x.construct(CPP2_UFCS(substr, value, 0, count));
4850
}
4951

0 commit comments

Comments
 (0)