// sed command does not work as-is on Windows.
// UNSUPPORTED: system-windows
// REQUIRES: custom-check

// Using cqc-main.cpp in the hope that we don't have a file with that name in
// our source tree. See: https://github.com/llvm/llvm-project/issues/182526
// RUN: sed -e "s:INPUT_DIR:%S/Inputs/custom-query-check:g" -e "s:OUT_DIR:%t:g" -e "s:MAIN_FILE:%s:g" %S/Inputs/custom-query-check/vfsoverlay.yaml > %t.yaml
// RUN: mkdir -p %t
// RUN: echo '[{"file": "cqc-main.cpp", "directory": "%t", "command": "clang++ -c cqc-main.cpp"}]' > %t/compile_commands.json
// RUN: clang-tidy --experimental-custom-checks %t/cqc-main.cpp -checks='-*,custom-*' -vfsoverlay %t.yaml | FileCheck %s --check-prefix=CHECK-SAME-DIR
// RUN: clang-tidy --experimental-custom-checks %t/subdir/cqc-main.cpp -checks='-*,custom-*' -vfsoverlay %t.yaml | FileCheck %s --check-prefix=CHECK-SUB-DIR-BASE
// RUN: clang-tidy --experimental-custom-checks %t/subdir-override/cqc-main.cpp -checks='-*,custom-*' -vfsoverlay %t.yaml | FileCheck %s --check-prefix=CHECK-SUB-DIR-OVERRIDE
// RUN: clang-tidy --experimental-custom-checks %t/subdir-empty/cqc-main.cpp -checks='-*,custom-*' -vfsoverlay %t.yaml --allow-no-checks | FileCheck %s --check-prefix=CHECK-SUB-DIR-EMPTY
// RUN: clang-tidy --experimental-custom-checks %t/subdir-append/cqc-main.cpp -checks='-*,custom-*' -vfsoverlay %t.yaml | FileCheck %s --check-prefix=CHECK-SUB-DIR-APPEND
// RUN: clang-tidy --experimental-custom-checks %t/subdir-append/cqc-main.cpp -checks='-*,custom-*' -vfsoverlay %t.yaml --list-checks | FileCheck %s --check-prefix=LIST-CHECK
// RUN: clang-tidy --experimental-custom-checks %t/subdir-append/cqc-main.cpp -checks='-*,custom-*' -vfsoverlay %t.yaml --dump-config | FileCheck %s --check-prefix=DUMP-CONFIG


long V;
// CHECK-SAME-DIR: [[@LINE-1]]:1: warning: use 'int' instead of 'long' [custom-avoid-long-type]
// CHECK-SUB-DIR-BASE: [[@LINE-2]]:1: warning: use 'int' instead of 'long' [custom-avoid-long-type]
// CHECK-SUB-DIR-OVERRIDE: [[@LINE-3]]:1: warning: use 'int' instead of 'long' override [custom-avoid-long-type]
// CHECK-SUB-DIR-EMPTY: No checks enabled.
// CHECK-SUB-DIR-APPEND: [[@LINE-5]]:1: warning: use 'int' instead of 'long' [custom-avoid-long-type]

void f();
// CHECK-SUB-DIR-APPEND: [[@LINE-1]]:1: warning: find function decl [custom-function-decl]

// LIST-CHECK: Enabled checks:
// LIST-CHECK:   custom-avoid-long-type
// LIST-CHECK:   custom-function-decl

// DUMP-CONFIG: CustomChecks:
// DUMP-CONFIG: - Name: avoid-long-type
// DUMP-CONFIG:   Query: |
// DUMP-CONFIG:     match varDecl(
// DUMP-CONFIG:       hasType(asString("long")),
// DUMP-CONFIG:       hasTypeLoc(typeLoc().bind("long"))
// DUMP-CONFIG:     )
// DUMP-CONFIG:   Diagnostic:
// DUMP-CONFIG:    - BindName: long
// DUMP-CONFIG:      Message: |
// DUMP-CONFIG:           use 'int' instead of 'long'
// DUMP-CONFIG:      Level:           Warning
// DUMP-CONFIG: - Name: function-decl
// DUMP-CONFIG:   Query: |
// DUMP-CONFIG:     match functionDecl().bind("func")
// DUMP-CONFIG:   Diagnostic:
// DUMP-CONFIG:    - BindName: func
// DUMP-CONFIG:      Message: |
// DUMP-CONFIG:        find function decl
// DUMP-CONFIG:   Level: Warning
