This repository was archived by the owner on Sep 15, 2025. It is now read-only.
Commit 486ec4b
authored
[clang-format] Add
This fixes llvm#101363 which is a resurrection of a previously opened but
never completed review: https://reviews.llvm.org/D11851
The feature is to allow code like the following not to be broken across
multiple lines:
```
namespace foo { class bar; }
namespace foo { namespace bar { class baz; } }
```
Code like this is commonly used for forward declarations, which are
ideally kept compact. This is also apparently the format that
include-what-you-use will insert for forward declarations.
Also, fix an off-by-one error in `CompactNamespaces` code. For nested
namespaces with 3 or more namespaces, it was incorrectly compacting
lines which were 1 or two spaces over the `ColumnLimit`, leading to
incorrect formatting results.AllowShortNamespacesOnASingleLine option (llvm#105597)1 parent 91c5de7 commit 486ec4b
File tree
7 files changed
+221
-1
lines changed- clang
- docs
- include/clang/Format
- lib/Format
- unittests/Format
7 files changed
+221
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2088 | 2088 | | |
2089 | 2089 | | |
2090 | 2090 | | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
2091 | 2096 | | |
2092 | 2097 | | |
2093 | 2098 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1123 | 1123 | | |
1124 | 1124 | | |
1125 | 1125 | | |
| 1126 | + | |
1126 | 1127 | | |
1127 | 1128 | | |
1128 | 1129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
988 | 988 | | |
989 | 989 | | |
990 | 990 | | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
991 | 995 | | |
992 | 996 | | |
993 | 997 | | |
| |||
5168 | 5172 | | |
5169 | 5173 | | |
5170 | 5174 | | |
| 5175 | + | |
| 5176 | + | |
5171 | 5177 | | |
5172 | 5178 | | |
5173 | 5179 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
975 | 975 | | |
976 | 976 | | |
977 | 977 | | |
| 978 | + | |
| 979 | + | |
978 | 980 | | |
979 | 981 | | |
980 | 982 | | |
| |||
1480 | 1482 | | |
1481 | 1483 | | |
1482 | 1484 | | |
| 1485 | + | |
1483 | 1486 | | |
1484 | 1487 | | |
1485 | 1488 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
| 364 | + | |
364 | 365 | | |
365 | 366 | | |
366 | 367 | | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
367 | 376 | | |
368 | 377 | | |
369 | 378 | | |
| |||
373 | 382 | | |
374 | 383 | | |
375 | 384 | | |
376 | | - | |
| 385 | + | |
377 | 386 | | |
378 | 387 | | |
379 | 388 | | |
| |||
420 | 429 | | |
421 | 430 | | |
422 | 431 | | |
| 432 | + | |
423 | 433 | | |
424 | 434 | | |
425 | 435 | | |
| |||
616 | 626 | | |
617 | 627 | | |
618 | 628 | | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
619 | 695 | | |
620 | 696 | | |
621 | 697 | | |
| |||
916 | 992 | | |
917 | 993 | | |
918 | 994 | | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
919 | 1010 | | |
920 | 1011 | | |
921 | 1012 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| 162 | + | |
162 | 163 | | |
163 | 164 | | |
164 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4476 | 4476 | | |
4477 | 4477 | | |
4478 | 4478 | | |
| 4479 | + | |
4479 | 4480 | | |
4480 | 4481 | | |
4481 | 4482 | | |
| |||
4504 | 4505 | | |
4505 | 4506 | | |
4506 | 4507 | | |
| 4508 | + | |
| 4509 | + | |
| 4510 | + | |
| 4511 | + | |
| 4512 | + | |
| 4513 | + | |
4507 | 4514 | | |
4508 | 4515 | | |
4509 | 4516 | | |
| |||
28314 | 28321 | | |
28315 | 28322 | | |
28316 | 28323 | | |
| 28324 | + | |
| 28325 | + | |
| 28326 | + | |
| 28327 | + | |
| 28328 | + | |
| 28329 | + | |
| 28330 | + | |
| 28331 | + | |
| 28332 | + | |
| 28333 | + | |
| 28334 | + | |
| 28335 | + | |
| 28336 | + | |
| 28337 | + | |
| 28338 | + | |
| 28339 | + | |
| 28340 | + | |
| 28341 | + | |
| 28342 | + | |
| 28343 | + | |
| 28344 | + | |
| 28345 | + | |
| 28346 | + | |
| 28347 | + | |
| 28348 | + | |
| 28349 | + | |
| 28350 | + | |
| 28351 | + | |
| 28352 | + | |
| 28353 | + | |
| 28354 | + | |
| 28355 | + | |
| 28356 | + | |
| 28357 | + | |
| 28358 | + | |
| 28359 | + | |
| 28360 | + | |
| 28361 | + | |
| 28362 | + | |
| 28363 | + | |
| 28364 | + | |
| 28365 | + | |
| 28366 | + | |
| 28367 | + | |
| 28368 | + | |
| 28369 | + | |
| 28370 | + | |
| 28371 | + | |
| 28372 | + | |
| 28373 | + | |
| 28374 | + | |
| 28375 | + | |
| 28376 | + | |
| 28377 | + | |
| 28378 | + | |
| 28379 | + | |
| 28380 | + | |
| 28381 | + | |
| 28382 | + | |
| 28383 | + | |
| 28384 | + | |
| 28385 | + | |
| 28386 | + | |
| 28387 | + | |
| 28388 | + | |
| 28389 | + | |
| 28390 | + | |
| 28391 | + | |
| 28392 | + | |
| 28393 | + | |
| 28394 | + | |
| 28395 | + | |
| 28396 | + | |
| 28397 | + | |
| 28398 | + | |
| 28399 | + | |
| 28400 | + | |
| 28401 | + | |
| 28402 | + | |
| 28403 | + | |
| 28404 | + | |
| 28405 | + | |
| 28406 | + | |
| 28407 | + | |
| 28408 | + | |
| 28409 | + | |
| 28410 | + | |
| 28411 | + | |
| 28412 | + | |
| 28413 | + | |
| 28414 | + | |
| 28415 | + | |
| 28416 | + | |
| 28417 | + | |
| 28418 | + | |
| 28419 | + | |
| 28420 | + | |
| 28421 | + | |
| 28422 | + | |
| 28423 | + | |
| 28424 | + | |
| 28425 | + | |
| 28426 | + | |
| 28427 | + | |
| 28428 | + | |
| 28429 | + | |
28317 | 28430 | | |
28318 | 28431 | | |
28319 | 28432 | | |
| |||
0 commit comments