summaryrefslogtreecommitdiffstats
path: root/lib/Format
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
commitec038a4a53332cd1b2d9dc1379d6e654a107399a (patch)
treeedd6bd75382fe6a0e241c83ff7679074d90fe284 /lib/Format
parentac4917bc8b8e6b9b05fdd4c956350df0ed6a1c1c (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304141 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format')
-rw-r--r--lib/Format/Format.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index 4fa0012f51..2ef6516e02 100644
--- a/lib/Format/Format.cpp
+++ b/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);