[PATCH] D69573: [clang-format] [PR36294] AlwaysBreakAfterReturnType works incorrectly for some operator functions

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 30 06:52:37 PDT 2019


MyDeveloperDay updated this revision to Diff 227083.
MyDeveloperDay marked 2 inline comments as done.
MyDeveloperDay added a comment.

Extend this revision to cover additional https://bugs.llvm.org/show_bug.cgi?id=43783 issue (which has overlap)

New revision correctly formats the following code:

  constexpr auto
  operator*() const -> reference {
    bfexpects_when_compliant(m_i < m_t->size());
    return m_t->get()[m_i];
  }
  
  constexpr auto
  operator->() const -> pointer {
    bfexpects_when_compliant(m_i < m_t->size());
    return &m_t->get()[m_i];
  }
  
  constexpr auto
  operator[](index_type n) const -> reference {
    bfexpects_when_compliant(m_i < m_t->size());
    return m_t->get()[m_i];
  }
  
  constexpr auto
  operator++() -> lra_iterator & {
    ++m_i;
    return *this;
  }
  
  constexpr auto
  operator()() const -> reference {}
  
  constexpr auto
  operator++() const -> reference {}
  
  constexpr auto
  operator--() const -> reference {}
  
  constexpr auto
  operator*() const -> reference {}
  
  constexpr auto
  operator->() const -> reference {}
  
  constexpr auto
  operator>>() const -> reference {}
  
  constexpr auto
  operator<<() const -> reference {}
  
  constexpr auto
  operator[]() const -> reference {}
  
  constexpr auto
  operator void*() const -> reference {}
  
  constexpr auto
  operator char*() const -> reference {}
  
  constexpr auto
  operator Foo*() const -> reference {}
  
  constexpr auto
  operator!() const -> reference {}
  
  class Foo {
  public:
    bool operator!() const;
    bool operator<(Foo const &) const;
    bool operator*() const;
    bool operator->() const;
    bool operator+() const;
    bool operator-() const;
    bool f() const;
  };
  
  bool
  Foo::operator!() const {
    return true;
  }
  bool
  Foo::operator<(Foo const &) const {
    return true;
  }
  bool
  Foo::operator*() const {
    return true;
  }
  bool
  Foo::operator->() const {
    return true;
  }
  bool
  Foo::operator+() const {
    return true;
  }
  bool
  Foo::operator-() const {
    return true;
  }
  bool
  Foo::f() const {
    return true;
  }


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69573/new/

https://reviews.llvm.org/D69573

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69573.227083.patch
Type: text/x-patch
Size: 4869 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191030/d51c80f3/attachment.bin>


More information about the cfe-commits mailing list