1#include "foobar.h"
2
3int x = foo();
4
5// RUN: clang-include-cleaner -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=CHANGE %s
6// CHANGE: - "foobar.h"
7// CHANGE-NEXT: + "foo.h"
8
9// RUN: clang-include-cleaner -disable-remove -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=INSERT %s
10// INSERT-NOT: - "foobar.h"
11// INSERT: + "foo.h"
12
13// RUN: clang-include-cleaner -disable-insert -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=REMOVE %s
14// REMOVE: - "foobar.h"
15// REMOVE-NOT: + "foo.h"
16
17// RUN: clang-include-cleaner -print=changes %s --ignore-headers="foobar\.h,foo\.h" -- -I%S/Inputs/ | FileCheck --match-full-lines --allow-empty --check-prefix=IGNORE %s
18// IGNORE-NOT: - "foobar.h"
19// IGNORE-NOT: + "foo.h"
20
21// RUN: clang-include-cleaner -print=changes %s --ignore-headers="foobar.*\.h" -- -I%S/Inputs/ | FileCheck --match-full-lines --allow-empty --check-prefix=IGNORE2 %s
22// IGNORE2-NOT: - "foobar.h"
23// IGNORE2: + "foo.h"
24
25// RUN: clang-include-cleaner -print=changes %s --ignore-headers= -- -I%S/Inputs/ | FileCheck --allow-empty --check-prefix=IGNORE3 %s
26// IGNORE3: - "foobar.h"
27// IGNORE3: + "foo.h"
28
29// RUN: clang-include-cleaner -print=changes %s --only-headers="foo\.h" -- -I%S/Inputs/ | FileCheck --match-full-lines --allow-empty --check-prefix=ONLY %s
30// ONLY-NOT: - "foobar.h"
31// ONLY: + "foo.h"
32
33// RUN: clang-include-cleaner -print=changes %s --only-headers= -- -I%S/Inputs/ | FileCheck --allow-empty --check-prefix=ONLY2 %s
34// ONLY2: - "foobar.h"
35// ONLY2: + "foo.h"
36
37// RUN: clang-include-cleaner -print %s -- -I%S/Inputs/ | FileCheck --match-full-lines --check-prefix=PRINT %s
38// PRINT: #include "foo.h"
39// PRINT-NOT: {{^}}#include "foobar.h"{{$}}
40
41// RUN: cp %s %t.cpp
42// RUN: clang-include-cleaner -edit %t.cpp -- -I%S/Inputs/
43// RUN: FileCheck --match-full-lines --check-prefix=EDIT %s < %t.cpp
44// EDIT: #include "foo.h"
45// EDIT-NOT: {{^}}#include "foobar.h"{{$}}
46
47// RUN: cp %s %t.cpp
48// RUN: clang-include-cleaner -edit --ignore-headers="foobar\.h,foo\.h" %t.cpp -- -I%S/Inputs/
49// RUN: FileCheck --match-full-lines --check-prefix=EDIT2 %s < %t.cpp
50// EDIT2-NOT: {{^}}#include "foo.h"{{$}}
51
52// RUN: rm -rf %t.dir && mkdir -p %t.dir
53// RUN: cp %s %t.cpp
54// RUN: echo "[{\"directory\":\"%t.dir\",\"file\":\"../%{t:stem}.tmp.cpp\",\"command\":\":clang++ -I%S/Inputs/ ../%{t:stem}.tmp.cpp\"}]" | sed -e 's/\\/\\\\/g' > %t.dir/compile_commands.json
55// RUN: pushd %t.dir
56// RUN: clang-include-cleaner -p %{t:stem}.tmp.dir -edit ../%{t:stem}.tmp.cpp
57// RUN: popd
58// RUN: FileCheck --match-full-lines --check-prefix=EDIT3 %s < %t.cpp
59// EDIT3: #include "foo.h"
60// EDIT3-NOT: {{^}}#include "foobar.h"{{$}}
61
62// RUN: clang-include-cleaner -insert=false -print=changes %s -- -I%S/Inputs/ 2>&1 | \
63// RUN: FileCheck --check-prefix=DEPRECATED-INSERT %s
64// DEPRECATED-INSERT: warning: '-insert=0' is deprecated in favor of '-disable-insert'. The old flag was confusing since it suggested that inserts were disabled by default, when they were actually enabled.
65
66// RUN: clang-include-cleaner -remove=false -print=changes %s -- -I%S/Inputs/ 2>&1 | \
67// RUN: FileCheck --check-prefix=DEPRECATED-REMOVE %s
68// DEPRECATED-REMOVE: warning: '-remove=0' is deprecated in favor of '-disable-remove'. The old flag was confusing since it suggested that removes were disabled by default, when they were actually enabled.
69
70// RUN: clang-include-cleaner -insert=false -remove=false -print=changes %s -- -I%S/Inputs/ 2>&1 | \
71// RUN: FileCheck --check-prefix=DEPRECATED-BOTH %s
72// DEPRECATED-BOTH: warning: '-insert=0' is deprecated in favor of '-disable-insert'. The old flag was confusing since it suggested that inserts were disabled by default, when they were actually enabled.
73// DEPRECATED-BOTH: warning: '-remove=0' is deprecated in favor of '-disable-remove'. The old flag was confusing since it suggested that removes were disabled by default, when they were actually enabled.
74

source code of clang-tools-extra/include-cleaner/test/tool.cpp