Commit 083f099
[clang-format] Support BraceWrapping.AfterNamespace with AllowShortNamespacesOnASingleLine (llvm#123010)
AllowShortNamespacesOnASingleLine assumes that there is no newline
before the namespace brace, however, there is no actual reason this
shouldn't be compatible with BraceWrapping.AfterNamespace = true.
This is a little tricky in the implementation because
UnwrappedLineFormatter works on lines, so being flexible about the
offsets is awkward.
Not sure if there is a better pattern for combining the 'AllowShort'
options with the various configurations of BraceWrapping, but this
seemed mostly reasonable. Really, it would almost be preferable to just
pattern match on the direct token stream, rather than the
AnnotatedLines, but I'm not seeing a straightforward way to do that.
---------
Co-authored-by: Owen Pan <[email protected]>1 parent 0ec1693 commit 083f099
File tree
2 files changed
+60
-17
lines changed- clang
- lib/Format
- unittests/Format
2 files changed
+60
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
366 | 366 | | |
367 | 367 | | |
368 | 368 | | |
369 | | - | |
370 | | - | |
| 369 | + | |
371 | 370 | | |
372 | 371 | | |
373 | 372 | | |
| |||
633 | 632 | | |
634 | 633 | | |
635 | 634 | | |
636 | | - | |
637 | | - | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
638 | 652 | | |
639 | 653 | | |
640 | 654 | | |
641 | 655 | | |
642 | 656 | | |
643 | | - | |
644 | | - | |
645 | | - | |
646 | | - | |
647 | | - | |
| 657 | + | |
| 658 | + | |
648 | 659 | | |
649 | 660 | | |
650 | 661 | | |
651 | 662 | | |
652 | 663 | | |
653 | | - | |
| 664 | + | |
| 665 | + | |
654 | 666 | | |
655 | 667 | | |
656 | 668 | | |
| |||
661 | 673 | | |
662 | 674 | | |
663 | 675 | | |
664 | | - | |
| 676 | + | |
| 677 | + | |
665 | 678 | | |
666 | 679 | | |
667 | | - | |
| 680 | + | |
668 | 681 | | |
669 | 682 | | |
670 | 683 | | |
671 | 684 | | |
672 | 685 | | |
673 | | - | |
674 | | - | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
675 | 689 | | |
676 | 690 | | |
677 | 691 | | |
| |||
686 | 700 | | |
687 | 701 | | |
688 | 702 | | |
689 | | - | |
| 703 | + | |
690 | 704 | | |
691 | 705 | | |
692 | | - | |
693 | | - | |
| 706 | + | |
| 707 | + | |
694 | 708 | | |
695 | 709 | | |
696 | 710 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28867 | 28867 | | |
28868 | 28868 | | |
28869 | 28869 | | |
| 28870 | + | |
| 28871 | + | |
| 28872 | + | |
| 28873 | + | |
| 28874 | + | |
| 28875 | + | |
| 28876 | + | |
| 28877 | + | |
| 28878 | + | |
| 28879 | + | |
| 28880 | + | |
| 28881 | + | |
| 28882 | + | |
| 28883 | + | |
| 28884 | + | |
| 28885 | + | |
| 28886 | + | |
| 28887 | + | |
| 28888 | + | |
| 28889 | + | |
| 28890 | + | |
| 28891 | + | |
| 28892 | + | |
| 28893 | + | |
| 28894 | + | |
| 28895 | + | |
| 28896 | + | |
| 28897 | + | |
| 28898 | + | |
28870 | 28899 | | |
28871 | 28900 | | |
28872 | 28901 | | |
| |||
0 commit comments