summaryrefslogtreecommitdiffstats
path: root/clang/test/Format/style-on-command-line.cpp
diff options
context:
space:
mode:
authorAntonio Maiorano <amaiorano@gmail.com>2017-01-20 01:22:42 +0000
committerAntonio Maiorano <amaiorano@gmail.com>2017-01-20 01:22:42 +0000
commit7eb7507aeb3552400c8a1f4dc82bb2212260c0da (patch)
treec1ba9c2444db29d3053228ac84cca3e5f28335a3 /clang/test/Format/style-on-command-line.cpp
parent187ffb4a8e13dafb90b7f371325065d0d648a4a1 (diff)
downloadbcm5719-llvm-7eb7507aeb3552400c8a1f4dc82bb2212260c0da.tar.gz
bcm5719-llvm-7eb7507aeb3552400c8a1f4dc82bb2212260c0da.zip
clang-format: fix fallback style set to "none" not always formatting
This fixes clang-format not formatting if fallback-style is explicitly set to "none", and either a config file is found or YAML is passed in without a "BasedOnStyle". With this change, passing "none" in these cases will have no affect, and LLVM style will be used as the base style. Differential Revision: https://reviews.llvm.org/D28844 llvm-svn: 292562
Diffstat (limited to 'clang/test/Format/style-on-command-line.cpp')
-rw-r--r--clang/test/Format/style-on-command-line.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/test/Format/style-on-command-line.cpp b/clang/test/Format/style-on-command-line.cpp
index 0d2d69206dc..441797f2060 100644
--- a/clang/test/Format/style-on-command-line.cpp
+++ b/clang/test/Format/style-on-command-line.cpp
@@ -11,6 +11,21 @@
// RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK7 %s
// RUN: clang-format -style="{BasedOnStyle: LLVM, PointerBindsToType: true}" %s | FileCheck -strict-whitespace -check-prefix=CHECK8 %s
// RUN: clang-format -style="{BasedOnStyle: WebKit, PointerBindsToType: false}" %s | FileCheck -strict-whitespace -check-prefix=CHECK9 %s
+
+// Fallback style tests
+// RUN: rm %T/_clang-format
+// Test no config file found, WebKit fallback style is applied
+// RUN: clang-format -style=file -fallback-style=WebKit -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK10 %s
+// Test no config file and no fallback style, LLVM style is applied
+// RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK11 %s
+// Test no config file and fallback style "none", no formatting is applied
+// RUN: clang-format -style=file -fallback-style=none -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK12 %s
+// Test config file with no based style, and fallback style "none", formatting is applied
+// RUN: printf "IndentWidth: 6\n" > %T/_clang-format
+// RUN: clang-format -style=file -fallback-style=none -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK13 %s
+// Test yaml with no based style, and fallback style "none", LLVM formatting applied
+// RUN: clang-format -style="{IndentWidth: 7}" -fallback-style=none %s | FileCheck -strict-whitespace -check-prefix=CHECK14 %s
+
void f() {
// CHECK1: {{^ int\* i;$}}
// CHECK2: {{^ int \*i;$}}
@@ -22,6 +37,11 @@ void f() {
// CHECK7: {{^ int\* i;$}}
// CHECK8: {{^ int\* i;$}}
// CHECK9: {{^ int \*i;$}}
+// CHECK10: {{^ int\* i;$}}
+// CHECK11: {{^ int \*i;$}}
+// CHECK12: {{^int\*i;$}}
+// CHECK13: {{^ int \*i;$}}
+// CHECK14: {{^ int \*i;$}}
int*i;
int j;
}
OpenPOWER on IntegriCloud