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' -export-fixes=%t.yaml -- -Wmissing-prototypes > %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 9 // CHECK-MESSAGES: -input.cpp:2:1: warning: no previous prototype for function 'ff' [clang-diagnostic-missing-prototypes] 10 // CHECK-MESSAGES: -input.cpp:1:19: note: expanded from macro 'X' 11 // CHECK-MESSAGES: {{^}}note: expanded from here{{$}} 12 // CHECK-MESSAGES: -input.cpp:2:1: note: declare 'static' if the function is not intended to be used outside of this translation unit 13 // CHECK-MESSAGES: -input.cpp:1:14: note: expanded from macro 'X' 14 // CHECK-MESSAGES: -input.cpp:3:7: error: 'a' declared as an array with a negative size [clang-diagnostic-error] 15 16 // CHECK-YAML: --- 17 // CHECK-YAML-NEXT: MainSourceFile: '{{.*}}-input.cpp' 18 // CHECK-YAML-NEXT: Diagnostics: 19 // CHECK-YAML-NEXT: - DiagnosticName: clang-diagnostic-missing-prototypes 20 // CHECK-YAML-NEXT: DiagnosticMessage: 21 // CHECK-YAML-NEXT: Message: 'no previous prototype for function 22 // ''ff''' 23 // CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp' 24 // CHECK-YAML-NEXT: FileOffset: 30 25 // CHECK-YAML-NEXT: Replacements: [] 26 // CHECK-YAML-NEXT: Notes: 27 // CHECK-YAML-NEXT: - Message: 'expanded from macro ''X''' 28 // CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp' 29 // CHECK-YAML-NEXT: FileOffset: 18 30 // CHECK-YAML-NEXT: Replacements: [] 31 // CHECK-YAML-NEXT: - Message: expanded from here 32 // CHECK-YAML-NEXT: FilePath: '' 33 // CHECK-YAML-NEXT: FileOffset: 0 34 // CHECK-YAML-NEXT: Replacements: [] 35 // CHECK-YAML-NEXT: - Message: 'declare ''static'' if the function is not intended to be used outside of this translation unit' 36 // CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp' 37 // CHECK-YAML-NEXT: FileOffset: 30 38 // CHECK-YAML-NEXT: Replacements: 39 // CHECK-YAML-NEXT: - FilePath: '{{.*}}-input.cpp' 40 // CHECK-YAML-NEXT: Offset: 30 41 // CHECK-YAML-NEXT: Length: 0 42 // CHECK-YAML-NEXT: ReplacementText: 'static ' 43 // CHECK-YAML-NEXT: - Message: 'expanded from macro ''X''' 44 // CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp' 45 // CHECK-YAML-NEXT: FileOffset: 13 46 // CHECK-YAML-NEXT: Replacements: [] 47 // CHECK-YAML-NEXT: Level: Warning 48 // CHECK-YAML-NEXT: BuildDirectory: '{{.*}}' 49 // CHECK-YAML-NEXT: - DiagnosticName: clang-diagnostic-error 50 // CHECK-YAML-NEXT: DiagnosticMessage: 51 // CHECK-YAML-NEXT: Message: '''a'' declared as an array with a negative size' 52 // CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp' 53 // CHECK-YAML-NEXT: FileOffset: 41 54 // CHECK-YAML-NEXT: Replacements: [] 55 // CHECK-YAML-NEXT: Level: Error 56 // CHECK-YAML-NEXT: BuildDirectory: '{{.*}}' 57 // CHECK-YAML-NEXT: Ranges: 58 // CHECK-YAML-NEXT: - FilePath: '{{.*}}-input.cpp' 59 // CHECK-YAML-NEXT: FileOffset: 41 60 // CHECK-YAML-NEXT: Length: 1 61 // CHECK-YAML-NEXT: ... 62