[sanitizer] Improve FreeBSD ASLR detection
[llvm-project.git] / clang-tools-extra / test / clang-tidy / infrastructure / export-diagnostics.cpp
blob033798ceec46d88d15a1d78c427729a91eba9afa
1 // RUN: grep -Ev "// *[A-Z-]+:" %s > %t-input.cpp
2 // RUN: not clang-tidy %t-input.cpp -checks='-*,google-explicit-constructor,clang-diagnostic-missing-prototypes,clang-diagnostic-zero-length-array' -export-fixes=%t.yaml -- -Wmissing-prototypes -Wzero-length-array > %t.msg 2>&1
3 // RUN: FileCheck -input-file=%t.msg -check-prefix=CHECK-MESSAGES %s -implicit-check-not='{{warning|error|note}}:'
4 // RUN: FileCheck -input-file=%t.yaml -check-prefix=CHECK-YAML %s
5 #define X(n) void n ## n() {}
6 X(f)
7 int a[-1];
8 int b[0];
10 void test(x);
11 struct Foo {
12 member;
15 // CHECK-MESSAGES: -input.cpp:2:1: warning: no previous prototype for function 'ff' [clang-diagnostic-missing-prototypes]
16 // CHECK-MESSAGES: -input.cpp:1:19: note: expanded from macro 'X'
17 // CHECK-MESSAGES: {{^}}note: expanded from here{{$}}
18 // CHECK-MESSAGES: -input.cpp:2:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
19 // CHECK-MESSAGES: -input.cpp:1:14: note: expanded from macro 'X'
20 // CHECK-MESSAGES: -input.cpp:3:7: error: 'a' declared as an array with a negative size [clang-diagnostic-error]
21 // CHECK-MESSAGES: -input.cpp:4:7: warning: zero size arrays are an extension [clang-diagnostic-zero-length-array]
22 // CHECK-MESSAGES: -input.cpp:6:11: error: unknown type name 'x' [clang-diagnostic-error]
23 // CHECK-MESSAGES: -input.cpp:8:3: error: C++ requires a type specifier for all declarations [clang-diagnostic-error]
25 // CHECK-YAML: ---
26 // CHECK-YAML-NEXT: MainSourceFile: '{{.*}}-input.cpp'
27 // CHECK-YAML-NEXT: Diagnostics:
28 // CHECK-YAML-NEXT: - DiagnosticName: clang-diagnostic-missing-prototypes
29 // CHECK-YAML-NEXT: DiagnosticMessage:
30 // CHECK-YAML-NEXT: Message: 'no previous prototype for function ''ff'''
31 // CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp'
32 // CHECK-YAML-NEXT: FileOffset: 30
33 // CHECK-YAML-NEXT: Replacements: []
34 // CHECK-YAML-NEXT: Notes:
35 // CHECK-YAML-NEXT: - Message: 'expanded from macro ''X'''
36 // CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp'
37 // CHECK-YAML-NEXT: FileOffset: 18
38 // CHECK-YAML-NEXT: Replacements: []
39 // CHECK-YAML-NEXT: - Message: expanded from here
40 // CHECK-YAML-NEXT: FilePath: ''
41 // CHECK-YAML-NEXT: FileOffset: 0
42 // CHECK-YAML-NEXT: Replacements: []
43 // CHECK-YAML-NEXT: - Message: 'declare ''static'' if the function is not intended to be used outside of this translation unit'
44 // CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp'
45 // CHECK-YAML-NEXT: FileOffset: 30
46 // CHECK-YAML-NEXT: Replacements:
47 // CHECK-YAML-NEXT: - FilePath: '{{.*}}-input.cpp'
48 // CHECK-YAML-NEXT: Offset: 30
49 // CHECK-YAML-NEXT: Length: 0
50 // CHECK-YAML-NEXT: ReplacementText: 'static '
51 // CHECK-YAML-NEXT: - Message: 'expanded from macro ''X'''
52 // CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp'
53 // CHECK-YAML-NEXT: FileOffset: 13
54 // CHECK-YAML-NEXT: Replacements: []
55 // CHECK-YAML-NEXT: Level: Warning
56 // CHECK-YAML-NEXT: BuildDirectory: '{{.*}}'
57 // CHECK-YAML-NEXT: - DiagnosticName: clang-diagnostic-error
58 // CHECK-YAML-NEXT: DiagnosticMessage:
59 // CHECK-YAML-NEXT: Message: '''a'' declared as an array with a negative size'
60 // CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp'
61 // CHECK-YAML-NEXT: FileOffset: 41
62 // CHECK-YAML-NEXT: Replacements: []
63 // CHECK-YAML-NEXT: Ranges:
64 // CHECK-YAML-NEXT: - FilePath: '{{.*}}-input.cpp'
65 // CHECK-YAML-NEXT: FileOffset: 41
66 // CHECK-YAML-NEXT: Length: 2
67 // CHECK-YAML-NEXT: Level: Error
68 // CHECK-YAML-NEXT: BuildDirectory: '{{.*}}'
69 // CHECK-YAML-NEXT: - DiagnosticName: clang-diagnostic-zero-length-array
70 // CHECK-YAML-NEXT: DiagnosticMessage:
71 // CHECK-YAML-NEXT: Message: zero size arrays are an extension
72 // CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp'
73 // CHECK-YAML-NEXT: FileOffset: 52
74 // CHECK-YAML-NEXT: Replacements: []
75 // CHECK-YAML-NEXT: Ranges:
76 // CHECK-YAML-NEXT: - FilePath: '{{.*}}-input.cpp'
77 // CHECK-YAML-NEXT: FileOffset: 52
78 // CHECK-YAML-NEXT: Length: 1
79 // CHECK-YAML-NEXT: Level: Warning
80 // CHECK-YAML-NEXT: BuildDirectory: '{{.*}}'
81 // CHECK-YAML-NEXT: - DiagnosticName: clang-diagnostic-error
82 // CHECK-YAML-NEXT: DiagnosticMessage:
83 // CHECK-YAML-NEXT: Message: 'unknown type name ''x'''
84 // CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp'
85 // CHECK-YAML-NEXT: FileOffset: 67
86 // CHECK-YAML-NEXT: Replacements: []
87 // CHECK-YAML-NEXT: Level: Error
88 // CHECK-YAML-NEXT: BuildDirectory: '{{.*}}'
89 // CHECK-YAML-NEXT: - DiagnosticName: clang-diagnostic-error
90 // CHECK-YAML-NEXT: DiagnosticMessage:
91 // CHECK-YAML-NEXT: Message: 'C++ requires a type specifier for all declarations'
92 // CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp'
93 // CHECK-YAML-NEXT: FileOffset: 86
94 // CHECK-YAML-NEXT: Replacements: []
95 // CHECK-YAML-NEXT: Level: Error
96 // CHECK-YAML-NEXT: BuildDirectory: '{{.*}}'
97 // CHECK-YAML-NEXT: ...