forked from OSchip/llvm-project
[clang-format] Allow empty .clang-format file
Differential Revision: https://reviews.llvm.org/D123535
This commit is contained in:
parent
54a6cc3405
commit
0cb9c6ea83
|
@ -1722,7 +1722,7 @@ std::error_code parseConfiguration(llvm::MemoryBufferRef Config,
|
|||
FormatStyle::LanguageKind Language = Style->Language;
|
||||
assert(Language != FormatStyle::LK_None);
|
||||
if (Config.getBuffer().trim().empty())
|
||||
return make_error_code(ParseError::Error);
|
||||
return make_error_code(ParseError::Success);
|
||||
Style->StyleSet.Clear();
|
||||
std::vector<FormatStyle> Styles;
|
||||
llvm::yaml::Input Input(Config, /*Ctxt=*/nullptr, DiagHandler,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// RUN: mkdir -p %t
|
||||
// RUN: printf "BasedOnStyle: google\nIndentWidth: 5\n" > %t/.clang-format
|
||||
// RUN: clang-format -style=file -assume-filename=%t/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK5 %s
|
||||
// RUN: printf "\n" > %t/.clang-format
|
||||
// RUN: printf "Invalid:\n" > %t/.clang-format
|
||||
// RUN: not clang-format -style=file -fallback-style=webkit -assume-filename=%t/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK6 %s
|
||||
// RUN: rm %t/.clang-format
|
||||
// RUN: printf "BasedOnStyle: google\nIndentWidth: 6\n" > %t/_clang-format
|
||||
|
@ -20,6 +20,13 @@
|
|||
// 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=CHECK11 %s
|
||||
|
||||
// Empty config file tests
|
||||
// RUN: touch %t/.clang-format
|
||||
// RUN: clang-format -style=file -assume-filename=%t/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK12 %s
|
||||
// RUN: rm %t/.clang-format
|
||||
// RUN: printf "\n" > %t/_clang-format
|
||||
// RUN: clang-format -style=file -assume-filename=%t/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK13 %s
|
||||
|
||||
void f() {
|
||||
// CHECK1: {{^ int\* i;$}}
|
||||
// CHECK2: {{^ int \*i;$}}
|
||||
|
@ -27,12 +34,15 @@ void f() {
|
|||
// CHECK3: Error parsing -style: [[MSG]]
|
||||
// CHECK4: Error parsing -style: [[MSG]]
|
||||
// CHECK5: {{^ int\* i;$}}
|
||||
// CHECK6: unknown key 'Invalid'
|
||||
// CHECK6: {{^Error reading .*\.clang-format: (I|i)nvalid argument}}
|
||||
// CHECK7: {{^ int\* i;$}}
|
||||
// CHECK8: {{^ int\* i;$}}
|
||||
// CHECK9: {{^ int \*i;$}}
|
||||
// CHECK10: {{^ int \*i;$}}
|
||||
// CHECK11: {{^ int \*i;$}}
|
||||
// CHECK12: {{^ int \*i;$}}
|
||||
// CHECK13: {{^ int \*i;$}}
|
||||
int*i;
|
||||
int j;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue