This is an archive of the discontinued LLVM Phabricator instance.

clang-format: [JS] do not clean up duplicated commas.
ClosedPublic

Authored by mprobst on May 29 2017, 1:26 AM.

Details

Summary

In JavaScript, duplicated commas have semantic meaning.

x = [a,,b];

The statement above creates an array with three entries, the middle being undefined. Because clang-format should not change semantics, disable this cleanup in JS.

Diff Detail

Repository
rL LLVM

Event Timeline

mprobst created this revision.May 29 2017, 1:26 AM
mprobst updated this revision to Diff 100593.May 29 2017, 1:27 AM
  • strip debug statements
djasper added inline comments.May 29 2017, 1:27 AM
lib/Format/Format.cpp
1085 ↗(On Diff #100592)

As all the cleanups that aren't comma clean ups are cleanups for constructor initializers, I think we should just completely opt out of cleans for JavaScript for now?

mprobst updated this revision to Diff 100595.May 29 2017, 1:38 AM
  • disable all cleanups in JS.
mprobst added inline comments.May 29 2017, 1:40 AM
lib/Format/Format.cpp
1085 ↗(On Diff #100592)

Agreed, done.

djasper accepted this revision.May 29 2017, 1:40 AM
djasper added inline comments.
lib/Format/Format.cpp
1914 ↗(On Diff #100595)

Maybe we should actually use Style.Language.isCpp(). These cleanups aren't tested for any other language.

This revision is now accepted and ready to land.May 29 2017, 1:40 AM
mprobst updated this revision to Diff 100596.May 29 2017, 1:41 AM
  • only clean up C++
This revision was automatically updated to reflect the committed changes.