[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Format / style-on-command-line.cpp
blobce2577beec86a3f12f4d237cf4ddf48a64816bbe
1 // RUN: clang-format -style="{BasedOnStyle: Google, IndentWidth: 8}" %s | FileCheck -strict-whitespace -check-prefix=CHECK1 %s
2 // RUN: clang-format -style="{BasedOnStyle: LLVM, IndentWidth: 7}" %s | FileCheck -strict-whitespace -check-prefix=CHECK2 %s
3 // RUN: not clang-format -style="{BasedOnStyle: invalid, IndentWidth: 7}" -fallback-style=LLVM %s 2>&1 | FileCheck -DMSG=%errc_EINVAL -strict-whitespace -check-prefix=CHECK3 %s
4 // RUN: not clang-format -style="{lsjd}" %s -fallback-style=LLVM 2>&1 | FileCheck -DMSG=%errc_EINVAL -strict-whitespace -check-prefix=CHECK4 %s
5 // RUN: mkdir -p %t
6 // RUN: printf "BasedOnStyle: google\nIndentWidth: 5\n" > %t/.clang-format
7 // RUN: clang-format -style=file -assume-filename=%t/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK5 %s
8 // RUN: printf "Invalid:\n" > %t/.clang-format
9 // RUN: not clang-format -style=file -fallback-style=webkit -assume-filename=%t/foo.cpp < %s 2>&1 | FileCheck -DMSG=%errc_EINVAL -strict-whitespace -check-prefix=CHECK6 %s
10 // RUN: rm %t/.clang-format
11 // RUN: printf "BasedOnStyle: google\nIndentWidth: 6\n" > %t/_clang-format
12 // RUN: clang-format -style=file -assume-filename=%t/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK7 %s
13 // RUN: clang-format -style="{BasedOnStyle: LLVM, PointerBindsToType: true}" %s | FileCheck -strict-whitespace -check-prefix=CHECK8 %s
14 // RUN: clang-format -style="{BasedOnStyle: WebKit, PointerBindsToType: false}" %s | FileCheck -strict-whitespace -check-prefix=CHECK9 %s
16 // Fallback style tests
17 // Test config file with no based style, and fallback style "none", formatting is applied
18 // RUN: printf "IndentWidth: 6\n" > %t/_clang-format
19 // RUN: clang-format -style=file -fallback-style=none -assume-filename=%t/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK10 %s
20 // Test yaml with no based style, and fallback style "none", LLVM formatting applied
21 // RUN: clang-format -style="{IndentWidth: 7}" -fallback-style=none %s | FileCheck -strict-whitespace -check-prefix=CHECK11 %s
23 // Empty config file tests
24 // RUN: touch %t/.clang-format
25 // RUN: clang-format -style=file -assume-filename=%t/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK12 %s
26 // RUN: rm %t/.clang-format
27 // RUN: printf "\n" > %t/_clang-format
28 // RUN: clang-format -style=file -assume-filename=%t/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK13 %s
30 void f() {
31 // CHECK1: {{^ int\* i;$}}
32 // CHECK2: {{^ int \*i;$}}
33 // CHECK3: Unknown value for BasedOnStyle: invalid
34 // CHECK3: Error parsing -style: [[MSG]]
35 // CHECK4: Error parsing -style: [[MSG]]
36 // CHECK5: {{^ int\* i;$}}
37 // CHECK6: unknown key 'Invalid'
38 // CHECK6: {{^Error reading .*\.clang-format:}} [[MSG]]
39 // CHECK7: {{^ int\* i;$}}
40 // CHECK8: {{^ int\* i;$}}
41 // CHECK9: {{^ int \*i;$}}
42 // CHECK10: {{^ int \*i;$}}
43 // CHECK11: {{^ int \*i;$}}
44 // CHECK12: {{^ int \*i;$}}
45 // CHECK13: {{^ int \*i;$}}
46 int*i;
47 int j;
50 // On Windows, the 'rm' commands fail when the previous process is still alive.
51 // This happens enough to make the test useless.
52 // UNSUPPORTED: system-windows