summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/Format.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/lib/Format/Format.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/lib/Format/Format.cpp')
-rw-r--r--clang/lib/Format/Format.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index e793d003ff6..82647b6b2e3 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1888,8 +1888,8 @@ static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) {
}
llvm::Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
- StringRef FallbackStyle, StringRef Code,
- vfs::FileSystem *FS) {
+ StringRef FallbackStyleName,
+ StringRef Code, vfs::FileSystem *FS) {
if (!FS) {
FS = vfs::getRealFileSystem().get();
}
@@ -1903,9 +1903,9 @@ llvm::Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
(Code.contains("\n- (") || Code.contains("\n+ (")))
Style.Language = FormatStyle::LK_ObjC;
- // 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))
+ return make_string_error("Invalid fallback style \"" + FallbackStyleName);
if (StyleName.startswith("{")) {
// Parse YAML/JSON style from the command line.
@@ -1977,7 +1977,7 @@ llvm::Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
return make_string_error("Configuration file(s) do(es) not support " +
getLanguageName(Style.Language) + ": " +
UnsuitableConfigFiles);
- return Style;
+ return FallbackStyle;
}
} // namespace format
OpenPOWER on IntegriCloud