summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/Format.cpp
diff options
context:
space:
mode:
authorMartin Probst <martin@probst.io>2017-05-29 08:41:11 +0000
committerMartin Probst <martin@probst.io>2017-05-29 08:41:11 +0000
commit816a9668bb6c56b5fae96cbe6ca8c33aa90be1e5 (patch)
tree6f575887b876a0e3ef3e2f59d66a9e015854ab7b /clang/lib/Format/Format.cpp
parent3b189d1643fe788ec4792984758a2c0bcaac1b36 (diff)
downloadbcm5719-llvm-816a9668bb6c56b5fae96cbe6ca8c33aa90be1e5.tar.gz
bcm5719-llvm-816a9668bb6c56b5fae96cbe6ca8c33aa90be1e5.zip
clang-format: [JS] do not clean up duplicated commas.
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. Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D33641 llvm-svn: 304141
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r--clang/lib/Format/Format.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 4fa0012f51f..2ef6516e02e 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1910,6 +1910,9 @@ tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
tooling::Replacements cleanup(const FormatStyle &Style, StringRef Code,
ArrayRef<tooling::Range> Ranges,
StringRef FileName) {
+ // cleanups only apply to C++ (they mostly concern ctor commas etc.)
+ if (Style.Language != FormatStyle::LK_Cpp)
+ return tooling::Replacements();
std::unique_ptr<Environment> Env =
Environment::CreateVirtualEnvironment(Code, FileName, Ranges);
Cleaner Clean(*Env, Style);
OpenPOWER on IntegriCloud