Skip to content

Commit 0df6f7e

Browse files
committed
test
1 parent dba8a8c commit 0df6f7e

File tree

6 files changed

+120
-0
lines changed

6 files changed

+120
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
InheritParentConfig: true
2+
CustomeChecks:
3+
- Name: function-decl
4+
Query: match functionDecl().bind("func")
5+
Diagnostic:
6+
- BindName: func
7+
Message: find function decl
8+
Level: Warning
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
InheritParentConfig: false
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CustomeChecks:
2+
- Name: avoid-long-type
3+
Query: |
4+
match varDecl(
5+
hasType(asString("long")),
6+
hasTypeLoc(typeLoc().bind("long"))
7+
)
8+
Diagnostic:
9+
- BindName: long
10+
Message: use 'int' instead of 'long' override
11+
Level: Warning
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CustomeChecks:
2+
- Name: avoid-long-type
3+
Query: |
4+
match varDecl(
5+
hasType(asString("long")),
6+
hasTypeLoc(typeLoc().bind("long"))
7+
)
8+
Diagnostic:
9+
- BindName: long
10+
Message: use 'int' instead of 'long'
11+
Level: Warning
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
version: 0
2+
roots:
3+
- name: OUT_DIR
4+
type: directory
5+
contents:
6+
- name: .clang-tidy
7+
type: file
8+
external-contents: INPUT_DIR/root-clang-tidy.yml
9+
- name: main.cpp
10+
type: file
11+
external-contents: MAIN_FILE
12+
- name: subdir
13+
type: directory
14+
contents:
15+
- name: main.cpp
16+
type: file
17+
external-contents: MAIN_FILE
18+
- name: subdir-override
19+
type: directory
20+
contents:
21+
- name: main.cpp
22+
type: file
23+
external-contents: MAIN_FILE
24+
- name: .clang-tidy
25+
type: file
26+
external-contents: INPUT_DIR/override-clang-tidy.yml
27+
- name: subdir-empty
28+
type: directory
29+
contents:
30+
- name: main.cpp
31+
type: file
32+
external-contents: MAIN_FILE
33+
- name: .clang-tidy
34+
type: file
35+
external-contents: INPUT_DIR/empty-clang-tidy.yml
36+
- name: subdir-append
37+
type: directory
38+
contents:
39+
- name: main.cpp
40+
type: file
41+
external-contents: MAIN_FILE
42+
- name: .clang-tidy
43+
type: file
44+
external-contents: INPUT_DIR/append-clang-tidy.yml
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// 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
2+
// RUN: clang-tidy %t/main.cpp -checks='-*,custom-*' -vfsoverlay %t.yaml | FileCheck %s --check-prefix=CHECK-SAME-DIR
3+
// RUN: clang-tidy %t/subdir/main.cpp -checks='-*,custom-*' -vfsoverlay %t.yaml | FileCheck %s --check-prefix=CHECK-SUB-DIR-BASE
4+
// RUN: clang-tidy %t/subdir-override/main.cpp -checks='-*,custom-*' -vfsoverlay %t.yaml | FileCheck %s --check-prefix=CHECK-SUB-DIR-OVERRIDE
5+
// RUN: clang-tidy %t/subdir-empty/main.cpp -checks='-*,custom-*' -vfsoverlay %t.yaml --allow-no-checks | FileCheck %s --check-prefix=CHECK-SUB-DIR-EMPTY
6+
// RUN: clang-tidy %t/subdir-append/main.cpp -checks='-*,custom-*' -vfsoverlay %t.yaml | FileCheck %s --check-prefix=CHECK-SUB-DIR-APPEND
7+
// RUN: clang-tidy %t/subdir-append/main.cpp -checks='-*,custom-*' -vfsoverlay %t.yaml --list-checks | FileCheck %s --check-prefix=LIST-CHECK
8+
// RUN: clang-tidy %t/subdir-append/main.cpp -checks='-*,custom-*' -vfsoverlay %t.yaml --dump-config | FileCheck %s --check-prefix=DUMP-CONFIG
9+
// REQUIRES: shell
10+
11+
12+
long V;
13+
// CHECK-SAME-DIR: [[@LINE-1]]:1: warning: use 'int' instead of 'long' [custom-avoid-long-type]
14+
// CHECK-SUB-DIR-BASE: [[@LINE-2]]:1: warning: use 'int' instead of 'long' [custom-avoid-long-type]
15+
// CHECK-SUB-DIR-OVERRIDE: [[@LINE-3]]:1: warning: use 'int' instead of 'long' override [custom-avoid-long-type]
16+
// CHECK-SUB-DIR-EMPTY: No checks enabled.
17+
// CHECK-SUB-DIR-APPEND: [[@LINE-5]]:1: warning: use 'int' instead of 'long' [custom-avoid-long-type]
18+
19+
void f();
20+
// CHECK-SUB-DIR-APPEND: [[@LINE-1]]:1: warning: find function decl [custom-function-decl]
21+
22+
// LIST-CHECK: Enabled checks:
23+
// LIST-CHECK: custom-avoid-long-type
24+
// LIST-CHECK: custom-function-decl
25+
26+
// DUMP-CONFIG: CustomeChecks:
27+
// DUMP-CONFIG: - Name: avoid-long-type
28+
// DUMP-CONFIG: Query: |
29+
// DUMP-CONFIG: match varDecl(
30+
// DUMP-CONFIG: hasType(asString("long")),
31+
// DUMP-CONFIG: hasTypeLoc(typeLoc().bind("long"))
32+
// DUMP-CONFIG: )
33+
// DUMP-CONFIG: Diagnostic:
34+
// DUMP-CONFIG: - BindName: long
35+
// DUMP-CONFIG: Message: |
36+
// DUMP-CONFIG: use 'int' instead of 'long'
37+
// DUMP-CONFIG: Level: Warning
38+
// DUMP-CONFIG: - Name: function-decl
39+
// DUMP-CONFIG: Query: |
40+
// DUMP-CONFIG: match functionDecl().bind("func")
41+
// DUMP-CONFIG: Diagnostic:
42+
// DUMP-CONFIG: - BindName: func
43+
// DUMP-CONFIG: Message: |
44+
// DUMP-CONFIG: find function decl
45+
// DUMP-CONFIG: Level: Warning

0 commit comments

Comments
 (0)