Page MenuHomePhabricator

[clang-format] Fix breaking of qualified operator
ClosedPublic

Authored by krasimir on Feb 1 2019, 10:39 AM.

Details

Summary

From https://bugs.llvm.org/show_bug.cgi?id=40516

$ cat a.cpp
const NamespaceName::VeryLongClassName &NamespaceName::VeryLongClassName::myFunction() {
  // do stuff
}

const NamespaceName::VeryLongClassName &NamespaceName::VeryLongClassName::operator++() {
  // do stuff
}
$ ~/ll/build/opt/bin/clang-format -style=LLVM a.cpp
const NamespaceName::VeryLongClassName &
NamespaceName::VeryLongClassName::myFunction() {
  // do stuff
}

const NamespaceName::VeryLongClassName &NamespaceName::VeryLongClassName::
operator++() {
  // do stuff
}

What was happening is that the split penalty before operator was being set to
a smaller value by a prior if block. Moved checks around to fix this and added a
regression test.

Diff Detail

Repository
rC Clang

Event Timeline

krasimir created this revision.Feb 1 2019, 10:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 1 2019, 10:39 AM
krasimir edited the summary of this revision. (Show Details)Feb 1 2019, 10:41 AM
krasimir updated this revision to Diff 184791.Feb 1 2019, 10:42 AM
  • Format tests
djasper accepted this revision.Feb 1 2019, 2:17 PM

Thank you.

This revision is now accepted and ready to land.Feb 1 2019, 2:17 PM
This revision was automatically updated to reflect the committed changes.