1 | // RUN: %check_clang_tidy %s misc-misleading-bidirectional %t |
2 | |
3 | void func(void) { |
4 | int admin = 0; |
5 | /* }if(admin) begin*/ |
6 | // CHECK-MESSAGES: :[[#@LINE-1]]:3: warning: comment contains misleading bidirectional Unicode characters [misc-misleading-bidirectional] |
7 | const char msg[] = "if(admin) tes" ; |
8 | // CHECK-MESSAGES: :[[#@LINE-1]]:22: warning: string literal contains misleading bidirectional Unicode characters [misc-misleading-bidirectional] |
9 | } |
10 | |
11 | void all_fine(void) { |
12 | char valid[] = "somevalidsequence" ; |
13 | /* EOL ends bidi sequence |
14 | * end it's fine to do so. |
15 | * EOL ends isolate too |
16 | */ |
17 | } |
18 | |
19 | int invalid_utf_8(void) { |
20 | bool isAdmin = false; |
21 | |
22 | // the comment below contains an invalid utf8 character, but should still be |
23 | // processed. |
24 | |
25 | // CHECK-MESSAGES: :[[#@LINE+1]]:3: warning: comment contains misleading bidirectional Unicode characters [misc-misleading-bidirectional] |
26 | /* } if (isAdmin) begin admins only */ |
27 | return 1; |
28 | /* end admins only { */ |
29 | // CHECK-MESSAGES: :[[#@LINE-1]]:3: warning: comment contains misleading bidirectional Unicode characters [misc-misleading-bidirectional] |
30 | return 0; |
31 | } |
32 | |
33 | // CHECK-MESSAGES: :[[#@LINE+1]]:19: warning: string literal contains misleading bidirectional Unicode characters [misc-misleading-bidirectional] |
34 | char invalid1[] = "" ; |
35 | |
36 | // Test that segment and paragraph separator correctly reset the state |
37 | char valid1[] = R"||( |
38 | )||" ; |
39 | |
40 | |