Skip to content

AlwaysBreakAfterReturnType works incorrectly for some operator functions #35642

@llvmbot

Description

@llvmbot
Bugzilla Link 36294
Resolution FIXED
Resolved on Mar 30, 2020 07:35
Version trunk
OS All
Depends On #44702 #44703
Reporter LLVM Bugzilla Contributor
CC @mjacobse,@mydeveloperday
Fixed by commit(s) rGa75f8d98d7ac9e557b238a229a9a2647c71feed1

Extended Description

Tried it with the latest trunk code.

$ cat /tmp/foo.cpp
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; }

$ bin/clang-format --style="{BasedOnStyle: llvm, AlwaysBreakAfterReturnType: TopLevelDefinitions}" /tmp/foo.cpp
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;
}

As you can see there is no break after the return type for the operators !, * and ->

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions