|
30 | 30 | #include <iterator> |
31 | 31 | #include <optional> |
32 | 32 | #include <string> |
| 33 | +#include <utility> |
33 | 34 |
|
34 | 35 | namespace llvm { |
35 | 36 |
|
@@ -612,82 +613,47 @@ class DiagnosticInfoOptimizationBase : public DiagnosticInfoWithLocationBase { |
612 | 613 | /// common base class. This allows returning the result of the insertion |
613 | 614 | /// directly by value, e.g. return OptimizationRemarkAnalysis(...) << "blah". |
614 | 615 | template <class RemarkT> |
615 | | -RemarkT & |
616 | | -operator<<(RemarkT &R, |
617 | | - std::enable_if_t< |
618 | | - std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value, |
619 | | - StringRef> |
620 | | - S) { |
621 | | - R.insert(S); |
622 | | - return R; |
623 | | -} |
624 | | - |
625 | | -/// Also allow r-value for the remark to allow insertion into a |
626 | | -/// temporarily-constructed remark. |
627 | | -template <class RemarkT> |
628 | | -RemarkT & |
| 616 | +decltype(auto) |
629 | 617 | operator<<(RemarkT &&R, |
630 | | - std::enable_if_t< |
631 | | - std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value, |
632 | | - StringRef> |
| 618 | + std::enable_if_t<std::is_base_of_v<DiagnosticInfoOptimizationBase, |
| 619 | + std::remove_reference_t<RemarkT>>, |
| 620 | + StringRef> |
633 | 621 | S) { |
634 | 622 | R.insert(S); |
635 | | - return R; |
636 | | -} |
637 | | - |
638 | | -template <class RemarkT> |
639 | | -RemarkT & |
640 | | -operator<<(RemarkT &R, |
641 | | - std::enable_if_t< |
642 | | - std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value, |
643 | | - DiagnosticInfoOptimizationBase::Argument> |
644 | | - A) { |
645 | | - R.insert(A); |
646 | | - return R; |
| 623 | + return std::forward<RemarkT>(R); |
647 | 624 | } |
648 | 625 |
|
649 | 626 | template <class RemarkT> |
650 | | -RemarkT & |
| 627 | +decltype(auto) |
651 | 628 | operator<<(RemarkT &&R, |
652 | | - std::enable_if_t< |
653 | | - std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value, |
654 | | - DiagnosticInfoOptimizationBase::Argument> |
| 629 | + std::enable_if_t<std::is_base_of_v<DiagnosticInfoOptimizationBase, |
| 630 | + std::remove_reference_t<RemarkT>>, |
| 631 | + DiagnosticInfoOptimizationBase::Argument> |
655 | 632 | A) { |
656 | 633 | R.insert(A); |
657 | | - return R; |
658 | | -} |
659 | | - |
660 | | -template <class RemarkT> |
661 | | -RemarkT & |
662 | | -operator<<(RemarkT &R, |
663 | | - std::enable_if_t< |
664 | | - std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value, |
665 | | - DiagnosticInfoOptimizationBase::setIsVerbose> |
666 | | - V) { |
667 | | - R.insert(V); |
668 | | - return R; |
| 634 | + return std::forward<RemarkT>(R); |
669 | 635 | } |
670 | 636 |
|
671 | 637 | template <class RemarkT> |
672 | | -RemarkT & |
| 638 | +decltype(auto) |
673 | 639 | operator<<(RemarkT &&R, |
674 | | - std::enable_if_t< |
675 | | - std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value, |
676 | | - DiagnosticInfoOptimizationBase::setIsVerbose> |
| 640 | + std::enable_if_t<std::is_base_of_v<DiagnosticInfoOptimizationBase, |
| 641 | + std::remove_reference_t<RemarkT>>, |
| 642 | + DiagnosticInfoOptimizationBase::setIsVerbose> |
677 | 643 | V) { |
678 | 644 | R.insert(V); |
679 | | - return R; |
| 645 | + return std::forward<RemarkT>(R); |
680 | 646 | } |
681 | 647 |
|
682 | 648 | template <class RemarkT> |
683 | | -RemarkT & |
684 | | -operator<<(RemarkT &R, |
685 | | - std::enable_if_t< |
686 | | - std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value, |
687 | | - DiagnosticInfoOptimizationBase::setExtraArgs> |
| 649 | +decltype(auto) |
| 650 | +operator<<(RemarkT &&R, |
| 651 | + std::enable_if_t<std::is_base_of_v<DiagnosticInfoOptimizationBase, |
| 652 | + std::remove_reference_t<RemarkT>>, |
| 653 | + DiagnosticInfoOptimizationBase::setExtraArgs> |
688 | 654 | EA) { |
689 | 655 | R.insert(EA); |
690 | | - return R; |
| 656 | + return std::forward<RemarkT>(R); |
691 | 657 | } |
692 | 658 |
|
693 | 659 | /// Common features for diagnostics dealing with optimization remarks |
|
0 commit comments