This is an archive of the discontinued LLVM Phabricator instance.

clang-format: [JS] improve calculateBraceType heuristic
ClosedPublic

Authored by mprobst on May 31 2017, 2:02 AM.

Details

Summary

calculateBraceTypes decides for braced init for empty brace pairs ({}). In context of a function declaration, this incorrectly classifies empty function or method bodies as braced inits, leading to missing wraps:

class C {
  foo() {}[bar]() {}
}

Where could should have wrapped after "}". This change adds another piece of contextual information in that braces following closing parentheses must always be the opening braces of function blocks. This fixes brace detection for methods immediately followed by brackets (computed property declarations), but also curlies.

Diff Detail

Repository
rL LLVM

Event Timeline

mprobst created this revision.May 31 2017, 2:02 AM
klimek accepted this revision.May 31 2017, 2:05 AM

Apart from fixme LG.

lib/Format/UnwrappedLineParser.cpp
397 ↗(On Diff #100837)

Here we call them FIXME and put them without a name:
// FIXME: ...

This revision is now accepted and ready to land.May 31 2017, 2:05 AM
mprobst updated this revision to Diff 100839.May 31 2017, 2:17 AM

TODO => FIXME

mprobst updated this revision to Diff 100840.May 31 2017, 2:28 AM
  • restrict to JS, C++ actually wants this.
This revision was automatically updated to reflect the committed changes.