[PATCH] D28844: clang-format: fix fallback style set to "none" not formatting

Daniel Jasper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 17 22:35:36 PST 2017

djasper accepted this revision.
djasper added inline comments.
This revision is now accepted and ready to land.

Comment at: lib/Format/Format.cpp:1906
-  // FIXME: If FallbackStyle is explicitly "none", format is disabled.
-  if (!getPredefinedStyle(FallbackStyle, Style.Language, &Style))
-    return make_string_error("Invalid fallback style \"" + FallbackStyle.str());
+  FormatStyle FallbackStyle = getNoStyle();
+  if (!getPredefinedStyle(FallbackStyleName, Style.Language, &FallbackStyle))
amaiorano wrote:
> Technically, we don't need to initialize FallbackStyle to getNoStyle() here as the call to getPredefinedStyle just below will initialize it. Let me know what you would prefer here.
This seems fine.

Comment at: test/Format/style-on-command-line.cpp:15
+// RUN: rm %T/_clang-format
+// RUN: clang-format -style=file -fallback-style=WebKit -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK10 %s
+// RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK11 %s
amaiorano wrote:
> Tests no config file found, WebKit fallback style is applied
Please put these into comments (as long as they don't start with "RUN", they should be just left alone as normal comments.


More information about the cfe-commits mailing list